/* -------------------------------------------------------------------------
   /earn — rewards dashboard.
   Loads after styles.css and consumes its tokens. Manga-panel layout: thick
   ink gutters, screentone fills, her dialogue in a bubble that breaks the
   panel border. Mobile first, min-width queries only.
   ---------------------------------------------------------------------- */

:root {
  /* Hex fallbacks first, oklch (authoritative) second. */
  --panel: #fefbf3;
  --ink-soft: #4e4640;
  --up: #1d7a37;
  --down: #b32d1f;

  --panel: oklch(0.985 0.006 88);
  --ink-soft: oklch(0.4 0.015 55);
  --up: oklch(0.52 0.15 148);
  --down: oklch(0.5 0.19 27);

  --gutter: 4px;
}

.earn {
  padding: 1.5rem 1rem 3rem;
}

@media (min-width: 48rem) {
  .earn {
    padding: 2.5rem 1.5rem 4rem;
  }
}

.earn__inner {
  max-width: 82rem;
  margin: 0 auto;
}

.earn__lede {
  margin-bottom: 1.25rem;
}

.earn__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5.5vw, 3rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.earn__title span {
  color: var(--primary);
}

.earn__sub {
  margin-top: 0.6rem;
  max-width: 46ch;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---- the sheet: panels divided by ink gutters ---- */

.sheet {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--gutter);
  background: var(--foreground);
  border: var(--gutter) solid var(--foreground);
}

@media (min-width: 48rem) {
  .sheet {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 64rem) {
  .sheet {
    grid-template-columns: repeat(10, 1fr);
  }
}

.panel {
  position: relative;
  min-width: 0;
  background: var(--panel);
  padding: 1rem 1.1rem;
}

.panel--tone::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--foreground) 1.1px, transparent 1.2px);
  background-size: 7px 7px;
  opacity: 0.07;
}

.panel > * {
  position: relative;
}

/* ---- shared type ---- */

.panel__eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.55rem;
  color: var(--ink-soft);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.panel__voice {
  margin-bottom: 0.8rem;
  font-style: italic;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.3;
  text-wrap: balance;
}

.fig {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 0.95;
}

.fig--xl {
  font-size: clamp(2rem, 6vw, 3.1rem);
}

.fig--sub {
  margin-top: 0.45rem;
  color: var(--ink-soft);
  font-size: 1.25rem;
}

.panel__note {
  margin-top: 0.6rem;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.5;
}

.panel__meta {
  display: flex;
  gap: 0.35rem 1.1rem;
  flex-wrap: wrap;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.rule {
  height: 3px;
  margin: 0.85rem 0 0.7rem;
  background: var(--foreground);
}

.rainbow {
  display: flex;
  height: 6px;
  margin: 0.9rem 0 0.7rem;
}

.rainbow i {
  flex: 1;
}

/* ---- stat strip ---- */

.stat {
  grid-column: span 1;
  padding: 0.8rem 0.9rem;
}

/* Five tiles never fill a 2- or 4-column row, so the last one takes the
   remainder. Without this the ink sheet shows through as an empty cell. */
.stat:last-of-type {
  grid-column: 1 / -1;
}

@media (min-width: 48rem) {
  .stat:last-of-type {
    grid-column: span 4;
  }
}

@media (min-width: 64rem) {
  .stat,
  .stat:last-of-type {
    grid-column: span 2;
  }
}

.stat__k {
  color: var(--ink-soft);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.stat__v {
  margin-top: 0.3rem;
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.4vw, 1.4rem);
  font-variant-numeric: tabular-nums;
}

.delta {
  margin-left: 0.35rem;
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 800;
}

.delta--up { color: var(--up); }
.delta--dn { color: var(--down); }

/* ---- panel spans ---- */

.panel--paid,
.panel--drop,
.panel--how,
.panel--calc,
.panel--facts,
.panel--share {
  grid-column: 1 / -1;
}

.panel--her {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: visible;
}

@media (min-width: 64rem) {
  .panel--paid { grid-column: span 4; }
  .panel--drop { grid-column: span 3; }
  .panel--her { grid-column: span 3; grid-row: span 2; z-index: 3; }
  .panel--how { grid-column: span 7; }
  .panel--calc { grid-column: span 6; }
  .panel--facts { grid-column: span 4; }
  .panel--share { grid-column: 1 / -1; }
}

/* ---- next drop ring ---- */

.drop__row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.ring text {
  font-family: var(--font-display);
  fill: var(--foreground);
}

/* ---- her panel ---- */

.her__frame {
  position: relative;
  flex: 1;
  min-height: 20rem;
  overflow: hidden;
  background: var(--panel);
}

.her__frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(var(--primary) 1.4px, transparent 1.5px);
  background-size: 9px 9px;
  opacity: 0.16;
}

/* styles.css sets img { display: block }, an author rule that overrides the
   user-agent [hidden] rule, so the attribute alone will not hide these. */
.her__frame img[hidden] {
  display: none;
}

.her__frame img {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  height: 100%;
  width: auto;
  max-width: none;
  object-fit: contain;
  object-position: bottom;
}

.bubble {
  position: absolute;
  z-index: 6;
  top: 1.1rem;
  left: 0.8rem;
  max-width: 13rem;
  padding: 0.7rem 0.9rem;
  background: var(--panel);
  border: 3px solid var(--foreground);
  border-radius: 1.35rem;
  box-shadow: 5px 5px 0 var(--foreground);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.3;
}

@media (min-width: 64rem) {
  .bubble {
    left: -2rem;
  }
}

.bubble::after,
.bubble::before {
  content: "";
  position: absolute;
  border-style: solid;
  border-bottom: 0;
}

.bubble::after {
  right: 1.6rem;
  bottom: -1.05rem;
  border-width: 9px;
  border-color: var(--foreground) transparent transparent;
}

.bubble::before {
  right: 1.75rem;
  bottom: -0.68rem;
  z-index: 1;
  border-width: 7px;
  border-color: var(--panel) transparent transparent;
}

.moods {
  padding: 0.75rem 0.9rem;
  border-top: var(--gutter) solid var(--foreground);
  background: var(--panel);
}

.moods__list {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.chip {
  padding: 0.25rem 0.45rem;
  border: 2px solid var(--foreground);
  background: var(--panel);
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--foreground);
  color: var(--gold);
}

/* ---- how I pay ---- */

.steps {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 40rem) {
  .steps {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 64rem) {
  .steps {
    grid-template-columns: repeat(4, 1fr);
  }
}

.step__n {
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-bottom: 0.5rem;
  background: var(--foreground);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.8rem;
}

.step__h {
  margin-bottom: 0.35rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.step__p {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.5;
}

/* ---- calculator ---- */

.field {
  margin-bottom: 0.9rem;
}

.field__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
  color: var(--ink-soft);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field__label b {
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0;
}

.field input[type="range"] {
  width: 100%;
  height: 1.4rem;
  accent-color: var(--primary);
}

.field input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 3px solid var(--foreground);
  border-radius: 0;
  background: var(--panel);
  color: var(--foreground);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.presets {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-top: 0.45rem;
}

.presets button {
  padding: 0.3rem 0.65rem;
  border: 2px solid var(--foreground);
  background: var(--panel);
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
}

.presets button:hover {
  background: var(--gold);
}

.payout {
  padding: 0.8rem 0.95rem;
  border: 3px solid var(--foreground);
  background: var(--gold);
  box-shadow: 5px 5px 0 var(--foreground);
}

.payout__k {
  font-size: 0.63rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.payout__v {
  margin: 0.2rem 0 0.1rem;
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 5vw, 2.5rem);
  font-variant-numeric: tabular-nums;
}

.payout__w {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: oklch(0.35 0.06 70);
}

.breakdown {
  margin-top: 0.85rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.breakdown div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.32rem 0;
  border-bottom: 1px dashed oklch(0.78 0.02 60);
}

.breakdown div:last-child {
  border-bottom: 0;
  font-weight: 800;
}

.breakdown span:first-child {
  color: var(--ink-soft);
}

.breakdown span:last-child {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
}

/* ---- facts ---- */

.facts {
  font-size: 0.82rem;
  font-weight: 600;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid oklch(0.88 0.01 70);
}

.facts div:last-child {
  border-bottom: 0;
}

.facts span:first-child {
  color: var(--ink-soft);
}

.facts span:last-child {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
}

/* ---- live / error state ---- */

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-soft);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.live::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--up);
}

.live[data-state="stale"]::before {
  background: var(--down);
}

.is-loading {
  opacity: 0.45;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* -------------------------------------------------------------------------
   Loading screen — "GUTTER SNAP".
   A three-panel manga page assembles in 175ms and then holds still. It covers
   the API fetch only: it dismisses the moment data lands, and is hard-capped
   at 2.5s by the script. Dismissal uses a class, NOT the [hidden] attribute,
   because .ld sets display and an author rule beats the UA [hidden] rule.
   ---------------------------------------------------------------------- */

.ld {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: var(--background);
}

.ld::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--foreground) 1.1px, transparent 1.2px);
  background-size: 7px 7px;
  opacity: 0.06;
}

.ld--out {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 180ms ease,
    visibility 0s linear 180ms;
}

.ld__page {
  position: relative;
  width: min(92vw, 26rem);
  background: var(--foreground);
  border: 4px solid var(--foreground);
  box-shadow: 8px 8px 0 var(--foreground);
}

/* The row owns the aspect ratio. Putting it on each panel instead lets the
   narrower tiara panel come up short, exposing the black page beneath it. */
.ld__panels {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 4px;
  aspect-ratio: 2.45 / 1;
}

.ld__panel {
  overflow: hidden;
  background: var(--panel);
  height: 100%;
}

.ld__panel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ld__say {
  margin-top: 4px;
  padding: 0.85rem 1rem;
  background: var(--panel);
  font-style: italic;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.25;
}

.ld__say b {
  display: block;
  margin-top: 0.3rem;
  font-family: var(--font-display);
  font-style: normal;
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

@keyframes ld-eye {
  from { transform: translateX(-12px); }
  to   { transform: translateX(0); }
}

@keyframes ld-tiara {
  from { transform: translateY(-10px); }
  to   { transform: translateY(0); }
}

@keyframes ld-say {
  from { transform: scale(0.94); }
  to   { transform: scale(1); }
}

/* The snap lives on the wrapper and the drift on the image, so the two
   transforms never fight over the same element. */
.ld__shot {
  display: block;
  width: 100%;
  height: 100%;
}

.ld__panel--eye .ld__shot {
  animation: ld-eye 110ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.ld__panel--tiara .ld__shot {
  animation: ld-tiara 140ms 35ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Once assembled the panels keep breathing, slowly and in opposition, so a
   held page reads as alive rather than frozen. Not a spinner. */
@keyframes ld-drift-a {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to   { transform: scale(1.10) translate3d(-2%, -1%, 0); }
}

@keyframes ld-drift-b {
  from { transform: scale(1.09) translate3d(0, 0, 0); }
  to   { transform: scale(1.01) translate3d(1.5%, 1%, 0); }
}

@keyframes ld-shine {
  0%        { transform: translateX(-130%) skewX(-14deg); }
  55%, 100% { transform: translateX(130%) skewX(-14deg); }
}

@keyframes ld-dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

.ld__panel--eye img {
  animation: ld-drift-a 7s ease-in-out infinite alternate;
}

.ld__panel--tiara img {
  animation: ld-drift-b 7s ease-in-out infinite alternate;
}

.ld__panel--tiara::after {
  content: "";
  position: absolute;
  inset: -10%;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    100deg,
    transparent 40%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 60%
  );
  animation: ld-shine 2.8s 600ms ease-in-out infinite;
}

.ld__say b::after {
  content: "";
  animation: ld-dots 1.4s steps(1, end) infinite;
}

.ld__say {
  animation: ld-say 100ms ease-out both;
}

/* ---- sound toggle ---- */

.snd {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 210;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.7rem;
  border: 3px solid var(--foreground);
  background: var(--panel);
  color: var(--foreground);
  box-shadow: 4px 4px 0 var(--foreground);
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}

.snd:hover {
  background: var(--gold);
}

.snd__note {
  font-size: 0.95rem;
  line-height: 1;
}

.snd[aria-pressed="true"] {
  background: var(--foreground);
  color: var(--gold);
}

@media (prefers-reduced-motion: reduce) {
  .ld__panel--eye img,
  .ld__panel--tiara img,
  .ld__panel--eye .ld__shot,
  .ld__panel--tiara .ld__shot,
  .ld__panel--tiara::after,
  .ld__say b::after,
  .ld__say {
    animation: none;
  }

  .ld__panel--tiara::after {
    display: none;
  }

  .ld--out {
    transition: none;
  }
}


/* -------------------------------------------------------------------------
   Take it with you — scan code and print
   ---------------------------------------------------------------------- */

.share {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}

.share__qr {
  flex: 0 0 auto;
  padding: 0.5rem;
  border: 3px solid var(--foreground);
  background: var(--panel);
  box-shadow: 5px 5px 0 var(--foreground);
}

.share__qr canvas {
  display: block;
  width: 8.5rem;
  height: 8.5rem;
}

.share__copy {
  flex: 1 1 16rem;
  min-width: 0;
}

.pbtn {
  margin-top: 0.7rem;
  padding: 0.6rem 1.1rem;
  border: 3px solid var(--foreground);
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 4px 4px 0 var(--foreground);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.pbtn:hover {
  background: var(--gold);
}

.pbtn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--foreground);
}

.printonly {
  display: none;
}

/* -------------------------------------------------------------------------
   Print / save as PDF.
   Strip the controls and let the panels break cleanly. Colour is forced on:
   without print-color-adjust the ink gutters drop out and the manga grid
   collapses into unseparated blocks.
   ---------------------------------------------------------------------- */

@media print {
  @page {
    margin: 12mm;
  }

  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    padding: 0;
    background: #fff;
  }

  .header,
  .footer,
  .snd,
  .ld,
  .presets,
  .moods,
  .pbtn,
  .field input[type="range"],
  .earn__sub {
    display: none !important;
  }

  .printonly {
    display: block;
    margin-top: 0.6rem;
    color: var(--ink-soft);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .earn {
    padding: 0;
  }

  .sheet {
    gap: 3px;
    border-width: 3px;
  }

  .panel {
    break-inside: avoid;
  }

  .panel--her {
    grid-row: auto;
  }

  .her__frame {
    min-height: 14rem;
  }

  .bubble {
    box-shadow: none;
  }

  .field input[type="text"] {
    border-width: 2px;
  }

  .share__qr canvas {
    width: 10rem;
    height: 10rem;
  }

  a[href]::after {
    content: "";
  }
}

.pbtns {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.pbtn--alt {
  background: var(--panel);
  color: var(--foreground);
}

.pbtn--alt:hover {
  background: var(--gold);
}
