/* ============================================================
   Breakthrough30 — Kings & Queens design system (web)
   One royal aesthetic, two lights.
   Dark: the throne room at night — navy, gold, burgundy, cream.
   Light: an illuminated manuscript — warm parchment, white vellum,
   the same gold and burgundy. Never plain white, never pure black.
   Theme is applied as class="dark" | "light" on <html>.
   ============================================================ */

:root,
html.dark {
  /* Backgrounds */
  --bg-top: #0e1b33;
  --bg-bottom: #070e1d;

  /* Surfaces */
  --surface: #152647;
  --surface-alt: #11203d;
  --border: #24365c;
  --card-border: rgba(201, 162, 39, 0.25);

  /* Text */
  --text: #f3ebd8;
  --text-2: rgba(243, 235, 216, 0.72);   /* 7.22:1 on surface (AAA) */
  --text-3: rgba(243, 235, 216, 0.55);   /* 5.04:1 on surface-alt (AA) */

  /* Accents */
  --gold: #c9a227;          /* decorative fills only */
  --gold-text: #d4af37;     /* 9.17:1 abyss / 7.13:1 surface (AAA) */
  --gold-ui: #c9a227;       /* interactive borders — 3:1+ on navy */
  --gold-bright: #e6c96a;
  --on-gold: #0a0e1a;
  --burgundy: #6e1f33;
  --burgundy-deep: #431222;
  --seal-bg: rgba(67, 18, 34, 0.55);
  --seal-border: rgba(110, 31, 51, 0.6);

  color-scheme: dark;
}

html.light {
  --bg-top: #faf6ee;
  --bg-bottom: #f5f0e8;

  --surface: #ffffff;
  --surface-alt: #ede8de;
  --border: #d4c9b0;
  --card-border: rgba(201, 162, 39, 0.35);

  --text: #0a0e1a;
  --text-2: #243352;                     /* 11.08:1 on parchment (AAA) */
  --text-3: rgba(36, 51, 82, 0.72);      /* 4.93:1 on parchment (AA) */

  --gold: #c9a227;          /* decorative fills only */
  --gold-text: #796012;     /* 5.3:1 parchment / 6.01:1 white (AA+) */
  --gold-ui: #8a6d12;       /* interactive borders — 4.33:1 on parchment */
  --gold-bright: #a8861d;
  --on-gold: #0a0e1a;
  --seal-bg: rgba(110, 31, 51, 0.08);
  --seal-border: rgba(110, 31, 51, 0.35);

  color-scheme: light;
}

:root {
  /* Type */
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  /* Breakpoints (reference) */
  --bp-mobile: 430px;
  --bp-tablet: 768px;
  --bp-desktop: 1025px;
  --bp-wide: 1440px;

  /* Content widths */
  --content-mobile: 430px;
  --content-tablet: 680px;
  --content-desktop: 960px;

  /* Fluid type — min @320px viewport, max @1440px */
  --text-xs:   clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --text-base: clamp(1rem, 0.925rem + 0.375vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem + 0.625vw, 1.375rem);
  --text-xl:   clamp(1.375rem, 1.15rem + 1.125vw, 1.875rem);
  --text-2xl:  clamp(1.75rem, 1.4rem + 1.75vw, 2.5rem);
  --text-3xl:  clamp(2rem, 1.5rem + 2.5vw, 3.25rem);
  --text-hero: clamp(2.5rem, 1.75rem + 3.75vw, 4.5rem);

  /* Metrics */
  --radius: 14px;
  --page-pad: 24px;
  --section-gap: 28px;

  /* Motion — slow, deliberate, reverent */
  --ease-reverent: cubic-bezier(0.42, 0, 0.58, 1);
  --dur-reverent: 0.7s;
  --dur-processional: 1.2s;
}

/* ---------- Base ---------- */

html, body {
  margin: 0;
  min-height: 100%;
}

html {
  background: var(--bg-bottom);
  transition: background-color 0.3s ease;
}

html.light body {
  background: radial-gradient(ellipse 120% 60% at 50% 0%,
    #ede8de 0%, #f5f0e8 55%, #faf6ee 100%) fixed;
}

body {
  width: 100%;
  min-height: 100vh;
  background: radial-gradient(ellipse 120% 60% at 50% 0%,
    #1b2a4a 0%, #0a0e1a 55%, #070912 100%) fixed;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: color 0.3s ease;
}

h1, h2, h3, .serif {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--text);
  margin: 0;
  transition: color 0.3s ease;
}

h1 { font-size: var(--text-2xl); line-height: 1.2; }
h2 { font-size: var(--text-xl); font-weight: 500; }
h3 { font-size: var(--text-lg); font-weight: 500; }

p { margin: 0 0 1em; max-width: 65ch; }

.muted { color: var(--text-2); transition: color 0.3s ease; }
.faint { color: var(--text-3); transition: color 0.3s ease; }

/* ---------- Theme toggle ---------- */
/* Moon in the dark, sun on parchment. Gold, quiet, top-right. */

.theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
  background: none;
  border: none;
  padding: 8px;
  font-size: 20px;
  line-height: 1;
  color: var(--gold-text);
  cursor: pointer;
  transition: color 0.3s ease;
}
.theme-toggle:hover { color: var(--gold-bright); }
.theme-toggle.spin { animation: toggle-spin 0.3s ease; }
@keyframes toggle-spin {
  from { transform: rotate(-90deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ---------- Court label ---------- */
/* THE WORD · THE AUDIENCE · THE COUNSEL · THE CHARGE · THE RETURN */

.court-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--gold-text);
  transition: color 0.3s ease;
}

/* ---------- Ornament divider ---------- */

.ornament {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.ornament::before,
.ornament::after {
  content: "";
  flex: 1;
  height: 1px;
}
.ornament::before {
  background: linear-gradient(to right, transparent, rgba(201, 162, 39, 0.6));
}
.ornament::after {
  background: linear-gradient(to left, transparent, rgba(201, 162, 39, 0.6));
}
.ornament .gem {
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: rotate(45deg);
}

/* ---------- Scripture block ---------- */

.scripture {
  border-left: 2px solid rgba(201, 162, 39, 0.7);
  padding-left: 16px;
  margin: 0;
}
.scripture .text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--text-lg);
  line-height: 1.6;
  color: var(--text);
  transition: color 0.3s ease;
}
.scripture .reference {
  display: block;
  margin-top: 12px;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--gold-text);
  font-style: normal;
  transition: color 0.3s ease;
}

/* ---------- Royal card ---------- */

.royal-card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ---------- Buttons ---------- */
/* Presses settle slowly — nothing springs. */

.btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 15px 24px;
  border-radius: var(--radius);
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  min-height: 44px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  transition:
    background-color 0.35s var(--ease-reverent),
    color 0.35s var(--ease-reverent),
    border-color 0.35s var(--ease-reverent),
    transform 0.35s var(--ease-reverent);
}
.btn:active { transform: scale(0.985); }

.btn-primary {
  background: var(--gold);
  color: var(--on-gold);
  font-weight: 600;
  border: none;
}
.btn-primary:hover { background: var(--gold-bright); }

.btn-secondary {
  background: transparent;
  color: var(--gold-text);
  font-weight: 500;
  border: 1px solid var(--gold-ui);
}
.btn-secondary:hover { color: var(--gold-bright); border-color: var(--gold-bright); }

/* ---------- Chamber accents (Solomon's Temple) ---------- */
/* 1 Bronze Sea · 2 Menorah · 3 Showbread cedar · 4 Shekinah glory */

.chamber-1 { --chamber-accent: #8b6914; }
.chamber-2 { --chamber-accent: #c9a227; }
.chamber-3 { --chamber-accent: #a0522d; }
.chamber-4 { --chamber-accent: #f0d060; }

/* Inside a chamber scope, ornaments and seals take the chamber's metal */
.ornament .gem { background: var(--chamber-accent, var(--gold)); }
.ornament::before {
  background: linear-gradient(to right, transparent,
    color-mix(in srgb, var(--chamber-accent, var(--gold)) 60%, transparent));
}
.ornament::after {
  background: linear-gradient(to left, transparent,
    color-mix(in srgb, var(--chamber-accent, var(--gold)) 60%, transparent));
}

/* ---------- Chamber hero imagery ---------- */

.chamber-hero,
.chamber-banner {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  background-size: cover;
  background-position: center;
  overflow: hidden;
}
.chamber-hero { height: 200px; }
.chamber-banner { height: 120px; }
.chamber-hero::after,
.chamber-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, transparent 35%, var(--bg-bottom) 100%),
    linear-gradient(to bottom,
      color-mix(in srgb, var(--chamber-accent, var(--gold)) 12%, transparent),
      transparent 50%);
}

/* ---------- Chamber seal ---------- */

.chamber-seal {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--seal-bg);
  border: 1px solid var(--seal-border);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  color: var(--text-2);
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.chamber-seal {
  border-color: color-mix(in srgb, var(--chamber-accent, var(--burgundy)) 45%, transparent);
}
.chamber-seal::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chamber-accent, var(--burgundy));
  box-shadow: inset 0 0 0 0.5px rgba(201, 162, 39, 0.5);
}

/* ---------- Reverent entrance ---------- */
/* Each screen enters like a room, not a toast. */

@keyframes enter-court {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.enter {
  animation: enter-court var(--dur-reverent) var(--ease-reverent) both;
}
.enter.delayed { animation-delay: 0.15s; }

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

/* ---------- Focus (keyboard navigation) ---------- */

:focus-visible {
  outline: 2px solid var(--gold-text);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--gold);
  color: var(--on-gold);
  padding: 8px 16px;
  z-index: 9999;
  font-weight: bold;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
}

/* ---------- Screen-reader only ---------- */

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

/* Section labels rendered as headings keep the label look */
h2.court-label, h1.court-label { font-weight: 600; }

/* ---------- Layout helper ---------- */

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--page-pad);
  display: grid;
  gap: var(--section-gap);
}

/* The app proper reads as a phone column on any screen; the royal
   background bleeds full-width behind it (html/body carry it). */
.page.app { max-width: var(--content-mobile); width: 100%; }

.stack {
  display: grid;
  gap: var(--section-gap);
}

/* ============================================================
   App components
   ============================================================ */

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

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-right: 44px; /* clear the fixed theme toggle */
}
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  color: var(--gold-text);
  text-decoration: none;
  transition: color 0.35s var(--ease-reverent);
}
.back-link:hover { color: var(--gold-bright); }

/* ---------- Home ---------- */

.day-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  transition: background-color 0.3s ease, color 0.3s ease,
              border-color 0.35s var(--ease-reverent);
}
.day-card:hover { border-color: rgba(201, 162, 39, 0.5); }

.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: var(--text-2);
  transition: color 0.3s ease;
}
.status-row span:first-child { color: var(--gold-text); }
.burgundy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--burgundy);
  box-shadow: inset 0 0 0 0.5px rgba(201, 162, 39, 0.5);
}

/* ---------- Day view ---------- */

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.section-body {
  margin: 14px 0 0;
}

.seal-btn {
  font-family: var(--font-serif);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gold-text);
  background: transparent;
  border: 1px solid var(--gold-ui);
  border-radius: 999px;
  padding: 6px 14px;
  min-height: 44px;
  cursor: pointer;
  transition:
    background-color 0.7s var(--ease-reverent),
    color 0.7s var(--ease-reverent),
    border-color 0.7s var(--ease-reverent);
}
.seal-btn.sealed {
  background: var(--gold);
  color: var(--on-gold);
  border-color: var(--gold);
  font-weight: 600;
}

/* ---------- Journey map ---------- */

.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.medallion {
  aspect-ratio: 1;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--text-3);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  transition:
    background-color 0.3s ease,
    border-color 0.35s var(--ease-reverent),
    color 0.35s var(--ease-reverent);
}
.medallion:hover { border-color: rgba(201, 162, 39, 0.5); color: var(--text-2); }
.medallion.current {
  background: var(--surface);
  border: 1.5px solid var(--gold-ui);
  color: var(--gold-text);
  font-weight: 500;
}
.medallion.done {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-gold);
  font-weight: 600;
}

@media (max-width: 420px) {
  .day-grid { gap: 7px; }
  .medallion { font-size: 0.8125rem; }
}

/* ---------- Settings ---------- */

.gear-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--gold-text);
  text-decoration: none;
  transition: color 0.3s ease;
}
.gear-link:hover { color: var(--gold-bright); }

.time-input {
  font-family: var(--font-serif);
  font-size: 1rem;
  min-height: 44px;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.linklike {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 0;
}




/* ============================================================
   Responsive system (spec: mobile default · tablet 768 ·
   desktop 1025 3-column shell · wide 1440)
   ============================================================ */

/* Mobile defaults: wrappers flatten into the single column */
.day-content { display: contents; }
.day-progress, .sidebar-left, .sidebar-right, .hero-art { display: none; }
.app-shell { width: 100%; }
.print-header { display: none; }

/* ---------- Tablet (768px+) ---------- */
@media (min-width: 768px) {
  .page.app { max-width: var(--content-tablet); padding-left: 24px; padding-right: 24px; }

  .royal-card {
    padding: 24px 28px;
    border-radius: 16px;
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.35),
                inset 0 1px 0 rgba(201, 162, 39, 0.08);
  }
  html.light .royal-card {
    box-shadow: 0 4px 32px rgba(36, 51, 82, 0.12),
                inset 0 1px 0 rgba(201, 162, 39, 0.15);
  }

  /* Home: subtle app-card container */
  .home-card {
    background: rgba(27, 42, 74, 0.4);
    border: 1px solid rgba(201, 162, 39, 0.12);
    border-radius: 24px;
    padding: 32px;
    margin-top: 24px;
  }
  html.light .home-card {
    background: rgba(255, 255, 255, 0.55);
  }

  /* Day screen: symmetric two-column court */
  .day-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "word     charge"
      "audience return"
      "counsel  progress";
    gap: 16px;
    align-items: start;
  }
  .section-word     { grid-area: word; }
  .section-audience { grid-area: audience; }
  .section-counsel  { grid-area: counsel; }
  .section-charge   { grid-area: charge; }
  .section-return   { grid-area: return; }
  .day-progress     { grid-area: progress; display: block; }
  .day-ornament     { display: none; }

  .chambers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .chamber-block { border: 1px solid var(--card-border); border-radius: 16px; padding: 16px; }
  .page.app.journey-view { max-width: var(--content-desktop); }

  .medallion { min-width: 52px; min-height: 52px; font-size: var(--text-sm); }
  .chamber-hero { height: 260px; }
  .chamber-banner { height: 160px; }
}

/* ---------- Desktop (1025px+): three-column shell ---------- */
@media (min-width: 1025px) {
  .app-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 240px;
    max-width: var(--content-desktop);
    margin: 0 auto;
    min-height: 100vh;
    gap: 0;
  }

  .sidebar-left {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 32px 24px;
    border-right: 1px solid rgba(201, 162, 39, 0.1);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .sidebar-left .wordmark {
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--gold-text);
    text-decoration: none;
    margin-bottom: 14px;
  }
  .sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
  .sidebar-nav a {
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-family: var(--font-serif);
    font-size: var(--text-sm);
    transition: background 0.2s, color 0.2s;
  }
  .sidebar-nav a:hover,
  .sidebar-nav a[aria-current="page"] {
    background: rgba(201, 162, 39, 0.1);
    color: var(--gold-text);
  }
  .sidebar-streak {
    margin-top: auto;
    padding: 16px;
    background: rgba(27, 42, 74, 0.5);
    border-radius: 12px;
    border: 1px solid rgba(201, 162, 39, 0.12);
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-2);
  }
  html.light .sidebar-streak { background: rgba(237, 232, 222, 0.6); }

  .sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 32px 24px;
    border-left: 1px solid rgba(201, 162, 39, 0.1);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .seal-tracker { display: flex; flex-direction: column; gap: 12px; }
  .seal-tracker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    color: var(--text-2);
  }
  .seal-tracker-item.sealed { color: var(--gold-text); }
  .sidebar-quote {
    margin-top: auto;
    border-left: 2px solid var(--gold);
    padding-left: 16px;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: var(--text-sm);
    color: var(--text-2);
    line-height: 1.7;
  }

  .page.app,
  .page.app.journey-view { max-width: 600px; padding: 32px 40px; margin: 0 auto; }
  .topnav { display: none; }

  /* Day hero full-bleed across the content column */
  .day-view .chamber-hero { margin: -32px -40px 0; height: 280px; border-radius: 0; }

  .medallion { min-width: 60px; min-height: 60px; position: relative; overflow: visible; }
  .medallion:hover {
    transform: scale(1.12);
    box-shadow: 0 0 20px rgba(201, 162, 39, 0.35);
  }
  .medallion:hover::after {
    content: attr(data-title);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid rgba(201, 162, 39, 0.3);
    color: var(--text);
    font-size: var(--text-xs);
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
  }
}

/* ---------- Wide (1440px+) ---------- */
@media (min-width: 1440px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr) 280px;
    max-width: 1100px;
  }
  .page.app,
  .page.app.journey-view { padding: 40px 56px; max-width: 640px; }
}

/* ---------- Print: a day fit for journaling ---------- */
@media print {
  .topnav, .sidebar-left, .sidebar-right, .seal-btn, .btn,
  .gear-link, .chamber-hero, .chamber-banner, .ornament,
  .status-row, .chamber-seal, .day-progress, .skip-link {
    display: none !important;
  }
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
  }
  body::before {
    content: "Breakthrough30 · " attr(data-day) " · " attr(data-title);
    display: block;
    font-family: var(--font-serif);
    font-size: 12pt;
    color: #666;
    border-bottom: 1pt solid #ccc;
    padding-bottom: 8pt;
    margin-bottom: 16pt;
  }
  #main-content { margin: 0 !important; max-width: 100% !important; padding: 0 !important; }
  .royal-card {
    border: 1px solid #ccc;
    box-shadow: none !important;
    background: #fff !important;
    break-inside: avoid;
    margin-bottom: 16px;
  }
  h1, h2, h3, .serif, .scripture .text, .scripture .reference, .muted, p { color: #000 !important; }
  .court-label { color: #666 !important; }
}
