/* Cosmetic layer for the current pages.
   Revert by deleting this file and the one <link> in templates/base.html.
   No new copy, routes, or third-party assets. Colours come from the
   geometric A* mark (navy #1E3A5F, gold #C8962E) and the area tints
   already in templates/_personality.html. */

:root {
  --desk: #F3EBDF;
  --raised: #FFFBF6;
  --ink: #1E3A5F;
  --ink-soft: #4A4036;
  --muted: #5C5146;
  --rule: #E3D3BD;
  --gold: #C8962E;
  --gold-ink: #7A5A10;
  --navy: #1E3A5F;
  --navy-hover: #16304F;
  --night: #1C1814;
  --night-raised: #2A241C;
  --night-ink: #F6EFE4;
  --night-muted: #D4C4B0;
}

/* ── Paper ──────────────────────────────────────────────────────────────── */
html:not(.dark) body.bg-gray-50 {
  background-color: var(--desk) !important;
  background-image:
    radial-gradient(980px 340px at 82% -12%, rgba(200, 150, 46, 0.20), transparent 64%),
    radial-gradient(720px 280px at -8% -6%, rgba(30, 58, 95, 0.05), transparent 58%),
    linear-gradient(rgba(243, 235, 223, 0.94), rgba(243, 235, 223, 0.94)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  color: #2C261F;
}

html.dark body {
  background-color: var(--night) !important;
  background-image: radial-gradient(880px 300px at 86% -16%, rgba(200, 150, 46, 0.10), transparent 62%);
  color: var(--night-ink);
}

/* ── Type: the mark's serif, for titles only ────────────────────────────── */
h1,
h2,
.sidebar-logo-text,
.app-topbar .brand-word,
ol strong.block {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  letter-spacing: -0.02em;
}

html:not(.dark) h1:not(.area-title),
html:not(.dark) .text-gray-900:not(.area-title) {
  color: var(--ink) !important;
}
html:not(.dark) .text-gray-800 { color: #3A3128 !important; }
html:not(.dark) .text-gray-700 { color: #3F3428 !important; }
html:not(.dark) .text-gray-600 { color: var(--ink-soft) !important; }
html:not(.dark) .text-gray-500 { color: var(--muted) !important; }
html:not(.dark) .text-gray-400 { color: #6B5C4E !important; }

html.dark h1:not(.area-title),
html.dark h2:not(.area-title) {
  color: var(--night-ink);
}
html.dark .text-gray-100,
html.dark .text-gray-200,
html.dark .text-gray-300,
html.dark .text-white {
  color: var(--night-ink) !important;
}
html.dark .text-gray-400,
html.dark .text-gray-500 {
  color: var(--night-muted) !important;
}

/* ── Chrome ─────────────────────────────────────────────────────────────── */
html:not(.dark) #sidebar,
html:not(.dark) .app-topbar {
  background-color: var(--raised) !important;
  border-color: var(--rule) !important;
}
html.dark #sidebar,
html.dark .app-topbar,
html.dark #forge-tab-rail {
  background-color: #241E18 !important;
  border-color: #3D342A !important;
}

html:not(.dark) .brand-row {
  border-bottom: 2px solid var(--gold) !important;
}
html.dark .brand-row {
  border-bottom: 2px solid #E0B44A !important;
}

.brand-mark {
  height: 36px;
  width: 36px;
  object-fit: contain;
  flex-shrink: 0;
}
.app-topbar .brand-mark {
  height: 28px;
  width: 28px;
}
/* Navy A disappears on the night sidebar; the cream plate is the same
   treatment used when the geometric mark replaced the quill sketch. */
html.dark .brand-mark {
  background-color: #F4EFE6;
  border-radius: 0.45rem;
  padding: 2px;
  box-sizing: content-box;
}

html:not(.dark) .nav-item.active {
  color: var(--ink) !important;
}

/* Resting rows are a list. The area tint returns on hover and on the
   active row, so the sidebar is not a stack of filled buttons. */
.nav-item[data-area]:not(:hover):not(.active) {
  background-color: transparent;
}

/* ── Landing title rule (the asterisk's gold, not a new line of copy) ──── */
.landing-hero h1 {
  background-image: linear-gradient(var(--gold), var(--gold));
  background-repeat: no-repeat;
  background-position: center calc(100% - 0.05rem);
  background-size: 4.5rem 3px;
  padding-bottom: 0.7rem;
}

/* ── Cards and quiet panels ─────────────────────────────────────────────── */
html:not(.dark) .bg-white { background-color: var(--raised) !important; }
html:not(.dark) .bg-gray-50 { background-color: var(--raised) !important; }
html:not(.dark) body.bg-gray-50 { background-color: var(--desk) !important; }
html:not(.dark) .border-gray-100 { border-color: #EADCCB !important; }
html:not(.dark) .border-gray-200,
html:not(.dark) .border-gray-300 { border-color: var(--rule) !important; }

.astar-card {
  border-radius: 0.85rem;
}
.astar-card::before {
  height: 2px;
  background: var(--area, transparent);
}
html:not(.dark) .astar-card {
  background: var(--raised);
  border: 1px solid #E8DCCB;
  box-shadow: none;
}
html:not(.dark) .astar-card:hover {
  border-color: color-mix(in srgb, var(--area, #E8DCCB) 35%, #E8DCCB);
  box-shadow: none;
}
html.dark .astar-card {
  background: var(--night-raised);
  border-color: #3A3128;
  box-shadow: none;
}
/* Read-only panels stay flat. Filled actions keep their own shadow. */
div.rounded-3xl,
li.rounded-2xl {
  box-shadow: none !important;
}
html.dark .dark\:bg-gray-900,
html.dark .dark\:bg-gray-800,
html.dark .bg-gray-900 { background-color: var(--night-raised) !important; }
html.dark .dark\:bg-gray-950 { background-color: var(--night) !important; }
html.dark .dark\:border-gray-700,
html.dark .dark\:border-gray-800,
html.dark .border-gray-700,
html.dark .border-gray-800 { border-color: #4A3E32 !important; }
html.dark .dark\:text-white { color: var(--night-ink) !important; }
html.dark .dark\:text-gray-100,
html.dark .dark\:text-gray-200,
html.dark .dark\:text-gray-300 { color: var(--night-ink) !important; }
html.dark .dark\:text-gray-400,
html.dark .dark\:text-gray-500 { color: var(--night-muted) !important; }

/* ── Sheen: the March 2026 dashboard glow-btn (commit 3acb886).
   A 35% band, skewed -25deg, travels 350% in 3.8s. It sits behind the
   label. Primary actions loop it. Tabs and outline buttons play it once
   on hover or focus, so the sidebar does not keep moving. ───────────── */
@keyframes astar-sheen {
  100% { transform: translateX(350%) skewX(-25deg); }
}
a.bg-indigo-600,
button.bg-indigo-600,
a.bg-sky-600,
button.bg-sky-600,
.nav-item,
.forge-tab,
.landing-hero a.bg-white {
  position: relative;
  z-index: 0;
}
a.bg-indigo-600::before,
button.bg-indigo-600::before,
a.bg-sky-600::before,
button.bg-sky-600::before,
.nav-item::before,
.forge-tab::before,
.landing-hero a.bg-white::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: -50%;
  left: -60%;
  width: 35%;
  height: 300%;
  background: linear-gradient(120deg, transparent, rgba(255, 244, 220, 0.22), transparent);
  transform: translateX(-20%) skewX(-25deg);
  pointer-events: none;
}
.nav-item,
.forge-tab {
  overflow: hidden;
}
.nav-item::before,
.forge-tab::before,
.landing-hero a.bg-white::before {
  opacity: 0;
  width: 18%;
  /* A pale band disappears on paper. A thin gold streak reads on an outline or a tab
     and stays behind the label, so the words keep their own colour. */
  background: linear-gradient(120deg, transparent, rgba(176, 112, 16, 0.32), transparent);
}
a.bg-indigo-600::before,
button.bg-indigo-600::before,
a.bg-sky-600::before,
button.bg-sky-600::before {
  animation: astar-sheen 3.8s linear infinite;
}
.nav-item:focus-visible,
.forge-tab:focus-visible {
  overflow: hidden !important;
}
.nav-item:hover::before,
.nav-item:focus-visible::before,
.forge-tab:hover::before,
.forge-tab:focus-visible::before,
.landing-hero a.bg-white:hover::before,
.landing-hero a.bg-white:focus-visible::before {
  opacity: 1;
  animation: astar-sheen 1.8s ease-out 1;
}
button:disabled::before,
button[disabled]::before,
[aria-busy="true"]::before {
  animation: none !important;
}

/* ── Buttons: filled actions, quiet outlines. Labels stay in the templates. */
a.bg-indigo-600,
button.bg-indigo-600,
a.bg-sky-600,
button.bg-sky-600 {
  background-color: var(--navy) !important;
  color: #FFFBF6 !important;
  border-color: transparent !important;
  overflow: hidden;
}
a.bg-indigo-600:hover,
button.bg-indigo-600:hover,
a.bg-sky-600:hover,
button.bg-sky-600:hover,
a.bg-indigo-700:hover,
button.bg-indigo-700:hover,
a.bg-indigo-600.rw-interactive:hover,
button.bg-indigo-600.rw-interactive:hover,
a.bg-sky-600.rw-interactive:hover,
button.bg-sky-600.rw-interactive:hover {
  background-color: var(--navy-hover) !important;
  color: #FFFBF6 !important;
  box-shadow: inset 0 -3px 0 var(--gold) !important;
}
html.dark a.bg-indigo-600,
html.dark button.bg-indigo-600,
html.dark a.bg-sky-600,
html.dark button.bg-sky-600 {
  border: 1px solid #E0B44A !important;
}
a.bg-indigo-600:focus-visible,
button.bg-indigo-600:focus-visible,
a.bg-sky-600:focus-visible,
button.bg-sky-600:focus-visible {
  overflow: hidden !important;
}

html:not(.dark) a.bg-white,
html:not(.dark) button.bg-white {
  background-color: transparent !important;
  border: 1px solid #C4A882 !important;
  color: var(--ink) !important;
  box-shadow: none !important;
}
html:not(.dark) a.bg-white:hover,
html:not(.dark) button.bg-white:hover {
  background-color: rgba(200, 150, 46, 0.12) !important;
}
html:not(.dark) a.bg-white:focus-visible,
html:not(.dark) button.bg-white:focus-visible {
  box-shadow: 0 0 0 2px var(--desk), 0 0 0 4px var(--gold-ink) !important;
  outline: 2px solid var(--gold-ink) !important;
  outline-offset: 3px !important;
}
.landing-hero a.bg-white {
  border: 1px solid var(--navy) !important;
  overflow: hidden;
}

/* Cards and text links do not jump. The filled actions still lift. */
a.rw-interactive:not(.bg-indigo-600):not(.bg-sky-600):hover,
a.rw-interactive:not(.bg-indigo-600):not(.bg-sky-600):active,
button.rw-interactive:not(.bg-indigo-600):not(.bg-sky-600):hover,
button.rw-interactive:not(.bg-indigo-600):not(.bg-sky-600):active {
  transform: none !important;
  box-shadow: none !important;
}

html:not(.dark) .bg-indigo-50 { background-color: #F8F1DE !important; }
html:not(.dark) .text-indigo-900,
html:not(.dark) .text-indigo-800,
html:not(.dark) .text-indigo-700 { color: var(--ink) !important; }
html:not(.dark) .border-indigo-200,
html:not(.dark) .border-indigo-700 { border-color: #E3C48A !important; }

html:not(.dark) .site-version {
  color: var(--gold-ink) !important;
  background: #F4E6C4 !important;
}
html.dark .site-version {
  color: #F6E6C0 !important;
  background: rgba(200, 150, 46, 0.22) !important;
}

/* ── Exam Grader's start-here strip, same words, warmer paper ──────────── */
html:not(.dark) #startHereGuide {
  background: #F8F1E4 !important;
  border: 1px solid #E6D7C0 !important;
  box-shadow: none !important;
}
html:not(.dark) #startHereGuide .text-sky-900,
html:not(.dark) #startHereGuide .text-sky-800,
html:not(.dark) #startHereGuide .text-sky-700,
html:not(.dark) #startHereGuide .text-sky-100,
html:not(.dark) #startHereGuide .text-sky-200,
html:not(.dark) #startHereGuide .text-sky-300 {
  color: var(--ink) !important;
}
html.dark #startHereGuide {
  background: linear-gradient(90deg, rgba(200, 150, 46, 0.16), rgba(30, 58, 95, 0.35)) !important;
  border-color: #E0B44A !important;
}

/* ── Paper Forge rail: warm paper, subject colours left as they are ────── */
html:not(.dark) #forge-tab-rail {
  background: var(--raised) !important;
  border-color: var(--rule) !important;
}
.forge-tab.border-indigo-500 {
  border-left-color: var(--navy) !important;
  background: rgba(200, 150, 46, 0.14);
}
html.dark .forge-tab.border-indigo-500 {
  border-left-color: #E0B44A !important;
  background: rgba(200, 150, 46, 0.12);
}

/* ── Fields ─────────────────────────────────────────────────────────────── */
html:not(.dark) input:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=file]),
html:not(.dark) select,
html:not(.dark) textarea {
  background-color: #F4E7D4 !important;
  border: 1.5px solid #6E5A40 !important;
  border-radius: 0.55rem !important;
  box-shadow: inset 0 1px 2px rgba(44, 32, 16, 0.14);
  color: #2C261F;
}
/* Beats the paper fill on .bg-white and the tan rule on .border-gray-300,
   so a field is not the same surface as the card around it. */
html:not(.dark) textarea.bg-white,
html:not(.dark) select.bg-white,
html:not(.dark) input.bg-white:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=file]) {
  background-color: #F4E7D4 !important;
  border-color: #6E5A40 !important;
  border-width: 1.5px !important;
  border-style: solid !important;
}
html.dark input:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=file]),
html.dark select,
html.dark textarea {
  background-color: #16130F !important;
  border: 1.5px solid #C4A882 !important;
  border-radius: 0.55rem !important;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  color: var(--night-ink);
}
html.dark textarea.dark\:bg-gray-800,
html.dark select.dark\:bg-gray-800,
html.dark input.dark\:bg-gray-800:not([type=radio]):not([type=checkbox]):not([type=range]):not([type=file]) {
  background-color: #16130F !important;
  border-color: #C4A882 !important;
  border-width: 1.5px !important;
  border-style: solid !important;
}

/* ── Focus: a gold ring that stays visible on the paper ────────────────── */
:focus-visible {
  outline: 2px solid var(--gold-ink) !important;
  outline-offset: 3px !important;
}
html.dark :focus-visible {
  outline-color: #E0B44A !important;
}
a:focus-visible,
button:focus-visible,
[role="switch"]:focus-visible {
  overflow: visible !important;
  box-shadow: 0 0 0 2px var(--raised), 0 0 0 4px var(--gold-ink) !important;
}
html.dark a:focus-visible,
html.dark button:focus-visible,
html.dark [role="switch"]:focus-visible {
  box-shadow: 0 0 0 2px var(--night), 0 0 0 4px #E0B44A !important;
}
input:not([type=radio]):not([type=checkbox]):not([type=range]):focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--gold-ink) !important;
  outline-offset: 1px !important;
  box-shadow: 0 0 0 3px rgba(200, 150, 46, 0.28) !important;
  border-color: var(--gold-ink) !important;
}
html.dark input:not([type=radio]):not([type=checkbox]):not([type=range]):focus,
html.dark select:focus,
html.dark textarea:focus {
  outline-color: #E0B44A !important;
  border-color: #E0B44A !important;
  box-shadow: 0 0 0 3px rgba(224, 180, 74, 0.28) !important;
}

/* ── Footer stays on the page, in ink rather than cool gray ────────────── */
html:not(.dark) footer {
  border-top-color: var(--rule) !important;
  color: var(--muted) !important;
}
html:not(.dark) footer a {
  color: #1A3354;
}
html:not(.dark) footer a:hover {
  color: var(--navy-hover);
}
html:not(.dark) footer strong,
html:not(.dark) footer strong.text-gray-600 {
  color: var(--ink) !important;
}
html.dark footer {
  border-top-color: #4A3E32 !important;
  color: var(--night-muted) !important;
}
html.dark footer a,
html.dark footer strong {
  color: var(--night-ink) !important;
}

/* ── Motion ─────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .rw-interactive,
  .rw-interactive:hover,
  .rw-interactive:active,
  .rw-interactive:not(.nav-item):hover,
  .rw-interactive:not(.nav-item):active,
  .nav-item.rw-interactive:hover,
  .nav-item.rw-interactive:active,
  .astar-card,
  .astar-card:hover,
  .fa-arrow-right {
    transition: none !important;
    transform: none !important;
    animation: none !important;
  }
  .rw-ripple-el { display: none !important; }
  a.bg-indigo-600::before,
  button.bg-indigo-600::before,
  a.bg-sky-600::before,
  button.bg-sky-600::before,
  .nav-item::before,
  .forge-tab::before,
  .landing-hero a.bg-white::before {
    animation: none !important;
  }
}
