/* Bureaucat — Off-Brand custom frontend (Phase 4)
   Brand language carried over from the Blocks UI: cream page, Fredoka type,
   pink/lime accents, amber value pills, the 5-step severity color ramp. */

:root {
  --bg: #FFFDF5;
  --ink: #2B2A26;
  --muted: #7A766C;
  --card: #FFFFFF;
  --line: #EFE9D9;
  --pink: #E91E63;
  --lime: #84CC16;
  --amber-bg: #FFF3CD;
  --amber-ink: #8B6914;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(43, 42, 38, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131A;
    --ink: #F0EEE6;
    --muted: #A39F93;
    --card: #1C1E27;
    --line: #2A2D3A;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

/* display:grid/flex on a class would otherwise beat the UA's [hidden] rule */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Fredoka", ui-sans-serif, system-ui, sans-serif;
  line-height: 1.55;
}

main { max-width: 980px; margin: 0 auto; padding: 0 20px 40px; }

/* ---- Hero ---- */
.hero {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 10px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.hero__cat {
  width: 84px; height: 84px;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.12));
}
.hero__text h1 {
  margin: 0;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--pink), #FF8A3D);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__text p { margin: 2px 0 0; color: var(--muted); font-size: 17px; }

/* ---- Cards ---- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---- Upload ---- */
.upload-card { margin-top: 16px; display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
@media (max-width: 720px) { .upload-card { grid-template-columns: 1fr; } }

.dropzone {
  border: 2.5px dashed var(--line);
  border-radius: var(--radius);
  min-height: 140px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  padding: 14px;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.is-dragover {
  border-color: var(--pink);
  background: color-mix(in srgb, var(--pink) 5%, transparent);
  outline: none;
}
/* After a verdict: the dropzone becomes an obvious, highlighted target for the next letter. */
.dropzone--ready {
  border-color: var(--lime);
  background: color-mix(in srgb, var(--lime) 9%, transparent);
  animation: dz-ready-pulse 1.5s ease-out 3;
}
.dropzone--ready .dropzone__icon { animation: dz-icon-bob 1.5s ease-in-out 3; }
@keyframes dz-ready-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--lime) 55%, transparent); }
  100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--lime) 0%, transparent); }
}
@keyframes dz-icon-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.dropzone__idle { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.dropzone__icon { font-size: 34px; }
.dropzone__hint { color: var(--muted); font-size: 13.5px; }
.dropzone__files { list-style: none; margin: 0; padding: 0; width: 100%; }
.dropzone__files li {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; padding: 4px 8px;
}
.dropzone__files li::before { content: "📄"; }

.upload-card__controls { display: flex; flex-direction: column; gap: 14px; justify-content: center; }

.beginner-toggle {
  display: flex; align-items: center; gap: 10px;
  font-size: 14.5px; cursor: pointer; user-select: none;
}
.beginner-toggle input { position: absolute; opacity: 0; }
.beginner-toggle__track {
  flex: 0 0 auto;
  width: 42px; height: 24px; border-radius: 12px;
  background: var(--line); position: relative; transition: background .15s ease;
}
.beginner-toggle__track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: left .15s ease;
}
.beginner-toggle input:checked + .beginner-toggle__track { background: var(--lime); }
.beginner-toggle input:checked + .beginner-toggle__track::after { left: 21px; }

.cta {
  font-family: inherit;
  font-size: 19px; font-weight: 600;
  padding: 14px 22px;
  border: none; border-radius: 14px;
  background: var(--pink); color: #fff;
  cursor: pointer;
  box-shadow: 0 5px 16px color-mix(in srgb, var(--pink) 45%, transparent);
  transition: transform .1s ease, filter .15s ease;
}
.cta:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.cta:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ---- Action buttons (Read it for me + Read another) sit together by the upload ---- */
.upload-card__buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.upload-card__buttons .cta { flex: 1 1 auto; }
.cta--again {
  background: var(--lime);
  color: #2B3A0E;
  box-shadow: 0 5px 16px color-mix(in srgb, var(--lime) 45%, transparent);
}
.cta--again[hidden] { display: none; }

/* ---- "Verdict for <letter>" attribution chip ---- */
.read-source {
  display: flex; align-items: center; gap: 12px;
  margin-top: 18px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: color-mix(in srgb, var(--pink) 4%, transparent);
}
.read-source__thumb {
  width: 42px; height: 54px; flex: 0 0 auto;
  object-fit: cover; object-position: top;
  border-radius: 6px; border: 1px solid var(--line); background: #fff;
}
.read-source__meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.read-source__eyebrow { font-size: 12px; color: var(--muted); }
.read-source__meta strong { font-size: 15px; word-break: break-word; }

/* ---- Stage (mascot + verdict) ---- */
.stage {
  margin-top: 22px;
  display: grid; grid-template-columns: 240px 1fr; gap: 20px;
  align-items: center;
}
@media (max-width: 720px) { .stage { grid-template-columns: 1fr; text-align: center; } }

.stage__mascot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.mascot { width: 200px; height: 200px; object-fit: contain; }
.stage__status { color: var(--muted); font-size: 14px; min-height: 20px; }

/* Mascot state animations (mirrors the Blocks keyframes) */
.mascot--reading   { animation: bcat-sway 1.1s ease-in-out infinite; }
.mascot--verifying { animation: bcat-pulse 0.7s ease-in-out infinite; }
.mascot--allclear  { animation: bcat-bounce 0.9s ease; }
.mascot--deadline,
.mascot--money     { animation: bcat-shake 0.5s ease 2; }
.mascot--confused,
.mascot--wrong_document { animation: bcat-tilt 0.8s ease; }

@keyframes bcat-sway   { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes bcat-pulse  { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes bcat-bounce { 0% { transform: translateY(0); } 35% { transform: translateY(-18px); } 70% { transform: translateY(0); } 85% { transform: translateY(-7px); } 100% { transform: translateY(0); } }
@keyframes bcat-shake  { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@keyframes bcat-tilt   { 0% { transform: rotate(0); } 40% { transform: rotate(-9deg); } 100% { transform: rotate(0); } }

/* ---- Panic-o-meter gauge ---- */
.panic__placeholder {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 22px; color: var(--muted); text-align: center; font-size: 16px;
}
.panic-gauge { text-align: center; animation: gauge-in .35s ease; }
@keyframes gauge-in { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panic-gauge__title {
  font-weight: 700; letter-spacing: 2px; font-size: 13px;
  color: var(--muted); text-transform: uppercase; margin-bottom: 2px;
}
.panic-gauge__svg { width: 240px; max-width: 100%; height: auto; display: block; margin: 0 auto; }
.panic-gauge__svg .gauge-needle { fill: var(--ink); }
.panic-gauge__svg .gauge-tick { fill: var(--muted); }
.panic-gauge__readout {
  display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: -4px;
}
.panic-gauge__face { font-size: 34px; line-height: 1; animation: face-pop .5s ease; }
@keyframes face-pop { 0% { transform: scale(.3); opacity: 0; } 60% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } }
.panic-gauge__num { font-size: 30px; font-weight: 700; line-height: 1; }
.panic-gauge__word { font-size: 18px; font-weight: 600; }

/* ---- Quip speech bubble ---- */
.quip {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 16px;
  font-style: italic;
  font-size: 16.5px;
  position: relative;
}
.quip::before {
  content: ""; position: absolute; left: -9px; top: 22px;
  border: 9px solid transparent; border-right-color: var(--line);
}
.quip strong { color: var(--pink); font-style: normal; }

/* ---- Deadline banner ---- */
.deadline-banner {
  margin-top: 20px;
  background: var(--amber-bg);
  color: var(--amber-ink);
  border: 1.5px solid color-mix(in srgb, var(--amber-ink) 30%, transparent);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 17px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.deadline-banner .value { text-decoration: underline; text-underline-offset: 3px; }
/* Attention pulse for action-needed verdicts (non-celebratory) */
.deadline-banner.pulse { animation: deadline-pulse 0.9s ease-out 2; }
@keyframes deadline-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 209, 102, 0); transform: scale(1); }
  35%      { box-shadow: 0 0 0 6px rgba(255, 209, 102, 0.55); transform: scale(1.015); }
}

/* ---- Results grid ---- */
.results {
  margin-top: 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 720px) { .results { grid-template-columns: 1fr; } }
.result-card--tldr { grid-column: 1 / -1; border-top: 4px solid var(--lime); }
.result-card h2 { margin: 0 0 10px; font-size: 18px; }
.prose { font-size: 15.5px; }
.prose p { margin: 0 0 10px; }

/* ---- Checklist ---- */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 12px;
  background: color-mix(in srgb, var(--lime) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--lime) 25%, transparent);
  border-radius: 12px;
  cursor: pointer; font-size: 15px;
}
.check-item input { margin-top: 3px; accent-color: var(--lime); width: 17px; height: 17px; flex: 0 0 auto; }
.check-item.done { opacity: .55; text-decoration: line-through; }

/* ---- Deadlines list ---- */
.deadlines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.deadlines li { font-size: 15px; }
.deadlines mark {
  background: var(--amber-bg); color: var(--amber-ink);
  padding: 3px 7px; border-radius: 6px; font-weight: 600;
}
.deadlines .none { color: var(--muted); }

/* ---- Grounding badge ---- */
.grounding { margin-top: 14px; font-size: 13.5px; border-radius: 10px; padding: 9px 12px; }
.grounding.ok   { background: color-mix(in srgb, var(--lime) 12%, transparent); color: #3F6212; }
.grounding.fail { background: #FDECEA; color: #B71C1C; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .grounding.ok { color: #B5E48C; }
  .grounding.fail { background: #3a1d1b; color: #FF8A80; }
}

/* ---- Refusal ---- */
.refusal { margin-top: 20px; border-top: 4px solid #E67E22; }

/* ---- Gallery ---- */
.gallery-section { margin-top: 34px; }
.gallery-section h2 { font-size: 20px; margin-bottom: 2px; }
.gallery-section__hint { color: var(--muted); margin-top: 0; font-size: 14.5px; }
.gallery {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}
@media (max-width: 860px) { .gallery { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .gallery { grid-template-columns: repeat(2, 1fr); } }
.gallery__item {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 8px; cursor: pointer; text-align: center;
  transition: transform .12s ease, border-color .12s ease;
  font-family: inherit; color: var(--ink);
}
.gallery__item:hover { transform: translateY(-3px); border-color: var(--pink); }
.gallery__item img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 9px; }
.gallery__item span { display: block; font-size: 12px; margin-top: 6px; color: var(--muted); }

/* ---- Verdict screen flash (full-viewport edge pulse) ---- */
.screen-flash { position: fixed; inset: 0; pointer-events: none; z-index: 9998; }
.screen-flash--good { animation: flash-good 0.9s ease-out forwards; }
.screen-flash--alert { animation: flash-alert 0.6s ease-out 2; }
@keyframes flash-good {
  0%   { box-shadow: inset 0 0 0 0 rgba(132,204,22,0); }
  30%  { box-shadow: inset 0 0 160px 30px rgba(132,204,22,0.45); }
  100% { box-shadow: inset 0 0 0 0 rgba(132,204,22,0); }
}
@keyframes flash-alert {
  0%   { box-shadow: inset 0 0 0 0 rgba(192,57,43,0); }
  35%  { box-shadow: inset 0 0 180px 40px rgba(192,57,43,0.5); }
  100% { box-shadow: inset 0 0 0 0 rgba(192,57,43,0); }
}

/* ---- Sound toggle ---- */
.sound-toggle {
  position: fixed; bottom: 16px; right: 16px; z-index: 9999;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 20px; cursor: pointer; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease;
}
.sound-toggle:hover { transform: scale(1.08); }

/* ---- Footer ---- */
.footer {
  max-width: 980px; margin: 30px auto 0; padding: 18px 20px 34px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 13px; text-align: center;
}
.footer p { margin: 4px 0; }

/* ============================================================
   Engagement pass: countdowns, skeleton, panic reveal, share
   ============================================================ */

/* ---- Deadline countdown pills ---- */
.cd {
  display: inline-block; margin-left: 6px;
  padding: 1px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
  vertical-align: middle;
}
.cd--overdue { background: #FDE2E1; color: #B3261E; }
.cd--soon    { background: #FDECD2; color: #9A5B00; }
.cd--near    { background: #FFF3CD; color: #8B6914; }
.cd--far     { background: var(--line); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .cd--overdue { background: #4A1F1C; color: #FFB4AB; }
  .cd--soon    { background: #432F12; color: #FFD8A8; }
  .cd--near    { background: #3A340F; color: #F2D98D; }
}

/* ---- Skeleton shimmer while reading ---- */
.skeleton { max-width: 980px; margin: 22px auto 0; display: grid; gap: 14px; }
.skel-card {
  height: 96px; border-radius: var(--radius);
  background: linear-gradient(100deg,
    var(--card) 30%, color-mix(in srgb, var(--line) 60%, var(--card)) 50%, var(--card) 70%);
  background-size: 220% 100%;
  border: 1px solid var(--line);
  animation: skel-shimmer 1.25s ease-in-out infinite;
}
.skel-card--tall { height: 150px; }
@keyframes skel-shimmer { 0% { background-position: 180% 0; } 100% { background-position: -80% 0; } }

/* ---- Panic reveal: number pop + severity colour-wash + alarm aura ---- */
.panic-gauge__num.num-pop { animation: num-pop 0.18s ease; }
@keyframes num-pop { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(1); } }

.stage {
  border-radius: var(--radius);
  transition: background 0.4s ease, box-shadow 0.4s ease;
}
/* faint wash in the verdict's severity colour (set via --sev on the stage) */
.stage[style*="--sev"] {
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--sev) 12%, transparent), transparent 70%);
}
.stage--alarm { box-shadow: 0 0 0 2px color-mix(in srgb, var(--sev) 35%, transparent); }
.stage--alarm .mascot { animation: bcat-alarm 0.5s ease-in-out 3; }
@keyframes bcat-alarm {
  0%,100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-5px) rotate(-3deg); }
  75% { transform: translateX(5px) rotate(3deg); }
}

/* ---- Quip as a cat speech bubble ---- */
.quip {
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.quip::before {
  content: ""; position: absolute; left: 26px; top: -9px;
  width: 16px; height: 16px; background: var(--card);
  border-left: 1.5px solid var(--line); border-top: 1.5px solid var(--line);
  transform: rotate(45deg);
}

/* ---- Share button ---- */
.share-row { display: flex; justify-content: center; margin-top: 18px; }
.cta--share {
  background: linear-gradient(135deg, var(--pink), #FF6FA5);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .skel-card { animation: none; }
  .panic-gauge__num.num-pop { animation: none; }
  .stage--alarm .mascot { animation: none; }
}
