/* ============================================================
   Fieldstone theme elevation layer
   Loaded after styles.css as the design-token authority: it
   intentionally re-tunes shared tokens (--ink, --forest, --amber, …)
   app-wide and layers typography, atmosphere, and motion on top.
   It never changes JS hooks or markup contracts.
   Aesthetic: a naturalist's field journal — paper, graphite,
   forest ink, amber specimen labels.
   ============================================================ */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/Fraunces.woff2") format("woff2");
}
@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("/static/fonts/Fraunces-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 300 800;
  font-display: swap;
  src: url("/static/fonts/AtkinsonHyperlegibleNext.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: italic;
  font-weight: 300 800;
  font-display: swap;
  src: url("/static/fonts/AtkinsonHyperlegibleNext-Italic.woff2") format("woff2");
}

:root {
  --font-display: "Fraunces", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --ink: #1b2620;
  --forest: #1f5a45;
  --forest-dark: #143b2e;
  --amber: #d99b3f;
  --amber-deep: #b57a24;

  --shadow: 0 1px 2px rgba(27, 43, 36, .05), 0 10px 28px rgba(27, 43, 36, .07);
  --shadow-lift: 0 2px 4px rgba(27, 43, 36, .06), 0 18px 44px rgba(27, 43, 36, .12);
  --ease-spring: cubic-bezier(.22, .9, .28, 1);

  font-family: var(--font-body);
  font-optical-sizing: auto;
}

/* ---------- paper atmosphere ---------- */

body::before {
  content: "";
  position: fixed;
  inset: 0;
  /* Below the site header (20) and exam header (10) so panels, toasts,
     and dropdowns never render under the grain. */
  z-index: 5;
  pointer-events: none;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: rgba(217, 155, 63, .35); color: var(--ink); }

/* ---------- typography ---------- */

h1, h2, h3,
.brand strong,
.brand-mark,
.mission-workload strong,
.stat-card strong,
.coach-metric strong,
.calibration-metrics dd,
.practice-result-score strong,
.score-ring strong,
.field-note blockquote,
.worked-prompt,
.lesson-number {
  font-family: var(--font-display);
}

h1 { font-weight: 560; font-variation-settings: "SOFT" 40, "WONK" 1; letter-spacing: -.028em; }
h2 { font-weight: 540; font-variation-settings: "SOFT" 40, "WONK" 0; letter-spacing: -.015em; }
h3 { font-weight: 580; }
.field-note blockquote { font-style: italic; font-weight: 470; font-variation-settings: "SOFT" 70, "WONK" 1; }
.worked-prompt { font-weight: 460; font-variation-settings: "SOFT" 60, "WONK" 0; }
p, li, label, input, select, textarea, button, td, th { letter-spacing: .004em; }
.kicker { font-weight: 700; letter-spacing: .17em; }

/* ---------- surfaces & depth ---------- */

.surface { border-radius: 16px; }
.surface:where(.focus-card, .subject-card, .exam-card, .stat-card, .coach-metric) {
  transition: box-shadow .3s var(--ease-spring), transform .3s var(--ease-spring), border-color .3s ease;
}
.subject-card:hover, .exam-card:hover, .focus-card:hover {
  transform: translateY(-2px);
  border-color: #c8cfc3;
  box-shadow: var(--shadow-lift);
}
.subject-card[data-available="false"]:hover { transform: none; box-shadow: none; }

/* contour lines: the field-map motif on dark hero panels */
.auth-story::before,
.mission-compass {
  background-image:
    repeating-radial-gradient(circle at 78% 18%, transparent 0 34px, rgba(255, 255, 255, .05) 34px 35px),
    repeating-radial-gradient(circle at 12% 85%, transparent 0 46px, rgba(255, 255, 255, .04) 46px 47px),
    radial-gradient(circle at center, rgba(255, 255, 255, .14) 0 2px, transparent 3px);
  background-size: auto, auto, 26px 26px;
  background-color: var(--forest-dark);
}
.auth-story::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: transparent;
  opacity: .85;
  pointer-events: none;
}
.lesson-block-opening, .next-card {
  background-image:
    repeating-radial-gradient(circle at 85% 12%, transparent 0 38px, rgba(255, 255, 255, .045) 38px 39px),
    repeating-radial-gradient(circle at 8% 90%, transparent 0 52px, rgba(255, 255, 255, .035) 52px 53px);
}

/* ---------- buttons ---------- */

.button {
  border-radius: 11px;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease,
              transform .18s var(--ease-spring), box-shadow .25s var(--ease-spring);
}
.button-primary {
  background: linear-gradient(180deg, #e2a854, var(--amber));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 6px 16px rgba(181, 122, 36, .25);
}
.button-primary:hover {
  background: linear-gradient(180deg, #e8b264, #dea54c);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .4) inset, 0 9px 22px rgba(181, 122, 36, .32);
}
.button-dark {
  background: linear-gradient(180deg, #276650, var(--forest));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset, 0 6px 16px rgba(20, 59, 46, .22);
}
.button-dark:hover { background: linear-gradient(180deg, #1c503e, var(--forest-dark)); }
.button:active { transform: translateY(1px) scale(.995); box-shadow: none; }

/* ---------- forms ---------- */

input, select, textarea {
  border-radius: 10px;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--forest);
  box-shadow: 0 0 0 4px rgba(31, 90, 69, .14);
}

/* ---------- navigation ---------- */

.sidebar nav a { transition: background-color .2s ease, color .2s ease, padding-left .25s var(--ease-spring); }
.sidebar nav a:hover:not(.active) { padding-left: 16px; }
.sidebar nav a.active { box-shadow: 0 6px 14px rgba(20, 59, 46, .28); }
.brand-mark { box-shadow: 0 4px 10px rgba(20, 59, 46, .3); }

/* ---------- progress & data ---------- */

.progress-track span, .lesson-progress span {
  background: linear-gradient(90deg, var(--forest), #3d7a5e);
  position: relative;
  overflow: hidden;
}
.progress-track span::after, .lesson-progress span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%);
  /* transform-only animation: runs on the compositor, no main-thread repaint */
  animation: shimmer 2.6s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 25% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}

/* ---------- choreographed page reveal ---------- */

@media (prefers-reduced-motion: no-preference) {
  .view > *, .auth-story > *, .auth-panel, .exam-mode > *, .review-mode > * {
    animation: rise .55s var(--ease-spring) backwards;
  }
  .view > :nth-child(2), .review-mode > :nth-child(2) { animation-delay: .06s; }
  .view > :nth-child(3), .review-mode > :nth-child(3) { animation-delay: .12s; }
  .view > :nth-child(4), .review-mode > :nth-child(4) { animation-delay: .18s; }
  .view > :nth-child(5), .review-mode > :nth-child(5) { animation-delay: .24s; }
  .view > :nth-child(6) { animation-delay: .3s; }
  .auth-story > :nth-child(2) { animation-delay: .08s; }
  .auth-story > :nth-child(3) { animation-delay: .16s; }
  .auth-story > :nth-child(4) { animation-delay: .24s; }
  .auth-panel { animation-delay: .12s; }

  .mission-compass::after { animation: compass-turn 80s linear infinite; }

  .daily-plan-list > li { animation: rise .45s var(--ease-spring) backwards; }
  .daily-plan-list > li:nth-child(2) { animation-delay: .05s; }
  .daily-plan-list > li:nth-child(3) { animation-delay: .1s; }
  .daily-plan-list > li:nth-child(4) { animation-delay: .15s; }
  .daily-plan-list > li:nth-child(5) { animation-delay: .2s; }

  .practice-feedback, .checkpoint-feedback { animation: pop .4s var(--ease-spring) backwards; }
  .toast { animation: toast-in .35s var(--ease-spring) backwards; }
  .notification-panel:not([hidden]) { animation: drop .3s var(--ease-spring) backwards; }
  .tutor-panel:not([hidden]) { animation: slide-left .35s var(--ease-spring) backwards; }
  .tutor-message { animation: rise .3s var(--ease-spring) backwards; }
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } }
@keyframes slide-left { from { opacity: 0; transform: translateX(24px); } }
@keyframes compass-turn { to { transform: rotate(1turn); } }

/* ---------- exam mode: calm, then urgent ---------- */

.timer, .station-timer { font-family: var(--font-mono); letter-spacing: .02em; }
@media (prefers-reduced-motion: no-preference) {
  .timer.warning, .station-timer.is-warning { animation: urgency 1.1s ease-in-out infinite; }
}
@keyframes urgency {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 40%, transparent); }
  50% { box-shadow: 0 0 0 7px transparent; }
}
.map-button { transition: background-color .18s ease, border-color .18s ease, transform .18s var(--ease-spring); }
.map-button:hover { transform: scale(1.08); border-color: var(--forest); }
.choice { transition: border-color .18s ease, background-color .18s ease, box-shadow .2s ease; }
.choice:has(input:checked) { box-shadow: inset 3px 0 var(--forest), 0 4px 12px rgba(31, 90, 69, .08); }

/* ---------- feedback states ---------- */

.practice-feedback { border-left: 5px solid #4d7d52; }
.practice-feedback.incorrect { border-left-color: var(--amber-deep); }
.checkpoint-feedback { border-left: 5px solid #4d7d52; }
.checkpoint-feedback.incorrect { border-left-color: var(--amber-deep); }
.repair-resolved > span { box-shadow: 0 8px 20px rgba(31, 90, 69, .3); }

/* ---------- exam save-state pills ----------
   Icon + text (never color alone). data-sync set by app.js:
   synced · busy · pending · offline */

:is(.save-state, .exam-save-state)[data-sync] {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: none;
  padding: 6px 11px;
  border: 1px solid #b7cabb;
  border-radius: 999px;
  background: #eef4ec;
  color: #2c5442;
  font-size: .7rem;
  font-weight: 700;
  text-align: left;
  line-height: 1.3;
}
:is(.save-state, .exam-save-state)[data-sync]::before {
  flex: 0 0 auto;
  font-weight: 800;
}
:is(.save-state, .exam-save-state)[data-sync="synced"]::before { content: "✓"; }
:is(.save-state, .exam-save-state)[data-sync="busy"]::before { content: "◌"; }
:is(.save-state, .exam-save-state):is([data-sync="pending"], [data-sync="offline"]) {
  border-color: #ddba7c;
  background: #fdf3dd;
  color: #6d4a15;
}
:is(.save-state, .exam-save-state)[data-sync="pending"]::before { content: "↑"; }
:is(.save-state, .exam-save-state)[data-sync="offline"]::before { content: "⚠"; }
@media (prefers-reduced-motion: no-preference) {
  :is(.save-state, .exam-save-state)[data-sync="busy"]::before {
    animation: compass-turn 1.2s linear infinite;
  }
}

/* Save feedback must stay visible during answer entry on mobile. */
@media (max-width: 700px) {
  .exam-status > #exam-save-state[data-sync] { display: inline-flex; }
  .exam-header { flex-wrap: wrap; gap: 8px; }
  .site-header .save-state[data-sync] { display: none; }
}

/* ---------- question & lesson imagery ---------- */

.question-figure {
  margin: 22px 0 4px;
  padding: 0;
  display: grid;
  gap: 6px;
}
.question-figure img {
  width: 100%;
  max-width: 460px;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfaf5;
  justify-self: start;
}
.question-figure figcaption {
  color: var(--muted);
  font-size: .66rem;
  font-family: var(--font-mono);
}
.image-gallery {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.image-gallery figure { margin: 0; }
.image-gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfaf5;
}
.image-gallery figcaption { margin-top: 8px; display: grid; gap: 3px; }
.image-gallery figcaption strong { font-size: .9rem; }
.image-gallery figcaption span { color: var(--muted); font-size: .76rem; line-height: 1.4; }
.image-gallery figcaption small { color: var(--muted); font-size: .62rem; font-family: var(--font-mono); overflow-wrap: anywhere; }

/* ---------- 2026 event catalog ---------- */

.catalog-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.catalog-chip {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.catalog-chip:hover { border-color: var(--forest); color: var(--forest); }
.catalog-chip[aria-pressed="true"] { border-color: var(--forest); background: var(--forest); color: white; }
.catalog-count { margin-left: auto; color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; }
.catalog-group { margin-bottom: 26px; }
.catalog-group > h3 {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--forest);
}
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.catalog-event { min-width: 0; padding: 15px 16px; border-radius: 12px; box-shadow: none; }
.catalog-event header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.catalog-event h4 { margin: 0; font-family: var(--font-display); font-size: 1.02rem; }
.division-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e7ebe3;
  color: var(--forest);
  font-size: .62rem;
  font-weight: 800;
}
.catalog-event p { margin: 7px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.catalog-event footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.catalog-event footer a { color: var(--forest); font-size: .74rem; font-weight: 700; text-decoration: none; }
.catalog-event footer a:hover { text-decoration: underline; }
.catalog-pending { color: var(--muted); font-size: .7rem; }
.catalog-actions { display: flex; gap: 6px; }
.catalog-course-link { padding: 6px 11px; border: 1px solid var(--forest); border-radius: 999px; background: var(--forest); color: #fff; font-size: .68rem; font-weight: 800; }
.catalog-course-link:hover { background: var(--forest-dark); }
.catalog-exam-link { padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--amber-soft); color: #744d1a; font-size: .68rem; font-weight: 800; }
.catalog-exam-link:hover { border-color: var(--amber); }
.catalog-content-badge { display: inline-flex; align-items: center; gap: 5px; margin-top: 9px; color: var(--forest); font-size: .68rem; font-weight: 700; }
.catalog-content-badge span { color: var(--amber-deep); }
.catalog-empty { padding: 24px; border: 1px dashed #aab9ac; border-radius: 12px; color: var(--muted); text-align: center; }

/* ---------- Google sign-in ---------- */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0 14px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}
.google-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.google-button svg { flex: 0 0 auto; }
.google-profile-note { margin: 0; color: var(--muted); font-size: .85rem; }
.google-profile-note strong { overflow-wrap: anywhere; }
#resend-verification { margin: 10px auto 0; }

/* ---------- small refinements ---------- */

.notification-count { font-family: var(--font-mono); }
.exam-save-state, .save-state, #lesson-save-state { font-variant-numeric: tabular-nums; }
.demo-note, .tutor-citation small, .citation-evidence small { font-family: var(--font-mono); }
.empty-state { border: 1px dashed #b9c1b3; box-shadow: none; background: #faf9f2; }
.empty-state > span { display: inline-grid; place-items: center; width: 58px; height: 58px; border: 1px solid #cdd4c8; border-radius: 50%; background: white; }

fieldset:not([class]) { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: #fbfaf5; }
fieldset:not([class]) legend { padding: 0 8px; font-weight: 700; font-size: .85rem; }

details summary { transition: color .18s ease; }
details summary:hover { color: var(--forest); }
details[open] summary { color: var(--forest); }

@supports (scrollbar-color: auto) {
  * { scrollbar-color: #b9c1b3 transparent; scrollbar-width: thin; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-track span::after, .lesson-progress span::after { animation: none; content: none; }
}
