/* ============================================================
   StudyVaults — topic (notes) page styles
   (loaded in addition to styles.css)
   ============================================================ */

/* ---- Header ---- */
.topic-header { padding: clamp(28px, 5vw, 52px) 0 8px; }
.topic-header .breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .86rem; color: var(--muted); margin-bottom: 24px; }
.topic-header .breadcrumb a { color: var(--muted); transition: color .2s var(--ease); }
.topic-header .breadcrumb a:hover { color: var(--accent-ink); }
.topic-header .breadcrumb span[aria-hidden] { opacity: .5; }
.topic-header .breadcrumb__current { color: var(--ink); font-weight: 500; }

.topic-eyebrow { font-size: .82rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--accent-ink); }
.topic-header h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -.03em;
  margin-top: 12px; max-width: 16ch;
}
.topic-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; color: var(--muted); font-size: .9rem; }
.topic-meta span[aria-hidden] { opacity: .5; }

/* ---- Mark as revised ---- */
.revise {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 20px; padding: 9px 16px 9px 11px; border-radius: 999px;
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  transition: background .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.revise:hover { border-color: var(--muted); transform: translateY(-1px); }
.revise__check {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--muted); color: transparent;
  transition: background .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.revise__check svg { width: 12px; height: 12px; }
.revise.is-revised { background: var(--success-tint); border-color: color-mix(in srgb, var(--success) 45%, var(--line)); color: var(--success-ink); }
.revise.is-revised .revise__check { background: var(--success); border-color: var(--success); color: #fff; }

/* ---- Flashcards / self-test ---- */
.selftest { margin: clamp(40px, 6vw, 64px) 0 0; padding-top: 36px; border-top: 1px solid var(--line); max-width: 760px; }
.selftest__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.selftest__head h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.5rem, 3vw, 1.95rem); letter-spacing: -.02em; }
.selftest__count { font-size: .9rem; color: var(--muted); font-weight: 600; white-space: nowrap; }

.flashcard { perspective: 1200px; cursor: pointer; }
.flashcard__inner { position: relative; width: 100%; min-height: 200px; transition: transform .55s var(--ease); transform-style: preserve-3d; }
.flashcard.is-flipped .flashcard__inner { transform: rotateY(180deg); }
.flashcard__face {
  position: absolute; inset: 0; height: 100%;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 28px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.flashcard:hover .flashcard__face { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.flashcard__back { transform: rotateY(180deg); background: var(--accent-tint); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.flashcard__hint { font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 12px; }
.flashcard__face p { margin: 0; line-height: 1.5; }
.flashcard__front p { font-family: var(--font-display); font-size: clamp(1.4rem, 3vw, 1.8rem); }
.flashcard__back p { font-size: 1.08rem; max-width: 52ch; }
.selftest__controls { display: flex; gap: 10px; margin-top: 16px; justify-content: center; flex-wrap: wrap; }
.selftest__controls .btn { font-size: .9rem; padding: 9px 16px; }

/* ---- Flashcard sign-in gate (shown to logged-out visitors) ---- */
.fc-gate {
  text-align: center; background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 34px 24px; max-width: 640px; margin: 0 auto;
}
.fc-gate__icon { display: inline-flex; color: var(--accent-ink); }
.fc-gate h3 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.4rem, 3vw, 1.7rem); margin: 10px 0 0; }
.fc-gate p { color: var(--muted); margin: 8px auto 18px; max-width: 400px; line-height: 1.6; }
.fc-gate__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---- Subject-wide flashcard deck (subject hub pages) ---- */
.subject-selftest { padding: clamp(48px, 8vw, 80px) 0; background: var(--surface-2); }
.subject-selftest .selftest__head { align-items: flex-start; max-width: 640px; margin: 0 auto 22px; }
.subject-selftest .selftest__head h2 { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.6rem, 4vw, 2.2rem); }
.subject-selftest__sub { color: var(--muted); margin: 8px 0 0; line-height: 1.6; }
.subject-selftest .flashcard,
.subject-selftest__toolbar,
.subject-selftest__rate,
.subject-selftest .selftest__controls,
.subject-selftest__empty { max-width: 640px; margin-left: auto; margin-right: auto; }
.subject-selftest__toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-bottom: 16px; }
.subject-selftest__filter { display: flex; align-items: center; gap: 8px; font-size: .9rem; font-weight: 500; cursor: pointer; }
.subject-selftest__filter input { width: 16px; height: 16px; accent-color: var(--accent); }
.subject-selftest__mastery { font-size: .85rem; color: var(--muted); font-weight: 600; }
.subject-selftest__reset {
  margin-left: auto; background: none; border: 0; padding: 0;
  font: inherit; font-size: .85rem; color: var(--muted); text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer;
}
.subject-selftest__reset:hover { color: var(--ink); }
.subject-selftest__empty {
  text-align: center; color: var(--muted); background: var(--surface);
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 32px 24px;
}
.subject-selftest__rate { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.subject-selftest__rate .btn { font-size: .92rem; }
/* display:flex on these otherwise beats the [hidden] attribute (equal specificity,
   author origin wins over the UA default) — the empty-deck state relies on this. */
.subject-selftest__rate[hidden],
.subject-selftest .selftest__controls[hidden] { display: none; }

/* ---- Layout: TOC + article ---- */
.topic-layout {
  display: grid; grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(32px, 5vw, 64px); align-items: start;
  padding: 28px 0 8px;
}
.topic-layout--solo { grid-template-columns: minmax(0, 760px); justify-content: start; }

.toc { position: sticky; top: 92px; font-size: .9rem; }
.toc__title { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 12px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc li a { display: block; padding: 6px 0 6px 16px; margin-left: -2px; color: var(--muted); border-left: 2px solid transparent; transition: color .2s var(--ease), border-color .2s var(--ease); }
.toc li a:hover { color: var(--ink); }
.toc li.toc__l3 a { padding-left: 28px; font-size: .85rem; }
.toc a.is-active { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 500; }

/* ---- Article prose ---- */
.article { max-width: 760px; }
.article > *:first-child { margin-top: 0; }
.article h2 {
  font-family: var(--font-display); font-weight: 500;
  font-size: clamp(1.5rem, 3vw, 1.95rem); letter-spacing: -.02em;
  margin: 2.2em 0 .6em; scroll-margin-top: 92px;
}
.article h3 { font-size: 1.2rem; font-weight: 600; margin: 1.8em 0 .5em; scroll-margin-top: 92px; }
.article p { margin: 1em 0; line-height: 1.75; color: var(--ink); }
.article a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.article img { display: block; max-width: 100%; height: auto; margin: 1.4em auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }

.article ul, .article ol { margin: 1em 0; padding-left: 1.4em; }
.article li { margin: .45em 0; line-height: 1.7; }
.article li::marker { color: var(--accent-ink); }

.article strong { font-weight: 600; }
.article code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .9em; background: var(--surface-2);
  padding: 2px 6px; border-radius: 6px;
}

.article blockquote {
  margin: 1.5em 0; padding: 16px 20px;
  background: var(--accent-tint); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.article blockquote p { margin: 0; color: var(--ink); }

.article hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }

.table-wrap { overflow-x: auto; margin: 1.5em 0; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.article table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.article th, .article td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.article tr:last-child td { border-bottom: 0; }
.article th { background: var(--surface-2); font-weight: 600; }
.article td:not(:last-child), .article th:not(:last-child) { border-right: 1px solid var(--line); }

/* ---- Empty state ---- */
.topic-empty {
  text-align: center; padding: clamp(40px, 7vw, 72px) 24px;
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: var(--surface);
}
.topic-empty__icon {
  display: grid; place-items: center; width: 60px; height: 60px;
  margin: 0 auto 18px; border-radius: 16px;
  background: var(--accent-tint); color: var(--accent-ink);
}
.topic-empty h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; }
.topic-empty p { margin: 12px auto 22px; max-width: 420px; color: var(--muted); }

/* ---- Prev / next ---- */
.topic-nav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  margin: clamp(40px, 6vw, 64px) 0 0; padding-top: 32px;
  border-top: 1px solid var(--line);
}
.topic-nav__slot {
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
}
a.topic-nav__slot:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-3px); box-shadow: var(--shadow); }
.topic-nav__next { text-align: right; align-items: flex-end; }
.topic-nav__dir { font-size: .78rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--accent-ink); }
.topic-nav__name { font-weight: 600; font-size: 1.02rem; }
span.topic-nav__slot { border: 0; background: transparent; }

.topic-back { margin: 28px 0 clamp(48px, 8vw, 88px); }
.topic-back a { color: var(--muted); font-weight: 500; transition: color .2s var(--ease); }
.topic-back a:hover { color: var(--accent-ink); }

/* ============================================================
   Blog (blog.html — list of posts + single post)
   ============================================================ */
.blog-head { margin: clamp(32px, 6vw, 56px) 0 28px; }
.blog-head h1 { font-family: var(--font-display); font-size: clamp(2rem, 5vw, 2.9rem); letter-spacing: -.02em; margin-top: 10px; }
.blog { display: grid; gap: 18px; margin-bottom: clamp(48px, 8vw, 88px); max-width: 760px; }
.blog-empty { color: var(--muted); padding: 32px 0; }
.blog-card {
  display: block; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 26px; box-shadow: var(--shadow);
  transition: transform .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.blog-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-lg); }
.blog-card__media img { width: 100%; height: auto; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid var(--line); }
.blog-card__date { font-size: .78rem; margin-bottom: 6px; }
.blog-card__title { font-family: var(--font-display); font-size: 1.4rem; letter-spacing: -.01em; margin: 0 0 8px; color: var(--ink); }
.blog-card__excerpt { color: var(--muted); line-height: 1.7; margin: 0 0 12px; }
.blog-card__more { font-size: .88rem; font-weight: 600; color: var(--accent-ink); }
.blog-cover { margin: 0 0 24px; }
.blog-cover img { width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--line); }

/* ============================================================
   Shop (shop.html — product catalog; no checkout yet)
   ============================================================ */
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 22px; margin-bottom: clamp(48px, 8vw, 88px);
}
.shop-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: transform .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease);
}
.shop-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: var(--shadow-lg); }
.shop-card__media img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.shop-card__body { padding: 18px 20px; }
.shop-card__title { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: -.01em; margin: 0 0 6px; color: var(--ink); }
.shop-card__price { font-weight: 700; color: var(--accent-ink); margin: 0 0 10px; }
.shop-card__desc { color: var(--muted); line-height: 1.65; font-size: .92rem; margin: 0; }
.shop-grid .blog-empty { grid-column: 1 / -1; max-width: 560px; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .topic-layout, .topic-layout--solo { grid-template-columns: minmax(0, 1fr); }
  .toc {
    position: static; order: -1; font-size: .92rem;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px;
  }
  .toc ul { border-left: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
  .toc li a { padding: 4px 0; border-left: 0; }
  .toc li.toc__l3 { display: none; }
}
@media (max-width: 560px) {
  .topic-nav { grid-template-columns: 1fr; }
  .topic-nav__next { text-align: left; align-items: flex-start; }
}
