/* Toppers Copy — design system
   Palette: #F6C992 sand · #30525C deep slate · #ACC0D3 sky
            #D396A6 rose · #09A1A1 teal · #5484A4 steel
   Aesthetic: modern-minimal, warm paper, Fraunces + Inter, soft colour washes. */

/* self-hosted, latin-subset variable fonts — no external font request */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;

  --paper:      #FBF9F5;
  --surface:    #FFFFFF;
  --surface-2:  #F3EFE8;
  --border:     #E9E3D8;
  --border-2:   #DAD1C2;

  --ink:        #263A40;   /* headings / near-black */
  --body:       #435559;   /* body copy */
  --muted:      #7A8A8D;   /* meta */

  --teal:       #09A1A1;
  --teal-text:  #0A7C7B;   /* link/text-safe teal */
  --teal-weak:  #E1F2F1;
  --teal-line:  #B9E1DF;

  --sand:       #F6C992;
  --sand-weak:  #FBEEDA;
  --rose:       #D396A6;
  --rose-weak:  #F6E7EB;
  --steel:      #5484A4;
  --steel-weak: #E7EEF3;
  --sky:        #ACC0D3;
  --sky-weak:   #EDF1F5;

  --ring:       rgba(9,161,161,.30);
  --shadow-sm:  0 1px 2px rgba(38,58,64,.06);
  --shadow:     0 2px 6px rgba(38,58,64,.06), 0 16px 40px -18px rgba(38,58,64,.20);
  --shadow-lg:  0 4px 12px rgba(38,58,64,.08), 0 32px 64px -24px rgba(38,58,64,.28);

  --glow-1: rgba(9,161,161,.14);
  --glow-2: rgba(246,201,146,.20);

  --serif: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --w: 1040px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper:      #101C1D;
    --surface:    #172829;
    --surface-2:  #1F3234;
    --border:     #2C4245;
    --border-2:   #3B5559;

    --ink:        #F0E9DC;
    --body:       #C9D6D5;
    --muted:      #8AA0A0;

    --teal:       #37C5BF;
    --teal-text:  #55D6CF;
    --teal-weak:  #10312F;
    --teal-line:  #245049;

    --sand:       #F6C992;
    --sand-weak:  #33291A;
    --rose:       #E1A9B7;
    --rose-weak:  #37262C;
    --steel:      #86ABC6;
    --steel-weak: #21323B;
    --sky:        #ACC0D3;
    --sky-weak:   #20302F;

    --ring:       rgba(55,197,191,.34);
    --shadow-sm:  0 1px 2px rgba(0,0,0,.30);
    --shadow:     0 2px 8px rgba(0,0,0,.32), 0 20px 48px -20px rgba(0,0,0,.62);
    --shadow-lg:  0 6px 16px rgba(0,0,0,.38), 0 40px 80px -28px rgba(0,0,0,.7);

    --glow-1: rgba(55,197,191,.16);
    --glow-2: rgba(246,201,146,.10);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:      #101C1D;
  --surface:    #172829;
  --surface-2:  #1F3234;
  --border:     #2C4245;
  --border-2:   #3B5559;

  --ink:        #F0E9DC;
  --body:       #C9D6D5;
  --muted:      #8AA0A0;

  --teal:       #37C5BF;
  --teal-text:  #55D6CF;
  --teal-weak:  #10312F;
  --teal-line:  #245049;

  --sand:       #F6C992;
  --sand-weak:  #33291A;
  --rose:       #E1A9B7;
  --rose-weak:  #37262C;
  --steel:      #86ABC6;
  --steel-weak: #21323B;
  --sky:        #ACC0D3;
  --sky-weak:   #20302F;

  --ring:       rgba(55,197,191,.34);
  --shadow-sm:  0 1px 2px rgba(0,0,0,.30);
  --shadow:     0 2px 8px rgba(0,0,0,.32), 0 20px 48px -20px rgba(0,0,0,.62);
  --shadow-lg:  0 6px 16px rgba(0,0,0,.38), 0 40px 80px -28px rgba(0,0,0,.7);

  --glow-1: rgba(55,197,191,.16);
  --glow-2: rgba(246,201,146,.10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--body);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  min-height: 100vh;
}
/* soft colour wash, mercury-style */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 620px;
  background:
    radial-gradient(60% 70% at 18% 0%, var(--glow-2), transparent 70%),
    radial-gradient(55% 65% at 88% 8%, var(--glow-1), transparent 72%);
  pointer-events: none;
  z-index: 0;
}
main, header.site, footer.site { position: relative; z-index: 1; }

a { color: var(--teal-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3 { color: var(--ink); }

.wrap { max-width: var(--w); margin: 0 auto; padding: 0 24px; }
@media (max-width: 560px) { .wrap { padding: 0 16px; } }

/* ---------- header ---------- */
header.site {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.5) blur(12px);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid var(--border);
}
header.site .bar { display: flex; align-items: center; gap: 18px; min-height: 66px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; letter-spacing: -.01em; color: var(--ink); }
.brand .mark {
  width: 28px; height: 28px; border-radius: 9px; flex: none;
  background: linear-gradient(150deg, var(--teal), var(--steel) 120%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.15), 0 2px 8px -2px var(--ring);
  display: grid; place-items: center; color: #fff; font-family: var(--serif); font-size: 15px; font-weight: 600;
}
header.site nav.tabs { display: flex; gap: 2px; margin-left: auto; }
header.site nav.tabs button {
  font: inherit; font-size: 14px; font-weight: 500;
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 13px; border-radius: 9px; cursor: pointer; white-space: nowrap;
  transition: color .15s, background .15s;
}
header.site nav.tabs button:hover { color: var(--ink); background: var(--surface-2); }
header.site nav.tabs button[aria-selected="true"] { color: var(--ink); background: var(--surface-2); }

.theme-toggle {
  flex: none; width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--ink);
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
  transition: border-color .15s, transform .15s;
}
.theme-toggle:hover { border-color: var(--teal); transform: translateY(-1px); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .moon,
:root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
:root[data-theme="dark"] .theme-toggle .sun,
:root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .moon { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .sun { display: block; }
}

@media (max-width: 680px) {
  header.site .bar { flex-wrap: wrap; min-height: 0; padding: 10px 0; gap: 10px; }
  header.site nav.tabs { order: 3; width: 100%; margin-left: 0; justify-content: space-between; }
  header.site nav.tabs button { flex: 1; padding: 8px 4px; font-size: 13px; }
  .theme-toggle { margin-left: auto; }
}

/* ---------- hero ---------- */
main { padding-bottom: 96px; }
.hero { padding: 56px 0 12px; }
.view:not(#view-browse) .hero { padding: 44px 0 4px; }
.hero h1 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(30px, 5.2vw, 48px);
  line-height: 1.08;
  letter-spacing: -.02em;
  margin: 0;
  max-width: 18ch;
}
.view:not(#view-browse) .hero h1 { font-size: clamp(28px, 4.4vw, 38px); max-width: none; }
.hero .sub { margin: 16px 0 0; color: var(--muted); font-size: 16px; }
.hero .lead { margin: 14px 0 0; color: var(--body); font-size: 16.5px; max-width: 64ch; }

.statline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin-top: 26px; }
.statline .s { font-size: 14px; color: var(--muted); display: inline-flex; align-items: baseline; gap: 6px; }
.statline .s b { font-family: var(--serif); font-weight: 500; font-size: 21px; color: var(--ink); letter-spacing: -.01em; }

.credit {
  margin: 26px 0 0; padding: 13px 16px; font-size: 13.5px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; max-width: 68ch;
}
.credit strong { color: var(--body); font-weight: 600; }
.credit a { color: var(--teal-text); }

/* ---------- shared view bits ---------- */
.view { padding-top: 8px; }
.view[hidden] { display: none; }

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 67px; z-index: 20;
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  padding: 18px 0 12px; margin: 22px 0 4px;
  display: flex; flex-direction: column; gap: 12px;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 680px) { .toolbar { position: static; } }

.search { position: relative; }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%; font: inherit; font-size: 16px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-2); border-radius: 14px;
  padding: 15px 16px 15px 46px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px var(--ring); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.seg button {
  font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent;
  color: var(--muted); padding: 7px 12px; border-radius: 9px; cursor: pointer;
  transition: color .12s, background .12s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--teal-text);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--teal-line);
}

select {
  font: inherit; font-size: 13.5px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 11px;
  padding: 9px 32px 9px 13px; cursor: pointer; box-shadow: var(--shadow-sm);
  appearance: none; max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A8A8D' stroke-width='2.4'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px var(--ring); }

.resultmeta { font-size: 13.5px; color: var(--muted); margin: 16px 0 16px; }

/* ---------- copy cards ---------- */
.copy {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, border-color .18s, transform .18s;
  content-visibility: auto;
  contain-intrinsic-size: auto 84px;
}
.copy:hover { border-color: var(--border-2); }
.copy[open] { box-shadow: var(--shadow); border-color: var(--teal-line); }
.copy > summary {
  list-style: none; cursor: pointer; padding: 18px 20px;
  display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: start;
}
.copy > summary::-webkit-details-marker { display: none; }
.copy > summary:hover .name { color: var(--teal-text); }
.copy .name { font-family: var(--serif); font-weight: 500; font-size: 19px; letter-spacing: -.01em; grid-column: 1; line-height: 1.25; }
.copy .qn {
  grid-column: 2; grid-row: 1 / span 2; align-self: center;
  font-size: 12px; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px;
}
.tags { grid-column: 1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .045em;
  padding: 3px 9px; border-radius: 7px; white-space: nowrap;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.tag.paper { background: var(--sky-weak);  color: var(--steel);     border-color: transparent; }
.tag.air   { background: var(--ink);       color: var(--surface);   border-color: transparent; letter-spacing: .06em; }
.tag.year  { background: var(--sand-weak); color: #9a6a1f;          border-color: transparent; }
.tag.marks { background: var(--rose-weak); color: #a85c74;          border-color: transparent; }
:root[data-theme="dark"] .tag.year, :root:not([data-theme="light"]) .tag.year { color: var(--sand); }
:root[data-theme="dark"] .tag.marks, :root:not([data-theme="light"]) .tag.marks { color: var(--rose); }

.qlist { border-top: 1px solid var(--border); }
.q { display: flex; gap: 16px; padding: 15px 20px; border-bottom: 1px solid var(--border); align-items: start; }
.q:last-child { border-bottom: 0; }
.q .txt { flex: 1; font-size: 15.5px; line-height: 1.62; color: var(--body); white-space: pre-wrap; }
.q .qmeta { display: block; margin-top: 6px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.q .open {
  flex: none; align-self: start; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: var(--teal-text); background: var(--teal-weak); border: 1px solid var(--teal-line);
  border-radius: 9px; padding: 7px 12px; transition: background .12s, color .12s;
}
.q .open:hover { text-decoration: none; background: var(--teal); color: #fff; border-color: transparent; }
@media (max-width: 560px) {
  .q { flex-direction: column; gap: 10px; }
  .q .open { align-self: stretch; text-align: center; }
}

mark { background: var(--sand); color: #3a2c12; padding: 0 3px; border-radius: 3px; }
:root[data-theme="dark"] mark, :root:not([data-theme="light"]) mark { background: var(--sand); color: #2a2010; }

.more {
  display: block; width: 100%; margin: 16px 0; padding: 13px;
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border-2); border-radius: 12px; box-shadow: var(--shadow-sm);
  transition: border-color .15s, background .15s;
}
.more:hover { background: var(--surface-2); border-color: var(--teal); }

.empty {
  text-align: center; color: var(--muted); padding: 56px 20px; font-size: 15px;
  background: var(--surface); border: 1px dashed var(--border-2); border-radius: 16px;
}
.empty .big { font-family: var(--serif); font-size: 20px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.empty a { color: var(--teal-text); font-weight: 600; }

/* ---------- optionals ---------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 4px 0 8px; }
.subject-card {
  text-align: left; font: inherit; cursor: pointer; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px 16px 16px; box-shadow: var(--shadow-sm);
  transition: transform .16s, box-shadow .16s, border-color .16s;
}
.subject-card::before {
  content: ""; position: absolute; left: 0; top: 0; height: 3px; width: 100%;
  background: var(--accent-bar, var(--teal)); opacity: .0; transition: opacity .16s;
}
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--border-2); }
.subject-card:hover::before { opacity: 1; }
.subject-card .sname { font-family: var(--serif); font-weight: 500; font-size: 16px; color: var(--ink); letter-spacing: -.01em; }
.subject-card .scount { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.subject-card[data-has="1"] .scount { color: var(--teal-text); font-weight: 600; }

.backrow { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; flex-wrap: wrap; }
.backbtn {
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px;
  padding: 8px 13px; color: var(--ink); box-shadow: var(--shadow-sm);
}
.backbtn:hover { border-color: var(--teal); }
.backrow h2 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px; }

/* ---------- forms ---------- */
form { max-width: 760px; }
form .field { margin-bottom: 16px; }
form label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
form label .req { color: var(--teal-text); }
form input, form select, form textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 11px;
  padding: 11px 13px; box-shadow: var(--shadow-sm);
}
form input::placeholder, form textarea::placeholder { color: var(--muted); }
form textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px var(--ring); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.kindswitch { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 22px; }
.kindswitch button {
  font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent;
  color: var(--muted); padding: 8px 15px; border-radius: 9px; cursor: pointer;
}
.kindswitch button[aria-pressed="true"] { background: var(--surface); color: var(--teal-text); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--teal-line); }

.btn {
  font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  background: var(--ink); color: var(--paper); border: 1px solid transparent; border-radius: 11px;
  padding: 12px 22px; box-shadow: var(--shadow-sm); transition: transform .14s, filter .14s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn.ghost { background: var(--surface); color: var(--teal-text); border-color: var(--border-2); }
.formnote { font-size: 13px; color: var(--muted); margin-top: 12px; }

/* ---------- prose ---------- */
.prose { font-size: 16px; color: var(--body); max-width: 68ch; }
.prose h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 30px 0 10px; letter-spacing: -.01em; }
.prose h2:first-child { margin-top: 6px; }
.prose p { margin: 0 0 14px; }
.prose ul { padding-left: 22px; margin: 0 0 14px; }
.prose li { margin: 6px 0; }
.prose a { color: var(--teal-text); }
.prose code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }

/* ---------- footer ---------- */
footer.site { border-top: 1px solid var(--border); background: var(--surface-2); margin-top: 40px; }
footer.site .wrap { padding: 26px 24px; display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; font-size: 13px; color: var(--muted); }
footer.site a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
footer.site a:hover { color: var(--ink); }
footer.site .spacer { flex: 1; }

.skeleton { color: var(--muted); font-size: 14px; padding: 48px 0; text-align: center; }
.q.loading .txt { color: var(--muted); font-style: italic; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- phones: lighten the paint, stop iOS focus-zoom ---------- */
@media (max-width: 680px) {
  /* backdrop-filter on a sticky bar is a known scroll-jank source on mid Android — use a solid bar */
  header.site { background: var(--paper); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .toolbar { background: var(--paper); backdrop-filter: none; -webkit-backdrop-filter: none; }
  /* the fixed radial wash repaints on every scroll frame; anchor it to the top instead */
  body::before { position: absolute; inset: 0 0 auto 0; height: 340px; }

  .hero { padding: 28px 0 8px; }
  .view:not(#view-browse) .hero { padding: 22px 0 4px; }
  .statline { margin-top: 18px; gap: 6px 16px; }

  /* 16px keeps iOS Safari from zooming the viewport on field focus */
  select, form input, form select, form textarea { font-size: 16px; }
  .theme-toggle { width: 40px; height: 40px; }
  .copy > summary { padding: 15px 16px; }
  .q { padding: 13px 16px; }
}
