/* ==========================================================================
   Brumelins — design system "Sticker pastel" (D-073)
   Cute and modern, but cheap to render: hard offset shadows (no blur),
   transforms and opacity only for motion, no backdrop-filter, no WebGL.
   ========================================================================== */

:root {
  /* Surfaces and ink */
  --bg: #F5F1E8;
  --bg-2: #EDE7DA;
  --surface: #FFFDF8;
  --ink: #23302C;
  --ink-soft: #55635E;
  --border: #23302C;
  --shadow-color: #23302C;

  /* Pastels: fills for cards, chips and stickers */
  --mint: #BDEBD3;
  --peach: #FFD5C2;
  --lavender: #DCD4FF;
  --sky: #CBE5FF;
  --butter: #FFE9A6;
  --rose: #FFD0E1;
  --sage: #DCE6DE;

  /* Actions */
  --primary: #8EDDB4;
  --primary-hover: #7DD3A6;
  --danger: #FF9F8C;
  --link: #22695A;
  --focus: #FF7AA8;

  /* Rarity chips (ink text on pastel) */
  --rarity-c: #D5E0D9;
  --rarity-r: #A9D3FF;
  --rarity-sr: #CDBBFF;
  --rarity-ur: #FFD66B;

  /* Shape */
  --radius: 22px;
  --radius-l: 32px;
  --stroke: 2.5px;
  --lift: 4px;
  --shadow: var(--lift) var(--lift) 0 var(--shadow-color);

  /* Type and motion */
  --font-title: "Fredoka", ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease-bounce: cubic-bezier(.34, 1.56, .64, 1);
  --page: 1120px;
  --tabbar: 0px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141B19;
    --bg-2: #101614;
    --surface: #1D2724;
    --ink: #F3EFE6;
    --ink-soft: #B6C3BD;
    --border: rgba(243, 239, 230, 0.22);
    --shadow-color: #070B0A;
    --mint: #20392F;
    --peach: #3D2B26;
    --lavender: #2C2943;
    --sky: #1F3245;
    --butter: #3B3420;
    --rose: #3D2531;
    --sage: #22302B;
    --primary-hover: #A2E6C2;
    --link: #8FDCC4;
    --rarity-c: #3A4842;
    --rarity-r: #2D4E73;
    --rarity-sr: #4B3D7A;
    --rarity-ur: #6E5718;
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--bg);
  /* Paper grain: one tiny tile, rasterized once. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, .logo { font-family: var(--font-title); font-weight: 600; line-height: 1.05; letter-spacing: -0.02em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2.1rem, 8vw, 3.4rem); font-weight: 700; }
h2 { font-size: clamp(1.45rem, 5vw, 2.1rem); margin-top: 1.4em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

a { color: var(--link); text-decoration-thickness: 2px; text-underline-offset: 0.18em; }
a:hover { text-decoration-color: var(--focus); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 8px; }
::selection { background: #FFE9A6; color: #23302C; }

.skip-link { position: absolute; left: 16px; top: -100px; z-index: 50; background: var(--surface); color: var(--ink); padding: 8px 16px; border: var(--stroke) solid var(--border); border-radius: 999px; }
.skip-link:focus { top: 12px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: var(--page); margin: 0 auto; padding: 12px 16px 56px; }
main:focus { outline: none; }

/* Highlighted word in titles: <mark class="hl">brume</mark> */
.hl { background: none; color: inherit; position: relative; white-space: nowrap; z-index: 0; }
.hl::before { content: ""; position: absolute; left: -0.08em; right: -0.08em; bottom: 0.06em; height: 0.42em; z-index: -1; border-radius: 0.2em; background: var(--hl, var(--butter)); transform: rotate(-1.5deg); }
@media (prefers-color-scheme: dark) { .hl::before { filter: brightness(1.7) saturate(1.2); } }
.hl--mint { --hl: var(--mint); } .hl--rose { --hl: var(--rose); } .hl--lavender { --hl: var(--lavender); } .hl--sky { --hl: var(--sky); }

.eyebrow, .chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; margin: 0 0 14px;
  font-size: 0.8rem; font-weight: 800; letter-spacing: 0.02em;
  color: var(--ink); background: var(--chip, var(--mint));
  border: var(--stroke) solid var(--border); border-radius: 999px;
}
.chip--peach { --chip: var(--peach); } .chip--sky { --chip: var(--sky); } .chip--lavender { --chip: var(--lavender); } .chip--butter { --chip: var(--butter); } .chip--rose { --chip: var(--rose); }
.lead { font-size: clamp(1.05rem, 2.6vw, 1.2rem); color: var(--ink-soft); max-width: 36em; }
.aside { font-size: 0.92rem; color: var(--ink-soft); }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.center .lead, .lead.center { margin-inline: auto; }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 30; padding: 10px 12px 0; }
.site-header__bar {
  max-width: var(--page); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 6px 6px 6px 14px;
  background: var(--surface);
  border: var(--stroke) solid var(--border); border-radius: 999px;
  box-shadow: var(--shadow);
}
.logo { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 1.35rem; font-weight: 700; color: var(--ink); text-decoration: none; }
.logo svg { flex: none; width: 30px; height: 30px; transition: transform .4s var(--ease-bounce); }
.logo:hover svg { transform: rotate(-12deg) scale(1.1); }
.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav form { margin: 0; }
.site-nav__link { padding: 8px 12px; border-radius: 999px; font-weight: 800; color: var(--ink); text-decoration: none; }
.site-nav__link:hover, .site-nav__link[aria-current="page"] { background: var(--mint); }
.site-nav__desktop { display: none; }
@media (min-width: 860px) { .site-nav__desktop { display: flex; gap: 2px; } }
@media (max-width: 419px) {
  .site-header__bar { padding-left: 10px; gap: 6px; }
  .logo { font-size: 1.15rem; gap: 6px; }
  .logo svg { width: 26px; height: 26px; }
  .site-nav { gap: 2px; }
  .site-nav__link { padding: 8px 8px; }
  .site-nav .button--small { padding: 6px 12px; }
}
.seed-chip { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 999px; background: var(--butter); color: var(--ink); font-weight: 800; border: var(--stroke) solid var(--border); text-decoration: none; white-space: nowrap; }
.avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--lavender); color: var(--ink); font-family: var(--font-title); font-weight: 700; font-size: 1.1rem; border: var(--stroke) solid var(--border); text-decoration: none; }

/* ---------- Mobile tab bar (signed-in players) ---------- */
.has-tabbar { --tabbar: calc(84px + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border: var(--stroke) solid var(--border); border-radius: 24px; box-shadow: var(--shadow);
  padding: 4px;
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 18px; font-size: 0.7rem; font-weight: 800; color: var(--ink-soft); text-decoration: none; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { background: var(--mint); color: var(--ink); }
@media (min-width: 860px) { .tabbar { display: none; } .has-tabbar { --tabbar: 0px; } }

/* ---------- Buttons: pastel pill + hard shadow, squishes when pressed ---------- */
.button, .link-button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.button {
  --btn-bg: var(--primary);
  --btn-ink: #23302C;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px;
  font-family: var(--font-title); font-weight: 600; font-size: 1.05rem; line-height: 1.1; text-align: center;
  color: var(--btn-ink); background: var(--btn-bg); text-decoration: none;
  border: var(--stroke) solid #23302C; border-radius: 999px;
  box-shadow: 0 var(--lift) 0 #23302C;
  transition: transform .12s ease, box-shadow .12s ease, background-color .15s;
}
.button:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 calc(var(--lift) + 2px) 0 #23302C; }
.button:active { transform: translateY(var(--lift)); box-shadow: 0 0 0 #23302C; }
.button--small { min-height: 40px; padding: 6px 16px; font-size: 0.95rem; --lift: 3px; }
.button--big { min-height: 58px; padding: 14px 30px; font-size: 1.2rem; --lift: 5px; }
.button--wide { width: 100%; margin-top: 10px; }
.button--ghost { --btn-bg: #FFFDF8; --primary-hover: #DCE6DE; }
.button--danger { --btn-bg: var(--danger); --primary-hover: #FF8B75; }
.button--dark { --btn-bg: #23302C; --btn-ink: #FFFDF8; --primary-hover: #34453F; border-color: #23302C; }
@media (prefers-color-scheme: dark) {
  .button { border-color: #070B0A; box-shadow: 0 var(--lift) 0 #070B0A; }
  .button:hover { box-shadow: 0 calc(var(--lift) + 2px) 0 #070B0A; }
  .button--ghost { --btn-bg: #2A3632; --primary-hover: #34433E; --btn-ink: #F3EFE6; }
  .button--dark { --btn-bg: #F3EFE6; --btn-ink: #141B19; --primary-hover: #FFFFFF; }
}
.button[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }
.link-button { background: none; border: 0; padding: 10px 4px; color: var(--link); text-decoration: underline; text-underline-offset: 0.18em; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 22px 0; }

/* ---------- Cards ---------- */
.card, .panel {
  background: var(--card, var(--surface));
  border: var(--stroke) solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card { padding: 20px; }
.card h2, .card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.panel { padding: 26px 20px; max-width: 540px; margin: 16px auto; }
@media (min-width: 640px) { .panel { padding: 32px; } }
.panel.prose { max-width: 760px; }
.panel--wide { max-width: var(--page); }
.card--mint { --card: var(--mint); } .card--peach { --card: var(--peach); } .card--lavender { --card: var(--lavender); }
.card--sky { --card: var(--sky); } .card--butter { --card: var(--butter); } .card--rose { --card: var(--rose); }

/* Sticker tilt: slight rotation, straightens on hover (pointer devices only). */
.tilt-l { transform: rotate(-1.5deg); } .tilt-r { transform: rotate(1.2deg); }
@media (hover: hover) {
  .lift { transition: transform .25s var(--ease-bounce), box-shadow .25s ease; }
  .lift:hover { transform: translate(-3px, -3px) rotate(0); box-shadow: 7px 7px 0 var(--shadow-color); }
}

/* ---------- Messages (toasts) ---------- */
.messages { width: 100%; max-width: var(--page); margin: 12px auto 0; padding-inline: 16px; display: grid; gap: 8px; }
.message { margin: 0; padding: 12px 16px; border: var(--stroke) solid var(--border); border-radius: 18px; background: var(--sky); font-weight: 700; box-shadow: var(--shadow); animation: toast-in .45s var(--ease-bounce) both; }
.message--success { background: var(--mint); }
.message--error { background: var(--peach); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Forms ---------- */
form { margin: 16px 0; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 800; margin-bottom: 6px; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .inline-form input, .breeding-form select {
  width: 100%; min-height: 50px; padding: 10px 16px;
  font: inherit; color: var(--ink); background: var(--surface);
  border: var(--stroke) solid var(--border); border-radius: 16px;
  transition: box-shadow .15s;
}
.field textarea { min-height: 96px; }
.field input:focus, .field select:focus, .field textarea:focus, .inline-form input:focus, .breeding-form select:focus { outline: none; box-shadow: 0 0 0 4px #FFC2D8; }
.field--check > label { display: flex; align-items: flex-start; gap: 12px; font-weight: 600; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 24px; height: 24px; margin: 0; flex: none; accent-color: #3CA678; }
.field--error input { border-color: #D2493A !important; }
.help { margin: 6px 0 0; font-size: 0.875rem; color: var(--ink-soft); }
.error { margin: 6px 0 0; font-size: 0.92rem; font-weight: 800; color: #C2402F; }
.form-errors { padding: 12px 16px; border: var(--stroke) solid var(--border); border-radius: 16px; background: var(--peach); font-weight: 700; }
.form-errors p { margin: 0; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.radio { display: flex; align-items: center; gap: 10px; min-height: 42px; font-weight: 600; }
fieldset.field { border: 0; padding: 0; margin-inline: 0; }
fieldset.field legend { font-weight: 800; margin-bottom: 6px; }
@media (prefers-color-scheme: dark) { .error, .danger { color: #FF9F8C !important; } }

/* ---------- Content bits ---------- */
.code {
  margin: 16px 0 0; padding: 18px 12px;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: clamp(1rem, 5vw, 1.6rem); font-weight: 700; letter-spacing: 0.04em; text-align: center;
  background: var(--butter); color: var(--ink);
  border: var(--stroke) dashed var(--border); border-radius: 18px;
  user-select: all; white-space: nowrap; overflow-x: auto;
}
.code--link { font-size: clamp(0.85rem, 4vw, 1.1rem); white-space: normal; overflow-wrap: anywhere; }
.tips { padding-left: 1.2em; color: var(--ink-soft); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.facts dt { font-weight: 800; }
.facts dd { margin: 0; }
.link-list { list-style: none; padding: 0; margin: 0 0 8px; border: var(--stroke) solid var(--border); border-radius: 18px; overflow: hidden; background: var(--surface); }
.link-list li + li { border-top: var(--stroke) solid var(--border); }
.link-list a { display: flex; justify-content: space-between; gap: 8px; padding: 14px 16px; font-weight: 700; color: var(--ink); text-decoration: none; }
.link-list a::after { content: "→"; transition: transform .2s; }
.link-list a:hover { background: var(--mint); }
.link-list a:hover::after { transform: translateX(4px); }
.danger { color: #C2402F !important; }
.prose h2 { font-size: 1.35rem; margin-top: 1.6em; }
.prose li { margin-bottom: 0.4em; }
.todo { background: #FFE9A6; color: #23302C; padding: 0 6px; border-radius: 6px; font-weight: 800; }
.crumbs { margin: 4px 0 10px; font-weight: 800; }
.crumbs a { text-decoration: none; }

/* ---------- Footer: dark block, oversized wordmark ---------- */
.site-footer { width: 100%; padding: 0 12px calc(12px + var(--tabbar)); }
.site-footer__inner {
  max-width: var(--page); margin: 0 auto; padding: 28px 22px 16px; overflow: hidden;
  background: #23302C; color: #F5F1E8; border-radius: var(--radius-l);
}
@media (prefers-color-scheme: dark) { .site-footer__inner { background: #0D1311; border: var(--stroke) solid var(--border); } }
.site-footer__top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 14px; }
.site-footer p { margin: 0; color: #C9D3CE; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: #F5F1E8; font-weight: 700; }
.site-footer__word {
  margin: 14px 0 0; font-family: var(--font-title); font-weight: 700; letter-spacing: -0.04em; line-height: 0.8;
  font-size: clamp(3.4rem, 18vw, 12.5rem); color: #8EDDB4; white-space: nowrap; user-select: none;
}

/* ---------- Scroll reveal (only when JS runs: html.js) ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s var(--ease-bounce); }
.js .reveal.is-visible { opacity: 1; transform: none; }
.js .reveal--d1 { transition-delay: .08s; } .js .reveal--d2 { transition-delay: .16s; } .js .reveal--d3 { transition-delay: .24s; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .js .reveal { opacity: 1; transform: none; }
}
