/* The alphabet study stays on the typography case's paper surface. */
[data-rui-editorial-case="typography"] [data-alphabet-study] {
  --rui-alphabet-paper: var(--rui-numi-paper, #f8f7ee);
  --rui-alphabet-ink: var(--rui-numi-charcoal, #302748);
  --rui-alphabet-muted: var(--rui-numi-sage, #405c73);
  --rui-alphabet-accent: var(--rui-numi-tea, #a52d48);
  --rui-alphabet-line: var(--rui-numi-line, rgba(48, 39, 72, .2));
  position: relative;
  width: 100%;
  max-width: 80rem;
  margin: clamp(3rem, 8vw, 7rem) auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) 0;
  color: var(--rui-alphabet-ink);
  background: var(--rui-alphabet-paper);
  border-block: 1px solid var(--rui-alphabet-line);
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 812px;
  margin-inline: auto;
  width: 100%;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame] {
  grid-area: 1 / 1;
  min-width: 0;
  width: 100%;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  transition: opacity .5s cubic-bezier(.22, 1, .36, 1), transform .5s cubic-bezier(.22, 1, .36, 1);
  will-change: opacity, transform;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame][data-alphabet-active="true"],
[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame].is-entering {
  z-index: 2;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame].is-leaving {
  z-index: 1;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame][hidden] {
  display: none !important;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame].is-entering {
  opacity: 0;
  transform: translate3d(0, .75rem, 0);
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame].is-leaving {
  opacity: 0;
  transform: translate3d(0, -.35rem, 0);
  pointer-events: none;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-specimens] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
}

/* The generator may keep the two figures directly in the frame; retain the
   same pair layout without requiring an extra wrapper element. */
[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: start;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame] > .rui-alphabet-specimens {
  grid-column: 1 / -1;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame] > .rui-alphabet-specimen {
  min-width: 0;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  margin: 0;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen svg {
  display: block;
  width: 100%;
  max-width: 386px;
  height: auto;
  overflow: hidden;
  background: var(--rui-alphabet-paper);
  border: 1px solid var(--rui-alphabet-line);
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen image {
  display: block;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen figcaption {
  width: min(100%, 386px);
  margin-top: .75rem;
  color: var(--rui-alphabet-muted);
  font-size: .85rem;
  line-height: 1.45;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen a {
  display: block;
  width: min(100%, 386px);
  color: inherit;
  text-underline-offset: .2em;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen figcaption span {
  display: block;
  margin-top: .25rem;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls] {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 1rem clamp(1rem, 3vw, 2rem);
  align-items: center;
  margin-top: clamp(1.5rem, 4vw, 3rem);
  padding-top: 1rem;
  border-top: 1px solid var(--rui-alphabet-line);
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-study-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  color: var(--rui-alphabet-muted);
  font-size: .8rem;
  line-height: 1.3;
  letter-spacing: .04em;
  text-transform: uppercase;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-study-top p {
  margin: 0;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-study-top [data-alphabet-count] {
  margin-left: .75rem;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls][hidden] {
  display: none !important;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls] button {
  min-height: 2.25rem;
  padding: .4rem .7rem;
  color: var(--rui-alphabet-ink);
  font: inherit;
  font-size: .8rem;
  line-height: 1;
  background: transparent;
  border: 1px solid var(--rui-alphabet-line);
  border-radius: 0;
  cursor: pointer;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls] button:hover,
[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls] button[data-alphabet-active="true"] {
  color: var(--rui-alphabet-paper);
  background: var(--rui-alphabet-ink);
  border-color: var(--rui-alphabet-ink);
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls] button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls] button:focus-visible,
[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen a:focus-visible,
[data-rui-editorial-case="typography"] [data-alphabet-study]:focus-visible {
  outline: 2px solid var(--rui-alphabet-accent);
  outline-offset: 4px;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-transport] {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-playback {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-letter-grid] {
  display: grid;
  grid-template-columns: repeat(13, minmax(1.3rem, 1fr));
  gap: .25rem;
  min-width: 0;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-letter-list {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: .25rem;
  min-width: 0;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-letter-grid] button {
  min-height: 1.9rem;
  padding: .25rem;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-letter-list button {
  min-width: 0;
  min-height: 1.9rem;
  width: 100%;
  padding: .25rem;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-readout] {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .35rem .7rem;
  color: var(--rui-alphabet-muted);
  font-size: .8rem;
  line-height: 1.3;
  white-space: nowrap;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-caption {
  max-width: 60ch;
  margin: 1rem 0 0;
  color: var(--rui-alphabet-muted);
  font-size: .85rem;
  line-height: 1.5;
}

[data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-status] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 767px) {
  [data-rui-editorial-case="typography"] [data-alphabet-study] {
    padding-inline: 0;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-specimens] {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame] {
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-specimen {
    width: min(100%, 386px);
    margin-inline: auto;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-controls] {
    grid-template-columns: 1fr;
    gap: .9rem;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-readout] {
    justify-content: flex-start;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-study-top {
    align-items: flex-start;
    flex-direction: column;
    gap: .35rem;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] .rui-alphabet-letter-list {
    grid-template-columns: repeat(13, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame] {
    transition: none;
  }

  [data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame].is-entering,
  [data-rui-editorial-case="typography"] [data-alphabet-study] [data-alphabet-frame].is-leaving {
    transform: none;
  }
}
