/*
 * One stage, four worlds. Designed at 375 px: the index is a strip of four
 * names the thumb can flick, and the stage is the full width beneath it.
 * From 1024 the index stands beside the stage as a column of large names.
 */

.root {
  display: grid;
  gap: var(--s6);
  --accent: var(--rule-strong);
}

.root[data-tone="navy"] {
  --stage-bg: var(--navy);
  --stage-ink: #fff;
}

.root[data-tone="paper"] {
  --stage-bg: var(--paper-2);
  --stage-ink: var(--ink);
}

/* ---- The index ---------------------------------------------------------- */

.index {
  display: grid;
  gap: var(--s4);
  align-content: start;
}

.label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.statement {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.4vw, 2.125rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.02em;
  max-width: 18ch;
  text-wrap: balance;
}

.tabs {
  display: flex;
  gap: var(--s2);
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  margin-inline: calc(var(--pad-x) * -1);
  padding-inline: var(--pad-x);
  padding-block: var(--s2) var(--s3);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 var(--s3);
  align-items: baseline;
  padding: var(--s3) var(--s4);
  border: var(--hairline) solid var(--rule);
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
  transition:
    border-color var(--t-colour) linear,
    background-color var(--t-colour) linear;
}

.tab[data-module="financa"] {
  --accent: var(--m-financa);
}

.tab[data-module="materiale"] {
  --accent: var(--m-materiale);
}

.tab[data-module="paga"] {
  --accent: var(--m-paga);
}

.tab[data-module="bar-restorant"] {
  --accent: var(--m-bar-restorant);
}

.tab:hover {
  border-color: var(--rule-strong);
}

.tab[data-selected] {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tab:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.code {
  font-family: var(--font-mono);
  font-size: var(--step-mono);
  color: var(--accent);
}

.brand {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* On a phone the strip carries names only; the stage says what they count. */
.unit {
  display: none;
  grid-column: 2;
  font-family: var(--font-mono);
  font-size: var(--step-label);
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

/* ---- The stage ---------------------------------------------------------- */

.stage {
  display: grid;
  gap: var(--s5);
  padding: var(--s5) var(--s4) var(--s5);
  background: var(--stage-bg);
  color: var(--stage-ink);
  min-width: 0;
  transition: background-color var(--t-fast) var(--ease);
}

.line {
  margin: 0;
  font-size: 1.0625rem;
  max-width: 52ch;
  color: var(--stage-ink);
}

.root[data-tone="paper"] .line {
  color: var(--ink-2);
}

.root[data-tone="navy"] .line {
  color: var(--mat);
}

.frame {
  min-width: 0;
}

.open {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-height: 44px;
  font-weight: 600;
  font-size: var(--step-small);
  color: var(--stage-ink);
  text-decoration: none;
  border-bottom: var(--hairline) solid currentColor;
}

.arrow {
  font-weight: 400;
  display: inline-block;
  transition: transform var(--t-colour) var(--ease);
}

.open:hover .arrow {
  transform: translateX(4px);
}

/* ---- Wider -------------------------------------------------------------- */

@media (min-width: 1024px) {
  .root {
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    gap: var(--s8);
    align-items: start;
  }

  .tabs {
    flex-direction: column;
    gap: 0;
    overflow: visible;
    margin-inline: 0;
    padding: 0;
    border-top: var(--hairline) solid var(--rule);
  }

  .tab {
    border: 0;
    border-bottom: var(--hairline) solid var(--rule);
    background: transparent;
    padding: var(--s4) var(--s4) var(--s4) var(--s4);
    grid-template-columns: 3ch minmax(0, 1fr);
    row-gap: var(--s1);
  }

  .tab[data-selected] {
    background: var(--paper-2);
  }

  .brand {
    font-size: 1.5rem;
    white-space: normal;
  }

  .unit {
    display: block;
  }

  .stage {
    padding: var(--s6) var(--s6) var(--s6);
  }
}

@media (min-width: 1280px) {
  .brand {
    font-size: 1.75rem;
  }
}
