/* Salarydle. See DESIGN.md for the reasoning behind these tokens.
   Everything sits directly on the cobalt "desk": no boxes, structure comes from rules and spacing. */

/* Rokkitt (SIL Open Font License, see fonts/OFL.txt), self-hosted: no request to Google.
   Used for the wordmark wherever Rockwell isn't installed (Android, Linux, many PCs). */
@font-face {
  font-family: "Rokkitt";
  src: url("../fonts/Rokkitt-VariableFont_wght.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}


:root {
  --desk: #2340d8;
  --text: #ffffff;
  --text-quiet: rgb(255 255 255 / 0.7);
  --rule: rgb(255 255 255 / 0.32);
  --rule-strong: #ffffff;
  --mark: #ffd21f;
  --on-mark: #0a0f2c;

  /* dialogs only */
  --paper: #ffffff;
  --ink: #0a0f2c;
  --quiet: #5b6283;
  --line: #d7dbea;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r: 4px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #080c26;
    --text: #eef0ff;
    --text-quiet: rgb(238 240 255 / 0.62);
    --rule: rgb(238 240 255 / 0.2);
    --rule-strong: rgb(238 240 255 / 0.85);
    --paper: #151c48;
    --ink: #eef0ff;
    --quiet: #a3aacb;
    --line: #2f3970;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--desk);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 3px; }
.small { font-size: 0.875rem; }
.quiet { color: var(--quiet); }
.center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 16px 8px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: start;
  gap: 8px;
}
.brand { text-align: center; min-width: 0; }
.wordmark {
  position: relative;
  display: inline-block;
  /* Rockwell where installed; Rokkitt (free, similar slab) is the self-hosted fallback to add */
  font-family: Rockwell, "Rockwell Nova", "Rokkitt", "Roboto Slab", Georgia, serif;
  font-size: clamp(2.6rem, 11vw, 3.4rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}
/* the yellow smile arc under the word */
.wordmark::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -0.44em;
  height: 0.36em;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 20' preserveAspectRatio='none'%3E%3Cpath d='M4 3 Q 100 22 196 3' fill='none' stroke='%23FFD21F' stroke-width='4' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
.tagline { margin: 30px 0 0; color: var(--text-quiet); font-weight: 600; font-size: 0.95rem; }
.tool-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 850;
  font-size: 1.2rem;
  opacity: 0.85;
}
.tool-btn:hover { opacity: 1; }
/* help: a ring around the "?", so it reads as a button and not like the hidden-salary "?" */
#btn-help {
  width: 34px;
  height: 34px;
  border: 2px solid currentColor;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
}
#btn-help:hover { color: var(--mark); }

/* ---------- Layout ---------- */
.wrap {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ---------- Profile (receipt lines, no box) ---------- */
.slip-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--rule-strong);
  font-weight: 800;
}
#puzzle-no { font-weight: 600; color: var(--text-quiet); }

.clues { margin: 4px 0 0; }
.clue {
  display: flex;
  align-items: flex-start;
  padding: 7px 0;
}
.clue dt {
  flex: 1;
  display: flex;
  align-items: baseline;
  color: var(--text-quiet);
  white-space: nowrap;
}
.clue dt::after {           /* dotted leader, like a receipt */
  content: "";
  flex: 1;
  min-width: 16px;
  margin: 0 10px;
  border-bottom: 2px dotted var(--rule);
  align-self: center;
  transform: translateY(3px);
}
.clue dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
  max-width: 72%;
}

/* hidden values: dimmed row, the value spot says when it unlocks */
.clue.locked dt { opacity: 0.6; }
.clue dd.pending { font-weight: 500; font-size: 0.85rem; color: var(--text-quiet); }
/* fixed line box: a revealed value and "after guess N" take exactly the same height,
   so nothing below (the input) moves when a clue appears */
.clue dt, .clue dd { line-height: 24px; }
.answer-pending { color: var(--text-quiet); }

/* reveal: the value comes into focus */
.reveal { display: inline-block; }
.reveal.fresh { animation: focus-in 0.7s ease-out; }
@keyframes focus-in {
  from { filter: blur(8px); opacity: 0.4; }
  to   { filter: blur(0); opacity: 1; }
}

.slip-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 2px solid var(--rule-strong);
  font-weight: 700;
}
.answer { font-size: 1.5rem; font-weight: 850; color: var(--mark); }

/* ---------- Controls ---------- */
.controls { display: flex; flex-direction: column; gap: 10px; }
.controls[hidden] { display: none; }
.controls-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.hint { margin: 0; color: var(--text-quiet); font-weight: 600; white-space: nowrap; }

.currency-toggle { display: flex; gap: 14px; flex-shrink: 0; }
.currency-toggle { transition: opacity 0.3s ease; }
.currency-toggle.is-off { visibility: hidden; opacity: 0; }
.seg {
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 2px 0;
  background: transparent;
  color: var(--text-quiet);
  font-size: 0.9rem;
  font-weight: 700;
}
.seg[aria-checked="true"] { color: var(--text); border-bottom-color: var(--text); }

.amount-row { display: flex; align-items: flex-end; gap: 16px; }
.amount-field {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  border-bottom: 3px solid var(--rule-strong);
}
.amount-field:focus-within { border-bottom-color: var(--mark); }
.amount-prefix { font-size: 2rem; font-weight: 800; color: var(--text-quiet); }
#amount {
  flex: 1;
  min-width: 0;
  padding: 4px 0 6px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 2rem;
  font-weight: 850;
  letter-spacing: -0.02em;
  outline: none;
}
#amount::placeholder { color: var(--text-quiet); opacity: 0.6; }

.btn-mark {
  border: 0;
  border-radius: var(--r);
  padding: 12px 24px;
  background: var(--mark);
  color: var(--on-mark);
  font-weight: 850;
}
.btn-mark:hover { filter: brightness(1.05); }
.btn-mark:active { transform: translateY(1px); }
.btn-mark.wide { width: 100%; margin-top: 4px; }

.form-error { margin: 0; font-weight: 700; color: var(--mark); font-size: 0.9rem; }
.form-error:empty { display: none; }


/* ---------- Done panel ---------- */
.done-panel { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.done-panel[hidden] { display: none; }
.done-panel p { margin: 0; font-weight: 800; font-size: 1.25rem; }
.done-panel .small { font-weight: 500; font-size: 0.875rem; color: var(--text-quiet); }

/* ---------- Direction triangles ---------- */
.tri { display: inline-block; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; }
.tri.up { border-bottom: 8px solid currentColor; }
.tri.down { border-top: 8px solid currentColor; }

/* ---------- Guess lines ---------- */
.guesses {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--rule-strong);
}
.guess {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 6px 0;
  border-bottom: 1px solid var(--rule);
}
.guess.empty { color: var(--text-quiet); border-bottom-style: dotted; }
.guess.hit { color: var(--mark); }
.guess.new { animation: slide-in 0.25s ease-out; }
@keyframes slide-in { from { transform: translateY(-4px); opacity: 0; } }
.guess-no { font-size: 0.85rem; font-weight: 700; opacity: 0.6; }
.guess-amount { font-weight: 800; font-size: 1.1rem; }
.guess-verdict { display: flex; align-items: center; gap: 6px; font-weight: 700; }

/* ---------- Ad slot ---------- */
.ad-slot {
  min-height: 90px;
  padding-top: 6px;
  border-top: 1px solid var(--rule);
  color: var(--text-quiet);
  font-size: 0.75rem;
}

/* ---------- Footer ---------- */
.site-footer {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 32px;
  font-size: 0.875rem;
  color: var(--text-quiet);
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.site-footer a { color: var(--text); text-underline-offset: 3px; }
.site-footer p { margin: 10px 0 0; }

/* ---------- Dialogs ---------- */
dialog {
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 18px 22px 22px;
  border: 0;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: rgb(6 10 40 / 0.6); }
dialog p { margin: 0 0 12px; }
dialog h3 { margin: 18px 0 8px; font-size: 1rem; }
.dlg-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--ink);
}
.dlg-head h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.close-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: var(--r);
  background: transparent;
  color: var(--ink);
}
.close-btn:hover { background: var(--line); }

.legend { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.stat-grid div { display: flex; flex-direction: column-reverse; }
.stat-grid dd { margin: 0; font-size: 1.8rem; font-weight: 850; line-height: 1.1; }
.stat-grid dt { font-size: 0.8rem; color: var(--quiet); }

.dist { display: grid; gap: 4px; margin-bottom: 14px; }
.dist-row { display: grid; grid-template-columns: 1rem 1fr; gap: 8px; align-items: center; font-size: 0.85rem; font-weight: 700; }
.dist-bar {
  min-width: 1.75rem;
  padding: 1px 8px;
  text-align: right;
  background: var(--ink);
  color: var(--paper);
  border-radius: 1px;
}
.dist-bar.current { background: var(--mark); color: var(--on-mark); }

.result-signals { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 14px; }
.result-signals span { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 0.9rem; }
.result-signals .is-hit { padding: 0 6px; background: var(--mark); color: var(--on-mark); border-radius: 2px; }
.result-salary { display: flex; flex-direction: column; margin: 0 0 12px; }
.result-amount { font-size: 2.2rem; font-weight: 850; letter-spacing: -0.03em; line-height: 1.1; }
.result-profile { font-size: 0.95rem; }
.result-context { margin: 0 0 14px; padding-left: 1.1em; font-size: 0.9rem; color: var(--quiet); }
.result-context li + li { margin-top: 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: var(--r);
  background: var(--mark);
  color: var(--on-mark);
  font-weight: 800;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 10;
}
.toast.show { opacity: 1; }

@media (max-width: 400px) {
  .guess { gap: 10px; grid-template-columns: 1.25rem 1fr auto; }
  .amount-prefix, #amount { font-size: 1.7rem; }
  .btn-mark { padding: 12px 18px; }
}

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

/* ==========================================================================
   Centered composition with varying widths (symmetric, not one rigid column)
   Header full width → profile 440 → input 360 → guesses 420 → footer centered
   ========================================================================== */
.wrap { align-items: center; }
.wrap > * { width: 100%; }

/* Stepped, mirror-symmetric silhouette: strong rules stick out wider than the rows
   they frame, the input is the narrowest point, the ad is the widest.
     wordmark ───── big
     tagline        narrow
     ├──── profile rule ────┤ 500
        rows (inset)          420
     ├──── salary rule ─────┤ 500
          hint                narrow
          input               320
     ├──── guesses rule ────┤ 500
        guess rows (inset)    420                                              */
:root { --k: 1px; }                 /* scale for the per-row offsets below */
@media (max-width: 480px) { :root { --k: 0.38px; } .clue dd { max-width: 80%; } }

.slip      { max-width: 500px; }
.controls  { max-width: 320px; }
.done-panel{ max-width: 340px; }
.guesses   { max-width: 470px; }
.ad-slot   { max-width: 528px; }

/* Every row gets its own width, mirrored on both sides, so there is no straight
   edge anywhere on the left or right. Fixed values (not Math.random) so nothing
   jumps around between visits. */
.slip-head  { margin-inline: calc(0 * var(--k)); }
.slip-total { margin-inline: calc(34 * var(--k)); }
.clue { margin-inline: calc(var(--o, 0) * var(--k)); }
.clue:nth-child(1) { --o: 20; }
.clue:nth-child(2) { --o: 54; }
.clue:nth-child(3) { --o: 8; }
.clue:nth-child(4) { --o: 40; }
.clue:nth-child(5) { --o: 66; }
.clue:nth-child(6) { --o: 16; }
.clue:nth-child(7) { --o: 46; }

.guesses { border-top: 0; }
.guesses::before {                     /* the strong rule above the guesses, its own width */
  content: "";
  display: block;
  margin-inline: calc(12 * var(--k));
  border-top: 2px solid var(--rule-strong);
}
.guess { margin-inline: calc(var(--o, 0) * var(--k)); }
.guess:nth-child(1) { --o: 36; }
.guess:nth-child(2) { --o: 4; }
.guess:nth-child(3) { --o: 58; }
.guess:nth-child(4) { --o: 22; }
.guess:nth-child(5) { --o: 48; }
.guess:nth-child(6) { --o: 14; }

.controls-top { flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.slip-head { justify-content: space-between; }
.done-panel { align-items: center; text-align: center; }
.site-footer { text-align: center; }
.site-footer nav { justify-content: center; }
.form-error { text-align: center; }

/* very small phones: slightly smaller profile text so values stay on one line */
@media (max-width: 360px) { .clues { font-size: 0.92rem; } }

/* ==========================================================================
   Lines: no big white rules. Only the dotted leaders in the profile rows and
   soft lines between the guesses that fade out at both ends.
   ========================================================================== */
.slip-head, .slip-total { border: 0; }
.guesses::before { content: none; }
.clue dt::after { border-bottom: 2px dotted var(--rule); }
.ad-slot { border-top: 0; }
.guess, .guess.empty {
  border-bottom: 0;
  background: linear-gradient(90deg, transparent, var(--rule) 22%, var(--rule) 78%, transparent) no-repeat left bottom / 100% 1px;
}


/* ==========================================================================
   Clue display: hidden rows almost disappear, so revealed values stand out.
   ========================================================================== */
.clue.locked dt { opacity: 0.38; }
.clue.locked dt::after { opacity: 0.5; }
.clue dd.pending { opacity: 0.45; font-size: 0.75rem; }
.clue dd:not(.pending) { color: var(--mark); }   /* revealed values in yellow */


.result-stats { margin-top: 18px; padding-top: 4px; border-top: 1px solid var(--line); }
.result-stats h3:first-child { margin-top: 12px; }


/* ==========================================================================
   Make the facts stand out: the job is the headline, revealed values are
   bigger and bolder, labels stay quiet. Line box stays 24px so nothing moves.
   ========================================================================== */
.job-title {
  margin: 10px 0 6px;
  text-align: center;
  font-family: Rockwell, "Rockwell Nova", "Rokkitt", "Roboto Slab", Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.7rem, 8vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.clue dt { font-size: 0.9rem; }
.clue dd:not(.pending) { font-size: 1.12rem; font-weight: 800; }
@media (max-width: 360px) { .clue dd:not(.pending) { font-size: 1.02rem; } }

/* more air above the wordmark; respects the notch on phones */
.topbar { padding-top: max(44px, calc(env(safe-area-inset-top) + 28px)); }
@media (min-width: 600px) { .topbar { padding-top: 64px; } }

/* desktop: the job headline as big and present as on the phone */
@media (min-width: 600px) { .job-title { font-size: 3rem; margin: 16px 0 12px; } }

/* ==========================================================================
   Tighter vertical rhythm so the input sits higher on a phone screen.
   The secondary info above the input ("Guess 3 of 6", currency) is smaller.
   ========================================================================== */
.wrap { padding-top: 8px; gap: 18px; }
.clue { padding: 5px 0; }
.slip-total { margin-top: 2px; padding-top: 6px; }
.controls { gap: 6px; }
.controls-top { gap: 2px; }
.hint { font-size: 0.78rem; font-weight: 600; }
.seg { font-size: 0.78rem; padding: 1px 0; }
.currency-toggle { gap: 12px; }

/* "Today's profile": a small, quiet caption centered above the job */
.slip-head { justify-content: center; padding-bottom: 0; font-size: 0.8rem; font-weight: 700; color: var(--text-quiet); }
.job-title { margin-top: 4px; }
/* a bit more air between "Guess 3 of 6 / USD EUR" and the input */
.controls { gap: 14px; }

/* Higher / Lower: two very soft tints, just enough to tell them apart */
:root { --up: #bfe8d0; --down: #f4c2bb; }
.is-higher { color: var(--up); }
.is-lower  { color: var(--down); }

/* "Guess 3 of 6 / USD EUR": smaller and further away from the input */
.controls { gap: 22px; }
.hint { font-size: 0.72rem; }
.seg  { font-size: 0.72rem; }
/* "Today's profile" sits a bit higher above the job */
.job-title { margin-top: 12px; }

/* guess counter: six dots (used / current / still open) */
.hint { display: flex; gap: 9px; justify-content: center; align-items: center; height: 12px; }
.pip { width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--rule); }
.pip.used { background: var(--text-quiet); box-shadow: none; opacity: 0.7; }
.pip.now  { box-shadow: inset 0 0 0 1.5px var(--text); }
/* without the tagline: keep room under the smile arc */
.brand { padding-bottom: 34px; }
.guesses:empty { display: none; }

/* sources under the facts in the result dialog */
.result-sources { margin: -6px 0 14px; font-size: 0.78rem; color: var(--quiet); }
.result-sources a { color: inherit; text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.ad-slot[hidden] { display: none; }
.noscript { max-width: 32ch; margin: 24px auto; text-align: center; font-weight: 700; }
/* text-style button (e.g. "Play today's puzzle") */
.link-btn { border: 0; padding: 0; background: none; color: var(--mark); font: inherit; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- text pages (privacy) ---------- */
.page-text { max-width: 36rem; line-height: 1.6; }
.page-text h1 { margin: 8px 0 6px; font-size: 1.9rem; text-align: center; }
.page-text h2 { margin: 28px 0 6px; font-size: 1.05rem; }
.page-text p { margin: 0 0 10px; color: var(--text); }
.page-text a { color: var(--text); text-underline-offset: 3px; }
.page-lead { text-align: center; color: var(--text-quiet) !important; margin-bottom: 18px !important; }
.page-date { margin-top: 28px !important; font-size: 0.85rem; color: var(--text-quiet) !important; }
.todo { color: var(--mark) !important; font-weight: 700; }

/* long answers (e.g. ₩25,882,560) drop below the label instead of squeezing it into 3 lines */
.slip-total { flex-wrap: wrap; row-gap: 2px; }
.slip-total > span:first-child { white-space: nowrap; }
.slip-total .answer { margin-left: auto; }
/* smaller digits for long amounts; the line box stays the same so the field never changes height */
#amount { line-height: 2.6rem; height: 2.6rem; box-sizing: content-box; }
#amount.is-long { font-size: 1.3rem; }
