/* ==========================================================================
   Chris the rainbow lover, main stylesheet

   Concept: a loud, cheerful comic-book fan page that someone has proofread.

   Palette (contrast checked against WCAG AA):
   --bg        #FFF8EC  cream page background. Ink on cream is about 16:1.
   --surface   #FFFFFF  quiz and log cards.
   --ink       #1F1A2E  text, the dark band and focus rings. About 16:1 on cream.
   --ink-soft  #4B4560  secondary text. About 8.6:1 on cream.
   --ginger    #C2410C  ginger accents and large headings. About 5.2:1 on white.
   --action    #5B21B6  buttons and links. About 9:1 with white text.
   --sun       #FFD60A  highlights on the dark band. About 12:1 with ink.
   Rainbow colours are decoration only. Body text never sits on them.

   Type: Lilita One for headings (chunky, a bit silly). Figtree for reading,
   at 400 and 700 only. Sizes are fluid with clamp().

   Motif: the rainbow arc. Six bands in order, used as the hero halo and
   as the stripe rules between sections.
   ========================================================================== */

:root {
  --bg: #FFF8EC;
  --surface: #FFFFFF;
  --sand: #F1E7D3;
  --ink: #1F1A2E;
  --ink-soft: #4B4560;
  --ginger: #C2410C;
  --action: #5B21B6;
  --action-hover: #4C1D95;
  --sun: #FFD60A;
  --sun-hover: #FFE14D;
  --panel-dark: #2B2540;

  --red: #E63946;
  --orange: #F77F00;
  --yellow: #FFD60A;
  --green: #2A9D8F;
  --blue: #3A86FF;
  --violet: #8338EC;

  --font-display: "Lilita One", "Arial Rounded MT Bold", Arial, sans-serif;
  --font-text: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --step--1: clamp(0.875rem, 0.85rem + 0.12vw, 0.95rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem);
  --step-2: clamp(1.75rem, 1.3rem + 2vw, 2.5rem);
  --step-3: clamp(2.25rem, 1.5rem + 3.2vw, 3.5rem);

  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 32px;
  --s5: 40px;
  --s6: 48px;
  --s8: 64px;
  --s10: 80px;

  --radius: 12px;
  --gutter: 1rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.6;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.1;
  margin: 0 0 var(--s2);
  text-wrap: balance;
}

h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p {
  margin: 0 0 var(--s2);
  max-width: 65ch;
}

a {
  color: var(--action);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--action-hover);
}

:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.wrap {
  width: min(100% - 2 * var(--gutter), 70rem);
  margin-inline: auto;
}

.ginger {
  color: var(--ginger);
}

/* Skip link */
.skip-link {
  position: absolute;
  left: var(--s2);
  top: -4rem;
  z-index: 30;
  background: var(--ink);
  color: var(--bg);
  padding: var(--s1) var(--s2);
  border-radius: var(--radius);
  font-weight: 700;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--s2);
}

/* Header */
.site-header {
  padding-block: var(--s2);
  border-bottom: 1px solid rgba(31, 26, 46, 0.15);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
}

.brand {
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--ink);
  text-decoration: none;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-list a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  padding-block: 4px;
}

.nav-list a:hover {
  color: var(--action);
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: var(--s2) var(--s3);
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: 700 var(--step-0) / 1.2 var(--font-text);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.btn-primary {
  background: var(--action);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--action-hover);
  color: #FFFFFF;
}

.btn-primary:active {
  transform: translateY(2px);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn-ghost:hover {
  background: var(--ink);
  color: var(--bg);
}

.btn-ghost:active {
  transform: translateY(2px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Hero */
.hero {
  padding-block: var(--s6) var(--s8);
}

.hero-grid {
  display: grid;
  gap: var(--s6);
  align-items: center;
}

.lede {
  font-size: var(--step-1);
  color: var(--ink-soft);
  max-width: 36ch;
}

.actions,
.form-actions,
.sight-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.actions {
  margin-top: var(--s4);
}

.hero-art {
  position: relative;
  display: grid;
  justify-items: center;
  padding-top: var(--s4);
}

.arc-art {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 28rem);
  height: auto;
  z-index: 0;
}

.arc-art path {
  fill: none;
  stroke-width: 12;
  stroke-linecap: butt;
}

.chris {
  position: relative;
  z-index: 1;
  width: min(72vw, 20rem);
  margin-top: var(--s3);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
}

.chris:hover .chris-svg {
  transform: rotate(-2deg);
}

.chris-svg {
  width: 100%;
  transform-origin: 50% 90%;
  transition: transform 0.2s;
}

.chris.wobble .chris-svg {
  animation: wobble 0.6s ease;
}

@keyframes wobble {
  0% { transform: rotate(0deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(6deg); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(2deg); }
  100% { transform: rotate(0deg); }
}

/* Chris expressions, switched by the poke button */
.chris-svg .wink,
.chris-svg .m-shock {
  display: none;
}

.chris-svg[data-mood="wink"] .wink {
  display: inline;
}

.chris-svg[data-mood="wink"] .eye-r {
  display: none;
}

.chris-svg[data-mood="shock"] .m-shock {
  display: inline;
}

.chris-svg[data-mood="shock"] .m-smile {
  display: none;
}

.bubble {
  position: relative;
  z-index: 1;
  max-width: 20rem;
  min-height: 3.2em;
  margin: var(--s3) 0 0;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-weight: 700;
  text-align: center;
}

/* Stripe rule, the rainbow motif as a thin band */
.stripes {
  height: 12px;
  background: linear-gradient(
    90deg,
    var(--red) 0 16.66%,
    var(--orange) 16.66% 33.33%,
    var(--yellow) 33.33% 50%,
    var(--green) 50% 66.66%,
    var(--blue) 66.66% 83.33%,
    var(--violet) 83.33% 100%
  );
}

/* About and rules */
.about {
  padding-block: var(--s10);
}

.split {
  display: grid;
  gap: var(--s6);
}

.rules {
  border-bottom: 2px solid var(--ink);
}

.rules h3 {
  margin-bottom: var(--s2);
}

.rules details {
  border-top: 2px solid var(--ink);
  padding-block: var(--s2);
}

.rules summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  font-size: var(--step-0);
}

.rules summary::-webkit-details-marker {
  display: none;
}

.rules summary::after {
  content: "+";
  flex: none;
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1;
  color: var(--ginger);
}

.rules details[open] summary::after {
  content: "\2013";
}

.rules summary:hover {
  color: var(--action);
}

.rules details p {
  margin: var(--s2) 0 0;
}

/* Dark band: Rainbow-o-meter */
.band-dark {
  background: var(--ink);
  color: var(--bg);
  padding-block: var(--s10);
}

.band-dark h2 {
  color: var(--bg);
}

.band-intro {
  color: #E9E4F2;
}

.meter-card {
  max-width: 44rem;
  margin-top: var(--s4);
  padding: var(--s4);
  background: var(--panel-dark);
  border-radius: var(--radius);
}

.meter-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s2);
  font-weight: 700;
}

output {
  font-family: var(--font-display);
  font-size: var(--step-2);
  color: var(--sun);
}

input[type="range"] {
  width: 100%;
  min-height: 44px;
  margin: var(--s3) 0 var(--s2);
  accent-color: var(--sun);
}

.meter-bar {
  height: 24px;
  background: #3A3352;
  border-radius: var(--radius);
  overflow: hidden;
  --level: 50%;
}

.meter-fill {
  display: block;
  height: 100%;
  width: var(--level);
  background: linear-gradient(
    90deg,
    var(--red),
    var(--orange),
    var(--yellow),
    var(--green),
    var(--blue),
    var(--violet)
  );
  transition: width 0.3s ease;
}

.verdict {
  min-height: 2.4em;
  margin: var(--s3) 0 0;
  max-width: none;
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--bg);
}

/* Quiz */
.quiz {
  padding-block: var(--s10);
  background: var(--surface);
}

.quiz-grid {
  display: grid;
  gap: var(--s6);
}

.quiz-form {
  display: grid;
  gap: var(--s4);
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
  margin-bottom: var(--s2);
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.2;
}

.choice {
  display: flex;
  align-items: center;
  gap: var(--s2);
  min-height: 48px;
  margin-bottom: var(--s1);
  padding: var(--s2);
  background: var(--bg);
  border: 2px solid rgba(31, 26, 46, 0.25);
  border-radius: var(--radius);
  cursor: pointer;
}

.choice:hover {
  border-color: var(--ink);
}

.choice:has(input:checked) {
  border-color: var(--action);
  box-shadow: inset 6px 0 0 var(--action);
}

.choice:focus-within {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.choice input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--action);
}

.quiz-result:not(:empty) {
  margin-top: var(--s4);
  padding: var(--s4);
  background: var(--bg);
  border-left: 8px solid var(--ink);
  border-radius: var(--radius);
}

.quiz-result[data-tone="red"]:not(:empty) { border-left-color: var(--red); }
.quiz-result[data-tone="yellow"]:not(:empty) { border-left-color: var(--yellow); }
.quiz-result[data-tone="blue"]:not(:empty) { border-left-color: var(--blue); }

/* Sightings */
.sightings {
  padding-block: var(--s10) var(--s8);
}

.sight-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s2) var(--s4);
  margin-bottom: var(--s4);
}

.count {
  max-width: none;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--step-1);
}

.count-num {
  display: block;
  font-size: var(--step-3);
  line-height: 1;
  color: var(--ginger);
}

.empty {
  margin-top: var(--s4);
  color: var(--ink-soft);
}

.log {
  display: grid;
  gap: var(--s1);
  margin: var(--s4) 0 0;
  padding: 0;
  list-style: none;
  counter-reset: spot;
}

.log li {
  counter-increment: spot;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s2);
  align-items: baseline;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  border-left: 6px solid var(--red);
  border-radius: var(--radius);
}

.log li::before {
  content: "#" counter(spot);
  font-family: var(--font-display);
  color: var(--ginger);
}

.log li:nth-child(6n+2) { border-left-color: var(--orange); }
.log li:nth-child(6n+3) { border-left-color: var(--yellow); }
.log li:nth-child(6n+4) { border-left-color: var(--green); }
.log li:nth-child(6n+5) { border-left-color: var(--blue); }
.log li:nth-child(6n+6) { border-left-color: var(--violet); }

/* Footer */
.site-footer {
  background: var(--sand);
  padding-top: var(--s6);
}

.footer-grid {
  display: grid;
  gap: var(--s4);
  padding-bottom: var(--s6);
}

.foot-brand,
.foot-label {
  font-family: var(--font-display);
  font-size: var(--step-1);
  margin-bottom: var(--s1);
}

.legal {
  padding-block: var(--s3);
  border-top: 1px solid rgba(31, 26, 46, 0.2);
  font-size: var(--step--1);
  color: var(--ink-soft);
}

/* Confetti, added by the script */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -16px;
  width: 10px;
  height: 14px;
  background: var(--c);
  border-radius: 2px;
  animation: fall var(--d, 2s) ease-in forwards;
}

@keyframes fall {
  to {
    transform: translate(var(--x, 0px), 110vh) rotate(540deg);
  }
}

/* Wider screens */
@media (min-width: 48rem) {
  .footer-grid {
    grid-template-columns: 2fr 1fr 1fr;
  }
}

@media (min-width: 60rem) {
  .hero-grid {
    grid-template-columns: 1.1fr 0.9fr;
    gap: var(--s8);
  }

  .split {
    grid-template-columns: 5fr 6fr;
    gap: var(--s8);
    align-items: start;
  }

  .quiz-grid {
    grid-template-columns: 4fr 7fr;
    gap: var(--s8);
    align-items: start;
  }
}

/* Reduced motion: no wobble, no falling confetti, no smooth scrolling */
@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;
  }

  .chris.wobble .chris-svg {
    animation: none;
  }

  .confetti {
    display: none;
  }
}
