/* styles.css — cozy-professional look. Pixel art for celebration, clean screens for data. */

@font-face {
  font-family: 'Pixelify Sans';
  src: url('../fonts/pixelify-sans.woff2') format('woff2');
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Nunito';
  src: url('../fonts/nunito.woff2') format('woff2');
  font-weight: 400 800; font-style: normal; font-display: swap;
}

:root {
  --bg: #fbf6ec;
  --paper: #ffffff;
  --ink: #26314a;
  --ink2: #5b6580;
  --line: #e6dccb;
  --navy: #2b3a5c;
  --navy-2: #3c4f7a;
  --gold: #f6c453;
  --gold-dk: #c9952a;
  --teal: #3f8f8c;
  --rose: #d77a8f;
  --danger: #b4483f;
  --focus: #4f86c6;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(38, 49, 74, .06), 0 6px 18px rgba(38, 49, 74, .06);
  --pixel: 'Pixelify Sans', ui-monospace, monospace;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-variant-ligatures: none;
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 var(--body);
  background-image:
    radial-gradient(circle at 12% 0%, rgba(246, 196, 83, .14), transparent 40%),
    radial-gradient(circle at 100% 30%, rgba(63, 143, 140, .08), transparent 45%);
  background-attachment: fixed;
  min-height: 100vh;
}
body.quiet { background-image: none; }

a { color: var(--navy-2); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .75em; }
.fine { color: var(--ink2); font-size: .92rem; }
.lede { color: var(--ink2); margin-top: -.25em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading { text-align: center; padding: 4rem 1rem; font-family: var(--pixel); color: var(--ink2); }
.pix { image-rendering: pixelated; display: block; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------- layout ---------- */
.app { max-width: 920px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
#view { outline: none; padding-top: 8px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 0 10px; padding-top: max(14px, env(safe-area-inset-top));
}
.brand {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--navy);
  font: 700 1.2rem/1 var(--pixel); letter-spacing: .3px; margin: 0;
}
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.save-status { font-size: .8rem; color: var(--ink2); white-space: nowrap; }
.player-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 6px; min-height: 40px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink);
  font-weight: 700; box-shadow: var(--shadow); min-width: 0;
}
.chip-name { max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Area navigation: tabs on wide screens, bottom bar on phones */
.areas {
  display: flex; gap: 6px; padding: 6px; background: var(--navy); border-radius: var(--radius);
  margin: 6px 0 18px; box-shadow: var(--shadow);
}
.areas a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 8px; border-radius: 10px; color: #e8ecf5; text-decoration: none; font-weight: 700; font-size: .95rem;
}
.areas a:hover { background: rgba(255, 255, 255, .08); }
.areas a[aria-current=page] { background: var(--bg); color: var(--navy); }

@media (max-width: 700px) {
  .areas {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0; border-radius: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 2px;
  }
  .areas a { flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 2px; }
  .save-status { display: none; }
  .brand span { font-size: 1.05rem; }
}
@media (max-width: 380px) { .chip-name { display: none; } }

/* ---------- cards & text ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 0 0 14px; box-shadow: var(--shadow);
}
.area-title { display: flex; align-items: center; gap: 10px; font: 700 1.6rem/1.2 var(--pixel); color: var(--navy); margin: 6px 0 14px; }
.welcome { display: flex; gap: 16px; align-items: center; }
.welcome h2 { font-size: 1.25rem; }
.welcome-art { flex: none; background: #eef3f1; border-radius: 12px; padding: 8px; }
body.quiet .welcome-art { background: none; padding: 0; }
.placeholder .soon { margin: 0; }
.pixel-badge {
  display: inline-block; font: 600 .85rem/1 var(--pixel); color: var(--navy); background: #fdf0cf;
  border: 2px solid var(--gold-dk); padding: 6px 10px; border-radius: 4px; box-shadow: 2px 2px 0 var(--gold-dk);
}
body.quiet .pixel-badge { box-shadow: none; border-width: 1px; }
.tag { font: 700 .72rem/1 var(--body); background: #eef1f7; color: var(--ink2); padding: 4px 8px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.facts { margin: 0; padding-left: 1.1em; }
.facts li { margin: 0 0 .4em; }
.danger-zone { border-color: #efcfca; }

.disclaimer {
  font-size: .82rem; color: var(--ink2); text-align: center; padding: 18px 8px 8px; max-width: 640px; margin: 0 auto;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none; font: 700 1rem/1.2 var(--body); border-radius: 10px; padding: 11px 16px; min-height: 44px;
  border: 2px solid var(--navy); background: var(--paper); color: var(--navy); cursor: pointer;
}
.btn:hover { background: #f3f5fa; }
.btn.primary { background: var(--navy); color: #fff; box-shadow: 0 3px 0 #1b2236; }
.btn.primary:hover { background: var(--navy-2); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #1b2236; }
.btn.ghost { border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn.ghost:hover { background: rgba(43, 58, 92, .06); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: #fbeeec; }
.btn.small { padding: 7px 12px; min-height: 36px; font-size: .9rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.icon-btn { appearance: none; border: 0; background: transparent; color: inherit; font-size: 1.1rem; cursor: pointer; padding: 8px; min-width: 40px; min-height: 40px; }
body.quiet .btn.primary { box-shadow: none; }

/* ---------- onboarding ---------- */
.ob-header { padding: 18px 0 6px; padding-top: max(18px, env(safe-area-inset-top)); }
.ob-main { max-width: 620px; margin: 0 auto; }
body.onboarding-mode .app { padding-bottom: 24px; }
.onboarding { padding: 22px 22px 18px; }
.ob-step h2 { font-size: 1.35rem; outline: none; }
.pixel-title { font-family: var(--pixel); color: var(--navy); font-size: 1.5rem !important; }
.ob-hero, .celebrate { display: flex; justify-content: center; gap: 10px; margin: 4px 0 14px; }
.celebrate { animation: hop .9s ease-in-out 2; }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-10px); } }
.ob-dots { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 16px; }
.ob-dots li { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.ob-dots li.done { background: var(--teal); }
.ob-dots li.now { background: var(--gold); }
.ob-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.ob-nav-right { display: flex; gap: 8px; margin-left: auto; }

.field { display: block; margin: 8px 0; }
.field span { display: block; font-weight: 700; margin-bottom: 6px; }
.field input {
  width: 100%; font: 1.05rem var(--body); padding: 12px 14px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.field input:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(79, 134, 198, .25); }
.error { color: var(--danger); font-weight: 700; margin: 6px 0 0; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.char-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 460px) { .char-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; } .char-card .pix { width: 52px; height: auto; } }
.char-opt input, .choice input, .pill input { position: absolute; opacity: 0; pointer-events: none; }
.char-card {
  display: flex; justify-content: center; padding: 10px 4px; border: 2px solid var(--line); border-radius: 12px; background: #f6f3ec; cursor: pointer;
}
.char-opt input:checked + .char-card { border-color: var(--navy); background: #fdf0cf; box-shadow: 0 0 0 2px var(--gold) inset; }
.char-opt input:focus-visible + .char-card,
.choice input:focus-visible + span,
.pill input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.choice-list { display: grid; gap: 8px; }
.choice-list.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 460px) { .choice-list.two { grid-template-columns: 1fr; } }
.choice span {
  display: block; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff;
}
.choice small { display: block; color: var(--ink2); font-size: .9rem; }
.choice input:checked + span { border-color: var(--navy); background: #f4f7fd; box-shadow: 0 0 0 2px var(--navy) inset; }
.custom-tags { margin-top: 14px; padding: 12px 14px; background: #f6f3ec; border-radius: 12px; }
.custom-tags legend { font-weight: 700; padding: 0; margin-bottom: 6px; float: left; width: 100%; }
.check { display: flex; gap: 10px; align-items: center; padding: 6px 0; clear: both; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill span { display: inline-block; padding: 10px 16px; border: 2px solid var(--line); border-radius: 999px; cursor: pointer; font-weight: 700; background: #fff; }
.pill input:checked + span { border-color: var(--navy); background: var(--navy); color: #fff; }

.switch { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 14px; cursor: pointer; }
.switch input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--navy); }
.switch small { display: block; color: var(--ink2); }

/* ---------- banners, toasts, modals ---------- */
.banner {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fdf0cf; border: 1px solid #edd291; border-radius: var(--radius); padding: 10px 14px; margin: 0 0 12px;
}
.banner > span:first-child { display: inline-flex; gap: 8px; align-items: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; max-width: min(92vw, 480px);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; box-shadow: var(--shadow); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 701px) { .toast { bottom: 24px; } }

.update-notice {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 4px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px;
  padding: 6px 6px 6px 8px; box-shadow: 0 8px 24px rgba(38, 49, 74, .18); max-width: calc(100vw - 24px);
}

.modal { border: 0; border-radius: 16px; padding: 0; max-width: min(92vw, 460px); width: 100%; color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal::backdrop { background: rgba(27, 34, 54, .45); }
.modal-body { padding: 20px 22px 6px; }
.modal-actions { padding: 8px 22px 20px; justify-content: flex-end; }
.save-preview { display: flex; gap: 12px; align-items: center; background: #f6f3ec; padding: 10px 12px; border-radius: 12px; margin: 0 0 12px; }

.boot-error { margin-top: 3rem; text-align: center; }

/* ---------- quiet mode & reduced motion ---------- */
body.quiet .celebrate { animation: none; }
body.quiet .ob-hero { display: none; }
body.quiet .area-title { font-family: var(--body); font-weight: 800; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- pixel font: no ligatures ----------
   Pixelify Sans swaps letter pairs like "fi" for a combined glyph that looks broken
   ("first" read as "Arst"). Turn every ligature/alternate feature off wherever the
   pixel font is used. This rule sits last on purpose: the `font:` shorthand used
   above resets ligatures, so it must come after those rules. */
.loading, .brand, .area-title, .pixel-badge, .pixel-title {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0, "dlig" 0, "calt" 0;
}
