@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;700&family=Source+Serif+4:opsz,wght@8..60,400;8..60,500&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---------- Design tokens ---------- */
:root {
  --paper: #ECEEE8;
  --paper-deep: #DCE1D7;
  --ink: #1E2421;
  --ink-soft: #5B645F;
  --accent-clinical: #3F5E4D;
  --accent-signature: #B6862C;
  --accent-signature-soft: #E4D2A4;
  --white: #FFFFFF;

  /* Core-family wedge tints — distinct hue per family, stepped lightness
     (core darkest → leaf lightest) so depth reads naturally outward. */
  /* Happy — yellow-gold */
  --c0-core: hsl(45, 70%, 62%); --c0-mid: hsl(45, 60%, 74%); --c0-leaf: hsl(45, 50%, 86%);
  /* Surprised — cyan-teal */
  --c1-core: hsl(185, 55%, 55%); --c1-mid: hsl(185, 45%, 70%); --c1-leaf: hsl(185, 38%, 83%);
  /* Bad — warm brown */
  --c2-core: hsl(28, 48%, 58%); --c2-mid: hsl(28, 38%, 72%); --c2-leaf: hsl(28, 30%, 84%);
  /* Fearful — soft purple */
  --c3-core: hsl(270, 32%, 60%); --c3-mid: hsl(270, 25%, 73%); --c3-leaf: hsl(270, 20%, 85%);
  /* Angry — red-orange */
  --c4-core: hsl(8, 58%, 60%); --c4-mid: hsl(8, 45%, 73%); --c4-leaf: hsl(8, 36%, 85%);
  /* Disgusted — olive-green */
  --c5-core: hsl(125, 28%, 52%); --c5-mid: hsl(125, 22%, 67%); --c5-leaf: hsl(125, 18%, 80%);
  /* Sad — steel blue */
  --c6-core: hsl(210, 48%, 55%); --c6-mid: hsl(210, 38%, 70%); --c6-leaf: hsl(210, 30%, 83%);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Source Serif 4', serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(20px, 5vw, 48px) clamp(16px, 5vw, 32px) 32px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink);
  margin-bottom: clamp(24px, 5vw, 40px);
}

.masthead-glyph {
  font-size: 28px;
  color: var(--accent-clinical);
  line-height: 1;
}

.masthead-text h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(20px, 4vw, 28px);
  margin: 0;
  letter-spacing: -0.01em;
}

.masthead-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin: 4px 0 0;
  letter-spacing: 0.02em;
}

/* ---------- Screens ---------- */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.screen.is-active { display: flex; }

@media (prefers-reduced-motion: no-preference) {
  .screen.is-active { animation: fadeUp 0.45s ease both; }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.prompt {
  font-size: clamp(22px, 4.5vw, 30px);
  font-weight: 500;
  margin: 0 0 6px;
}
.prompt span { color: var(--accent-clinical); font-style: italic; }

.instruction {
  font-size: 16px;
  color: var(--ink-soft);
  margin: 0 0 28px;
  max-width: 440px;
}

/* ---------- Wheel ---------- */
.wheel-stage {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel {
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1 / 1;
  overflow: visible;
}

.wedge {
  stroke: var(--paper);
  stroke-width: 1.5;
  cursor: default;
  transition: filter 0.15s ease, stroke 0.15s ease;
}

.wedge-core    { cursor: pointer; stroke-width: 2; }
.wedge-middle  { cursor: pointer; stroke-width: 1.5; }
.wedge-leaf    { cursor: pointer; stroke-width: 1.5; }

.wedge-core:hover,   .wedge-core:focus-visible,
.wedge-middle:hover, .wedge-middle:focus-visible,
.wedge-leaf:hover,   .wedge-leaf:focus-visible {
  filter: brightness(0.94);
  outline: none;
  stroke: var(--accent-clinical);
  stroke-width: 2.5;
}

.wedge.is-selected {
  fill: var(--accent-signature) !important;
  stroke: var(--ink);
  stroke-width: 2;
}

/* core/middle fills by family */
.core-0.wedge-core { fill: var(--c0-core); } .core-0.wedge-middle { fill: var(--c0-mid); } .core-0.wedge-leaf { fill: var(--c0-leaf); }
.core-1.wedge-core { fill: var(--c1-core); } .core-1.wedge-middle { fill: var(--c1-mid); } .core-1.wedge-leaf { fill: var(--c1-leaf); }
.core-2.wedge-core { fill: var(--c2-core); } .core-2.wedge-middle { fill: var(--c2-mid); } .core-2.wedge-leaf { fill: var(--c2-leaf); }
.core-3.wedge-core { fill: var(--c3-core); } .core-3.wedge-middle { fill: var(--c3-mid); } .core-3.wedge-leaf { fill: var(--c3-leaf); }
.core-4.wedge-core { fill: var(--c4-core); } .core-4.wedge-middle { fill: var(--c4-mid); } .core-4.wedge-leaf { fill: var(--c4-leaf); }
.core-5.wedge-core { fill: var(--c5-core); } .core-5.wedge-middle { fill: var(--c5-mid); } .core-5.wedge-leaf { fill: var(--c5-leaf); }
.core-6.wedge-core { fill: var(--c6-core); } .core-6.wedge-middle { fill: var(--c6-mid); } .core-6.wedge-leaf { fill: var(--c6-leaf); }

.wedge-label {
  font-family: var(--font-display);
  fill: var(--ink);
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
  user-select: none;
}
.wedge-label-core   { font-size: 13px; font-weight: 700; }
.wedge-label-middle { font-size: 9px; font-weight: 500; }
.wedge-label-leaf   { font-size: 7.5px; font-weight: 400; }

.readout {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  min-height: 24px;
}
.readout-label { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.readout-value { font-size: 16px; color: var(--accent-clinical); font-weight: 500; }

/* ---------- Selection tray ---------- */
.selection-tray {
  margin-top: 22px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 4px;
  transition: background 0.2s ease;
}
.selection-tray.limit-flash { background: var(--accent-signature-soft); }

.tray-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}

.tray-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 32px;
}

.pill {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--white);
  border: 1.5px solid var(--accent-signature);
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill::after { content: '\2715'; font-size: 10px; color: var(--ink-soft); }
.pill:hover { background: var(--accent-signature-soft); }
.pill:focus-visible { outline: 2px solid var(--accent-clinical); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.align-button, .reset-button, .retry-button {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 14px 28px;
  margin-top: 26px;
  cursor: pointer;
  background: var(--accent-signature);
  color: var(--white);
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.align-button:hover:not(:disabled), .reset-button:hover, .retry-button:hover { transform: translateY(-1px); }
.align-button:focus-visible, .reset-button:focus-visible, .retry-button:focus-visible {
  outline: 2px solid var(--accent-clinical); outline-offset: 3px;
}
.align-button:disabled { background: var(--paper-deep); color: var(--ink-soft); cursor: not-allowed; }

.reset-button { background: var(--accent-clinical); }
.retry-button { background: var(--ink); margin-top: 12px; }

/* ---------- Colored pills (intake tray + processing screen) ---------- */
.pill-wheel {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  border-radius: 999px;
  padding: 10px 24px;
  display: inline-block;
  border: 2px solid rgba(0,0,0,0.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  letter-spacing: 0.01em;
}

.processing-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

/* ---------- Processing screen ---------- */
.processing-label {
  font-family: var(--font-display);
  font-size: 18px;
  margin-bottom: 18px;
  color: var(--ink-soft);
}

.seed-readout {
  font-family: var(--font-mono);
  font-size: clamp(14px, 3.4vw, 18px);
  background: var(--white);
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  padding: 16px 20px;
  min-width: 260px;
  min-height: 1.4em;
  color: var(--accent-clinical);
}

.processing-error {
  margin-top: 22px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: #8C3B2A;
}

/* ---------- Reveal screen ---------- */
.reveal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}
.reveal-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--accent-clinical);
  color: var(--accent-clinical);
  border-radius: 999px;
  padding: 4px 12px;
}

.comic-frame {
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 4px;
  padding: 10px;
  box-shadow: 4px 4px 0 var(--accent-signature);
  max-width: 100%;
}
.comic-frame img {
  display: block;
  max-width: 100%;
  height: auto;
}

.reveal-caption {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  margin: 20px 0 4px;
  color: var(--accent-clinical);
}

.comic-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin: 0;
}
.comic-meta a { color: var(--ink-soft); }

/* ---------- Response screen ---------- */
.response-message {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(26px, 5vw, 38px);
  color: var(--ink);
  max-width: 480px;
  line-height: 1.3;
  margin: 0 0 32px;
}

/* ---------- Regulation check ---------- */
.regulation-check {
  margin-top: 30px;
  padding-top: 22px;
  border-top: 1px solid var(--paper-deep);
  width: 100%;
  max-width: 420px;
}

.regulation-question {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 14px;
}

.regulation-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.regulation-button {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--ink);
  background: var(--white);
  color: var(--ink);
  border-radius: 4px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.regulation-button:hover:not(:disabled) { background: var(--paper-deep); transform: translateY(-1px); }
.regulation-button:disabled { opacity: 0.5; cursor: not-allowed; }
.regulation-button:focus-visible { outline: 2px solid var(--accent-clinical); outline-offset: 2px; }

.regulation-button-upgrade {
  border-color: var(--accent-signature);
  color: var(--accent-signature);
}
.regulation-button-upgrade:hover:not(:disabled) { background: var(--accent-signature-soft); }

.regulation-ack {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-clinical);
  margin: 14px 0 0;
}

/* ---------- Footer ---------- */
.footnote {
  margin-top: auto;
  padding-top: 32px;
  border-top: 1px solid var(--paper-deep);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-soft);
  text-align: center;
}
.footnote a { color: var(--accent-clinical); }

@media (max-width: 420px) {
  .wedge-label-middle, .wedge-label-leaf { display: none; }
}

/* ---------- About page ---------- */
.about-content {
  text-align: left;
  max-width: 600px;
  margin: 0 auto;
}

.about-lede {
  font-size: 18px;
  line-height: 1.6;
  margin: 0 0 16px;
}

.about-aka {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink-soft);
  background: var(--white);
  border: 1px solid var(--paper-deep);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 0 0 32px;
}
.about-aka strong { color: var(--ink); }

.about-content h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 32px 0 12px;
  padding-top: 16px;
  border-top: 1px solid var(--paper-deep);
}
.about-content h2:first-of-type { border-top: none; padding-top: 0; }

.about-content p,
.about-content li {
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
}

.about-content ol,
.about-content ul {
  margin: 0 0 16px;
  padding-left: 22px;
}
.about-content li { margin-bottom: 10px; }
.about-content li ul { margin-top: 8px; margin-bottom: 0; }

.about-content a { color: var(--accent-clinical); }

.about-readme-link {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--paper-deep);
}

/* ---------- Share button ---------- */
.share-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 0 2px;
  color: var(--ink-soft);
  vertical-align: middle;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s ease, transform 0.1s ease;
}
.share-btn:hover:not(:disabled) {
  color: var(--accent-clinical);
  transform: scale(1.15);
}
.share-btn:disabled { opacity: 0.5; cursor: default; }
.share-btn:focus-visible { outline: 2px solid var(--accent-clinical); outline-offset: 2px; border-radius: 2px; }
