/* ============================================================
   Forma. Night-catalog edition.
   One locked dark theme. One accent (kiln ember). All-sharp
   corners. Serif display (Newsreader) + print-shop mono
   (Space Mono). Native HTML/CSS/JS only.
   Z-index scale: 30 sticky toolbar, 100 live region (visual
   only, sr-only), dialogs use the native top layer.
   ============================================================ */

:root {
  --bg: #171210;            /* warm near-black */
  --bg-raised: #201a15;
  --surface: #211b16;       /* dialog surface */
  --line: rgba(238, 228, 213, 0.14);
  --line-strong: rgba(238, 228, 213, 0.32);
  --text: #f0e9dc;          /* warm off-white, ~15:1 on bg */
  --text-muted: #b4a78f;     /* ~7.8:1 on bg */
  --text-faint: #93836c;    /* ~5:1 on bg, small labels only */
  --accent: #e6532b;        /* kiln ember, ~5:1 on bg */
  --accent-ink: #241009;    /* text on accent, 4.9:1 */
  --accent-hover: #f0693f;
  --serif: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --mono: 'Space Mono', 'Courier New', ui-monospace, monospace;
  --gutter: clamp(1.25rem, 5vw, 4.5rem);
}

* { box-sizing: border-box; }

html {
  color-scheme: dark;
  scroll-padding-top: 7rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.6 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open { overflow: hidden; }

::selection { background: var(--accent); color: var(--accent-ink); }

img { max-width: 100%; }

a { color: var(--text); }

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

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  font: 700 .8rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: .7rem 1rem;
  text-decoration: none;
}
.skip-link:focus { top: .75rem; color: var(--accent-ink); }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  padding: 1.05rem var(--gutter);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.brand {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -.01em;
  text-decoration: none;
}

.topnav { display: flex; gap: 1.8rem; }

.topnav a {
  font: 400 .72rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  text-decoration: none;
  color: var(--text-muted);
  transition: color .18s;
}
.topnav a:hover { color: var(--accent); }

/* ---------- cover ---------- */

.cover {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  min-height: clamp(380px, 52vh, 560px);
}

.cover-media { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.cover-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% 38%;
  filter: saturate(.85) brightness(.75);
}
.cover-media::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(
    to top,
    rgb(23 18 16 / .97) 0%,
    rgb(23 18 16 / .9) 45%,
    rgb(23 18 16 / .66) 100%
  );
}

.cover-inner {
  position: relative;
  padding: 3.2rem var(--gutter) clamp(2.2rem, 5vh, 3.4rem);
  max-width: 62rem;
}

/* extra fade behind the text block so small copy always
   sits on a near-solid field, whatever the photo beneath */
.cover-inner::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -1.4rem -1.75rem -2.6rem;
  background: linear-gradient(
    to top,
    rgb(23 18 16 / .92),
    rgb(23 18 16 / .55) 62%,
    transparent
  );
}

.kicker {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin: 0 0 1.15rem;
  font: 400 .74rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .18em;
  color: var(--text-muted);
}
.kicker::before {
  content: "";
  width: 26px; height: 2px;
  background: var(--accent);
  flex: none;
}

.cover h1 {
  margin: 0 0 1.25rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: 1.04;
  letter-spacing: -.015em;
  max-width: 14ch;
}
.cover h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  padding-right: .06em;
}

.lede {
  margin: 0 0 2rem;
  max-width: 42ch;
  font-size: clamp(1.05rem, 1.6vw, 1.28rem);
  line-height: 1.55;
  color: var(--text-muted);
}

.cta {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  font: 700 .78rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  text-decoration: none;
  padding: .95rem 1.5rem;
  cursor: pointer;
  transition: background-color .18s, transform .12s;
}
.cta:hover { background: var(--accent-hover); color: var(--accent-ink); }
.cta:active { transform: translateY(1px); }

.cta-ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.cta-ghost:hover { background: var(--accent); color: var(--accent-ink); }

/* ---------- toolbar (sticky) ---------- */

.toolbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.toolbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem 2.2rem;
  padding: .85rem var(--gutter) .95rem;
}

.field { display: flex; flex-direction: column; gap: .35rem; }

.field label {
  font: 400 .62rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--text-faint);
}

#search {
  width: clamp(200px, 26vw, 330px);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  color: var(--text);
  font: 400 .95rem var(--mono);
  padding: .55rem .1rem;
  border-radius: 0;
}
#search::placeholder { color: var(--text-faint); }
#search:focus-visible { outline-offset: 4px; }

#filter {
  appearance: none;
  -webkit-appearance: none;
  width: max-content;
  background: transparent url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='10'%20height='6'%3E%3Cpath%20d='M1%201l4%204%204-4'%20stroke='%23b4a78f'%20fill='none'%20stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right .35rem center;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  color: var(--text);
  font: 400 .95rem var(--mono);
  padding: .55rem 1.5rem .55rem .1rem;
  cursor: pointer;
  border-radius: 0;
}
#filter:focus-visible { outline-offset: 4px; }

.saved-toggle {
  align-self: flex-end;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text);
  font: 700 .72rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: .68rem 1.05rem;
  cursor: pointer;
  min-height: 44px;
  transition: background-color .18s, color .18s, border-color .18s;
}
.saved-toggle:hover { border-color: var(--accent); color: var(--accent); }
.saved-toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.saved-toggle[aria-pressed="true"]:hover {
  background: var(--accent-hover);
  color: var(--accent-ink);
}

.count {
  margin: 0 0 0 auto;
  align-self: flex-end;
  padding-bottom: .75rem;
  font: 400 .7rem var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ---------- ledger ---------- */

.ledger {
  list-style: none;
  margin: 0;
  padding: 0 var(--gutter) 1.2rem;
  border-bottom: 1px solid var(--line);
}

.row { border-top: 1px solid var(--line); }

.row-btn {
  display: grid;
  grid-template-columns: 6.2rem minmax(0, 1fr) auto 2.2rem;
  align-items: center;
  gap: clamp(1rem, 2.6vw, 2.4rem);
  width: 100%;
  padding: 1.45rem .6rem;
  background: none;
  border: 0;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color .18s;
}
.row-btn:hover { background: rgb(240 233 220 / .04); }
.row-btn:focus-visible { outline-offset: -2px; }

.row-date {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  font-family: var(--mono);
  line-height: 1.1;
}
.rd-mon, .rd-day {
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .16em;
}
.rd-mon { color: var(--text-faint); }
.rd-day { color: var(--text-muted); }
.rd-num {
  font-family: var(--serif);
  font-size: 1.65rem;
  font-weight: 500;
  color: var(--text);
}

.row-main { display: flex; flex-direction: column; min-width: 0; }

.row-title {
  font-family: var(--serif);
  font-size: clamp(1.25rem, 1.9vw, 1.5rem);
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -.005em;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .7rem;
}

.tag-saved {
  font: 700 .58rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .22rem .5rem;
}

.row-summary {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  margin-top: .4rem;
  font-style: italic;
  font-size: .95rem;
  color: var(--text-muted);
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1.4rem;
  margin-top: .85rem;
  font: 400 .65rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .13em;
  color: var(--text-faint);
}
.m-cat { color: var(--accent); font-weight: 700; }

.row-price {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  text-align: right;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
}
.row-price small {
  font-weight: 400;
  font-size: .58rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-faint);
}

.row-arrow {
  justify-self: end;
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--text-faint);
  transition: transform .18s, color .18s;
}
.row-btn:hover .row-arrow,
.row-btn:focus-visible .row-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* ---------- empty state ---------- */

.empty {
  display: grid;
  justify-items: center;
  gap: .9rem;
  padding: 4.5rem var(--gutter) 5.5rem;
  text-align: center;
}
.empty[hidden] { display: none; }

.empty-kicker {
  margin: 0;
  font: 400 .68rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .2em;
  color: var(--accent);
}
.empty h2 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  letter-spacing: -.01em;
}
.empty p { margin: 0; color: var(--text-muted); max-width: 44ch; }
.empty .cta { margin-top: .6rem; }

/* ---------- teachers ---------- */

.teachers {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: clamp(2.2rem, 5vw, 5rem);
  align-items: center;
  padding: clamp(3.5rem, 8vw, 6rem) var(--gutter);
}

.teachers h2 {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.8rem, 3.1vw, 2.5rem);
  letter-spacing: -.012em;
  line-height: 1.12;
}

.teachers-intro {
  margin: 0 0 2.4rem;
  max-width: 48ch;
  color: var(--text-muted);
}

.teacher-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.7rem 2.6rem;
}
.teacher-list li { display: flex; flex-direction: column; gap: .3rem; }
.t-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  font-weight: 500;
}
.t-disc {
  font: 400 .64rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--text-faint);
}

.teachers-media { margin: 0; overflow: hidden; }
.teachers-media img {
  display: block;
  width: 100%;
  height: clamp(280px, 42vw, 440px);
  object-fit: cover;
  object-position: 50% 45%;
  filter: saturate(.92) brightness(.9);
}

/* ---------- footer ---------- */

.footer {
  display: grid;
  grid-template-columns: auto 1fr minmax(auto, 46ch);
  gap: 1rem 3rem;
  align-items: baseline;
  padding: 2.6rem var(--gutter) 3.2rem;
  border-top: 1px solid var(--line);
}
.f-brand {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.4rem;
}
.f-tag { margin: 0; color: var(--text-muted); }
.f-fine {
  margin: 0;
  font: 400 .62rem var(--mono);
  line-height: 1.7;
  letter-spacing: .04em;
  color: var(--text-faint);
  text-align: right;
}

/* ---------- detail dialog ---------- */

dialog.detail {
  width: min(64rem, calc(100vw - 2rem));
  height: min(86dvh, 42rem);
  max-height: min(90dvh, 42rem);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  overflow: hidden;
}

dialog.detail::backdrop { background: rgb(12 9 7 / .76); }

.detail-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  height: 100%;
}

.detail-media {
  position: relative;
  margin: 0;
  overflow: hidden;
  min-height: 0;
}
.detail-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(.95);
}

.detail-close {
  position: absolute;
  top: 1rem; right: 1rem;
  z-index: 2;
  background: rgb(23 18 16 / .88);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font: 700 .66rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  padding: .6rem .9rem;
  min-height: 44px;
  cursor: pointer;
  transition: color .18s, border-color .18s;
}
.detail-close:hover { color: var(--accent); border-color: var(--accent); }

.detail-content {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  padding: clamp(1.7rem, 3.4vw, 2.8rem);
  overflow-y: auto;
}

.detail-kicker {
  margin: 0 0 1.1rem;
  font: 700 .66rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--accent);
}

#detail-title {
  margin: 0 0 1.1rem;
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 3.2vw, 2.55rem);
  line-height: 1.08;
  letter-spacing: -.012em;
}

.detail-body {
  margin: 0 0 1.9rem;
  max-width: 54ch;
  font-size: 1.05rem;
  line-height: 1.68;
  color: var(--text-muted);
}

.detail-specs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 2.2rem;
  margin: 0 0 2.2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.detail-specs div { display: flex; flex-direction: column; gap: .3rem; }
.detail-specs dt {
  font: 400 .6rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--text-faint);
}
.detail-specs dd {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1rem;
}

.save-btn {
  margin-top: auto;
  width: 100%;
  padding: 1rem;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  font: 700 .74rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .14em;
  cursor: pointer;
  min-height: 48px;
  transition: background-color .18s, color .18s, transform .12s;
}
.save-btn:hover { background: var(--accent-hover); color: var(--accent-ink); }
.save-btn:active { transform: translateY(1px); }
.save-btn[aria-pressed="true"] {
  background: transparent;
  color: var(--accent);
}
.save-btn[aria-pressed="true"]:hover { color: var(--accent-hover); }

/* ---------- motion (gated behind preference) ---------- */

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  .cover-inner > * {
    animation: rise .55s cubic-bezier(.16, 1, .3, 1) backwards;
  }
  .cover-inner > *:nth-child(2) { animation-delay: .08s; }
  .cover-inner > *:nth-child(3) { animation-delay: .16s; }
  .cover-inner > *:nth-child(4) { animation-delay: .24s; }

  .ledger.boot .row {
    animation: rise .45s cubic-bezier(.16, 1, .3, 1) backwards;
    animation-delay: calc(var(--i) * 45ms);
  }

  dialog.detail[open] { animation: dialog-in .26s cubic-bezier(.16, 1, .3, 1); }
  dialog.detail[open]::backdrop { animation: fade-in .26s ease; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes dialog-in {
  from { opacity: .4; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- mobile (390 x 844) ---------- */

@media (max-width: 700px) {
  html { scroll-padding-top: 11rem; }
  .topbar { padding-block: .9rem; }
  .topnav { gap: 1.3rem; }

  .cover { min-height: clamp(400px, 54vh, 480px); }
  .cover-inner { padding-top: 2.4rem; }
  .lede { margin-bottom: 1.7rem; }

  .toolbar-inner {
    gap: .9rem 1.2rem;
    padding-bottom: 1rem;
  }
  .field { flex: 1 1 100%; }
  #search { width: 100%; }
  #filter { flex: 1; width: 100%; }
  .count { margin-left: 0; padding-bottom: .55rem; }
  .saved-toggle { margin-left: auto; }

  .row-btn {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: .35rem 1.2rem;
    padding: 1.35rem .35rem;
  }
  .row-main { grid-area: 1 / 1 / 2 / 3; }
  .row-date {
    grid-area: 2 / 1 / 3 / 2;
    flex-direction: row;
    align-items: baseline;
    gap: .5rem;
  }
  .rd-num { font-size: 1.15rem; }
  .row-price {
    grid-area: 2 / 2 / 3 / 3;
    flex-direction: row;
    align-items: baseline;
    gap: .5rem;
    font-size: .95rem;
  }
  .row-summary { -webkit-line-clamp: 2; }
  .row-arrow { display: none; }

  .teachers { grid-template-columns: 1fr; }
  .teacher-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 1.6rem; }
  .teachers-media { order: -1; }
  .teachers-media img { height: 260px; }

  .footer { grid-template-columns: 1fr; gap: .7rem; }
  .f-fine { text-align: left; }

  dialog.detail {
    width: calc(100vw - 1.25rem);
    height: 92dvh;
    max-height: 92dvh;
  }
  .detail-grid { grid-template-columns: 1fr; grid-template-rows: 230px minmax(0, 1fr); }
  .detail-content { padding: 1.5rem 1.3rem 1.7rem; }
  .detail-specs { gap: 1.1rem 1.5rem; }
}
