/* ── tokens ── */
:root {
  color-scheme: light dark;

  --accent-l: oklch(0.58 0.14 45);
  --accent-d: oklch(0.72 0.15 50);

  --bg:     light-dark(#fafaf9, #0d0d0c);
  --text:   light-dark(#111110, #e8e8e2);
  --muted:  light-dark(#6f6f66, #808078);
  --border: light-dark(#e5e5e0, #222220);
  --accent: light-dark(var(--accent-l), var(--accent-d));
  /* highlighter ink: 28% in light, 45% in dark */
  --hl:     light-dark(color-mix(in oklab, var(--accent-l) 28%, transparent),
                       color-mix(in oklab, var(--accent-d) 45%, transparent));

  --serif:  'Cormorant Garamond', Georgia, serif;
  --sans:   'Inter', system-ui, sans-serif;

  /* type scale: 11 / 13 / 14 / 17px, plus the clamped site name */
  --fs-meta: 0.6875rem;
  --fs-sm:   0.8125rem;
  --fs-base: 0.875rem;
  --fs-lg:   1rem;
  --lh-read: 1.7;

  --dur: 0.22s;
  --spring-open: 0.48s linear(0.0, 0.085, 0.2604, 0.4501, 0.6177, 0.7503, 0.8472, 0.9137, 0.9564, 0.9822, 0.9964, 1.0033, 1.0059, 1.0062, 1.0054, 1.0042, 1.0031, 1.0021, 1.0013, 1.0008, 1.0004);
  --spring-icon: 0.42s linear(0.0, 0.0862, 0.2666, 0.4638, 0.6387, 0.7763, 0.8753, 0.941, 0.9809, 1.0026, 1.0124, 1.0151, 1.0141, 1.0115, 1.0085, 1.0057, 1.0036, 1.002, 1.001, 1.0003, 1.0);
  --card: light-dark(#f2f2ef, #171715);
}

[data-theme="light"] { color-scheme: light; }
[data-theme="dark"]  { color-scheme: dark; }

/* ── icons ── */
.ico {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: middle;
  fill: currentColor;
  flex-shrink: 0;
}

/* the theme button shows the mode it switches to */
.ico-sun { display: none; }
[data-theme="dark"] .ico-sun  { display: inline-block; }
[data-theme="dark"] .ico-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .ico-sun  { display: inline-block; }
  :root:not([data-theme]) .ico-moon { display: none; }
}

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.2s ease, color 0.2s ease;
  min-height: 100svh;
  padding: clamp(2rem, 5vmin, 4rem) clamp(1rem, 4vw, 3rem);
}

/* ── layout ── */
.wrap {
  width: 100%;
  max-width: 600px;
  padding: 2.25rem 1.5rem 2.5rem;
  margin-left: 0;
  background: var(--card);
  border-radius: 28px;
  box-shadow:
    0 2px 4px oklch(0 0 0 / 0.04),
    0 8px 24px oklch(0 0 0 / 0.08),
    0 24px 64px oklch(0 0 0 / 0.06);
  will-change: box-shadow;
  transition: box-shadow 0.3s ease;
}

/* ── header ── */
header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 1rem;
  margin-bottom: 3.5rem;
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
}

.site-name {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.6rem, 4.5vw, 2.25rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  color: var(--text);
  text-decoration: none;
  text-wrap: balance;
}

.controls {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
  padding-top: 0.4rem;
}

.btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  letter-spacing: 0.04em;
  padding: 0;
  line-height: 1;
  position: relative;
  transition: color 0.12s ease, opacity 0.12s ease;
}

.btn::after {
  content: '';
  position: absolute;
  inset: -10px;
}

.btn:hover { color: var(--text); }
.btn:active { opacity: 0.6; }

@keyframes btn-bounce {
  0%, 100% { transform: translateY(0); }
  20% { transform: translateY(-4px); }
  40% { transform: translateY(0); }
  60% { transform: translateY(-2px); }
  80% { transform: translateY(0); }
}

#expand-btn {
  animation: btn-bounce 1.1s ease 0.4s 1;
}

.lang {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.lang-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--sans);
  font-size: var(--fs-meta);
  letter-spacing: 0.06em;
  padding: 0;
  position: relative;
  transition: color 0.12s ease, opacity 0.12s ease;
}

.lang-btn::after {
  content: '';
  position: absolute;
  inset: -10px;
}

.lang-btn:hover,
.lang-btn.active { color: var(--text); }
.lang-btn:active { opacity: 0.6; }

.lang-sep {
  color: var(--border);
  font-size: var(--fs-meta);
  pointer-events: none;
}

/* ── tagline ── */
.tagline {
  font-size: var(--fs-base);
  font-weight: 300;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: pre-line;
}

/* ── disclosure: one set of mechanics for all three tiers ── */
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }

summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

::details-content > * {
  min-height: 0;
}

details[open] > summary .rotatable { transform: rotate(45deg); }

.rotatable {
  transition: transform var(--spring-icon);
}

/* row headings: strip UA styling, keep the flex row */
.nav-heading { font: inherit; }

.nav-row,
.nested-row,
.deep-row {
  font: inherit;
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── nav list ── */
.nav-list {
  list-style: none;
  border-top: 1px solid var(--border);
}

.nav-item {
  border-bottom: 1px solid var(--border);
}

.nav-row {
  gap: 0.75rem;
  padding: 0.9rem 0;
  text-decoration: none;
}

.nav-row:hover .nav-icon { color: var(--text); }

.nav-num {
  font-size: var(--fs-meta);
  color: var(--muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  min-width: 1.75rem;
  flex-shrink: 0;
}

/* highlighter sweep: a marker stroke drawn left→right on hover */
.nav-label,
.nested-label {
  margin-right: auto;
  margin-left: -0.15em;
  padding: 0 0.15em;
  background-image: linear-gradient(var(--hl) 0 100%);
  background-repeat: no-repeat;
  background-position: 0 50%;
  background-size: 0 1.15em;
  transition: background-size 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.nav-row:hover .nav-label,
.nested-row:hover .nested-label {
  background-size: 100% 1.15em;
}

.nav-label {
  font-family: var(--sans);
  font-size: var(--fs-lg);
  font-weight: 400;
  color: var(--text);
  text-wrap: balance;
}

.nav-icon {
  font-size: var(--fs-base);
  color: var(--muted);
  transition: color var(--dur), transform var(--dur);
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.expand-pad {
  padding: 0.1rem 0 0.84rem 2.5rem;
  color: var(--muted);
  font-size: var(--fs-base);
  line-height: var(--lh-read);
}

.expand-pad p + p { margin-top: 0.3rem; }

.content-row {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
}

.content-icon {
  color: var(--muted);
  font-size: var(--fs-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  height: calc(var(--fs-base) * var(--lh-read));
}

.content-text { flex: 1; min-width: 0; }
.content-text p { text-wrap: pretty; }

/* ── nested list ── */
.nested-list {
  list-style: none;
  border-top: 1px solid var(--border);
  margin: 0.24rem 0 0 -2.5rem;
  padding-left: 2.5rem;
}

.nested-item { border-bottom: 1px solid var(--border); }
.nested-item:last-child { border-bottom: none; }

.nested-row {
  gap: 0.55rem;
  padding: 0.65rem 0;
}

.nested-arrow {
  font-size: var(--fs-meta);
  color: var(--muted);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nested-label {
  font-size: var(--fs-base);
  color: var(--text);
}

.nested-icon {
  font-size: var(--fs-sm);
  color: var(--muted);
  transition: transform var(--dur);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nested-pad {
  padding: 0.1rem 0 0.51rem 1.3rem;
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: var(--lh-read);
}

/* ── deep list (nested lvl 3) ── */
.deep-list { margin-top: 0.3rem; }

.deep-item + .deep-item { margin-top: 0.2rem; }

.deep-row {
  gap: 0.5rem;
  padding: 0.4rem 0;
}

.deep-row:hover .deep-label { color: var(--accent); }

.deep-label {
  flex: 1;
  font-family: var(--sans);
  font-size: var(--fs-meta);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  transition: color var(--dur);
}

.deep-icon {
  font-size: var(--fs-meta);
  color: var(--accent);
  transition: transform var(--dur), color var(--dur);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.deep-pad { padding: 0.1rem 0 0.36rem; }

/* ── logo grid (nested lvl 4) ── */
.logo-grid {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.36rem;
  margin-top: 0.24rem;
}

.logo-tile {
  width: calc((100% - 0.72rem) / 3);
  aspect-ratio: 16 / 10;
  border: 1px solid var(--border);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: var(--fs-meta);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  filter: grayscale(1);
  opacity: 0.65;
  transition: opacity var(--dur), transform var(--dur), border-color var(--dur), filter var(--dur);
  cursor: pointer;
}

.logo-tile:hover {
  filter: grayscale(0);
  opacity: 1;
  transform: translateY(-3px);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 6px 16px -8px var(--accent);
}

.logo-tile:active {
  transform: scale(0.96) translateY(-1px);
}

/* ── footer ── */
footer {
  margin-top: 3rem;
  font-size: var(--fs-meta);
  color: var(--muted);
  letter-spacing: 0.02em;
}

.footer-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

/* ── mobile ── */
@media (max-width: 480px) {
  body       { padding: 0; }
  .wrap      { padding: 1.5rem 1.25rem 2rem; border-radius: 0; box-shadow: none; max-width: 100%; }
  header     { margin-bottom: 2.5rem; }
  .controls  { gap: 1rem; padding-top: 0.2rem; }
  .expand-pad { padding-left: 2rem; }
  .nested-list { margin-left: -2rem; padding-left: 2rem; }
  .logo-grid { gap: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  #expand-btn { animation: none; }
  .nav-label,
  .nested-label,
  .rotatable,
  ::details-content { transition: none; }
}
