/* ==========================================================================
   Pulls for Two - shared theme: "Bun Wonderland" bakery (morning bakery light,
   late-night bakery dark). Text colours (--ink*, --up, --down, --crust-deep) keep at least
   4.5:1 contrast on --bg, --surface and --surface-2, white on --crust buttons too, and
   --up/--down inside their own chips.
   ========================================================================== */

:root {
  --bg: #fbf1e4;
  --bg-2: #f8dfbd;
  --surface: #fffaf3;
  --surface-2: #f6ead9;
  --surface-glass: rgba(255, 250, 243, 0.74);
  --line: rgba(120, 72, 30, 0.15);
  --line-strong: rgba(120, 72, 30, 0.3);
  --ink: #46280f;
  --ink-soft: #6e4a2a;
  --ink-faint: #7d5838;
  --crust: #ad6522;
  --crust-deep: #8a4b14;
  --crust-light: #f7dfbd;
  --crust-milk: #efc792;
  --on-crust: #ffffff;
  --hero-tint: #e9a24b;
  /* bakery pieces: awning stripes, the counter (footer), dough, cheeks, floating snacks */
  --awning: #f3b25f;
  --awning-cream: #fffcf7;
  --awning-band: #b4773a;
  --counter: #9c5c24;
  --counter-ink: #fff3e3;
  --dough: #f8e4c3;
  --dough-toast: #dd9548;
  --dough-line: #a8682e;
  --cheek: #f4a8b6;
  --snack: #d98c3a;
  --honey: #e8a93c;
  --up: #176d47;
  --up-bg: rgba(23, 109, 71, 0.12);
  --down: #ae3456;
  --down-bg: rgba(174, 52, 86, 0.12);
  --shadow-sm: 0 2px 6px rgba(90, 50, 15, 0.08);
  --shadow: 0 10px 30px -10px rgba(90, 50, 15, 0.25);
  --shadow-lg: 0 30px 60px -20px rgba(80, 40, 10, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
  --brand-ink: #8a4b14;
  --font-bakery: "Chewy", "Fredoka", system-ui, sans-serif; /* the bubbly lettering: brand and big headings */
  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d140e;
    --bg-2: #2e1d10;
    --surface: #2a1d14;
    --surface-2: #35251a;
    --surface-glass: rgba(42, 29, 20, 0.8);
    --line: rgba(255, 214, 170, 0.12);
    --line-strong: rgba(255, 214, 170, 0.24);
    --ink: #fbeedd;
    --ink-soft: #dcc2a4;
    --ink-faint: #b89a7b;
    --crust: #e9a557;
    --crust-deep: #f5c27f;
    --crust-light: #4a3020;
    --crust-milk: #6b4426;
    --on-crust: #2a1708;
    --hero-tint: #ffd99a;
    --brand-ink: #f5c27f;
    --awning: #c98034;
    --awning-cream: #3b2818;
    --awning-band: #8a4f1c;
    --counter: #2a180b;
    --counter-ink: #f0d9bd;
    --snack: #f0b464;
    --up: #5cd39c;
    --up-bg: rgba(92, 211, 156, 0.14);
    --down: #ff8aa6;
    --down-bg: rgba(255, 138, 166, 0.14);
    --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #1d140e;
  --bg-2: #2e1d10;
  --surface: #2a1d14;
  --surface-2: #35251a;
  --surface-glass: rgba(42, 29, 20, 0.8);
  --line: rgba(255, 214, 170, 0.12);
  --line-strong: rgba(255, 214, 170, 0.24);
  --ink: #fbeedd;
  --ink-soft: #dcc2a4;
  --ink-faint: #b89a7b;
  --crust: #e9a557;
  --crust-deep: #f5c27f;
  --crust-light: #4a3020;
  --crust-milk: #6b4426;
  --on-crust: #2a1708;
  --hero-tint: #ffd99a;
  --brand-ink: #f5c27f;
  --awning: #c98034;
  --awning-cream: #3b2818;
  --awning-band: #8a4f1c;
  --counter: #2a180b;
  --counter-ink: #f0d9bd;
  --snack: #f0b464;
  --up: #5cd39c;
  --up-bg: rgba(92, 211, 156, 0.14);
  --down: #ff8aa6;
  --down-bg: rgba(255, 138, 166, 0.14);
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-2), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, var(--bg-2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: var(--crust-deep); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
/* Chewy has one weight: never let the browser fake a bold one */
h1, h2 { font-family: var(--font-bakery); font-weight: 400; letter-spacing: 0.01em; font-synthesis: none; }

.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; }

.wrap { width: min(1240px, 100% - 32px); margin-inline: auto; }

/* ---- pretzels, crackers and little buns drifting behind everything ------------------ */
.snack-sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; color: var(--snack); }
.snack-sky span { position: absolute; bottom: -60px; opacity: 0.2; animation: snack-rise linear infinite; }
.snack-sky svg { display: block; width: 100%; height: 100%; animation: snack-spin 18s linear infinite; }
:root[data-theme="dark"] .snack-sky span { opacity: 0.11; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .snack-sky span { opacity: 0.11; }
}
@keyframes snack-rise {
  from { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(var(--drift, 20px), -55vh, 0); }
  to { transform: translate3d(0, -118vh, 0); }
}
@keyframes snack-spin { to { transform: rotate(var(--spin, 360deg)); } }

/* ---- header ------------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  border-top: 6px solid var(--awning-band);
  margin-bottom: 18px; /* room for the awning hanging below */
}
/* the bakery awning: a striped valance hanging under the header, each stripe ending in a scallop */
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 28px; pointer-events: none;
  background: repeating-linear-gradient(90deg, var(--awning) 0 30px, var(--awning-cream) 30px 60px);
  -webkit-mask: linear-gradient(#000, #000) 0 0 / 100% 13px no-repeat, radial-gradient(circle at 15px 13px, #000 14.5px, transparent 15px) 0 0 / 30px 28px repeat-x;
  mask: linear-gradient(#000, #000) 0 0 / 100% 13px no-repeat, radial-gradient(circle at 15px 13px, #000 14.5px, transparent 15px) 0 0 / 30px 28px repeat-x;
}
/* its shadow: the same scalloped shape a little lower (a filter would be cut off by the mask) */
.topbar::before {
  content: ""; position: absolute; left: 0; right: 0; top: calc(100% + 3px); height: 28px; pointer-events: none;
  background: rgba(90, 50, 15, 0.13);
  -webkit-mask: linear-gradient(#000, #000) 0 0 / 100% 13px no-repeat, radial-gradient(circle at 15px 13px, #000 14.5px, transparent 15px) 0 0 / 30px 28px repeat-x;
  mask: linear-gradient(#000, #000) 0 0 / 100% 13px no-repeat, radial-gradient(circle at 15px 13px, #000 14.5px, transparent 15px) 0 0 / 30px 28px repeat-x;
}
.topbar .wrap { display: flex; align-items: center; gap: 14px; min-height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 44px; height: 38px; flex: none; }
.brand-name { font-family: var(--font-bakery); font-weight: 400; font-synthesis: none; font-size: 1.5rem; color: var(--brand-ink); letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }

.live-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-glass); border: 1px solid var(--line);
  font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 var(--up); animation: live-pulse 2s infinite; }
.live-pill.is-stale .live-dot { background: var(--honey); animation: none; }
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--up) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface-glass);
  cursor: pointer; color: var(--ink-soft); text-decoration: none;
  transition: transform .15s, background .15s, color .15s;
}
.icon-btn:hover { color: var(--crust-deep); background: var(--surface); transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---- buttons, inputs, chips --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: 0.95rem; cursor: pointer; text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, background .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, var(--crust), var(--crust-deep)); color: var(--on-crust); box-shadow: 0 6px 16px -6px var(--crust-deep); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 22px -8px var(--crust-deep); transform: translateY(-1px); }
.btn-ghost { background: var(--surface-glass); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { background: var(--surface); border-color: var(--line-strong); }
.btn-danger { background: var(--down-bg); color: var(--down); border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn svg { width: 16px; height: 16px; flex: none; }

.input, .select, .textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line-strong); background: var(--surface);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--crust); box-shadow: 0 0 0 4px color-mix(in srgb, var(--crust) 22%, transparent); }
.select { appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23ad6522' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.textarea { resize: vertical; min-height: 70px; }
label.field { display: grid; gap: 6px; font-weight: 700; font-size: 0.85rem; color: var(--ink-soft); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700;
  background: var(--surface-2); color: var(--ink-soft); white-space: nowrap;
}
.chip.up { background: var(--up-bg); color: var(--up); }
.chip.down { background: var(--down-bg); color: var(--down); }
.chip.crust { background: var(--crust-light); color: var(--crust-deep); }
.chip.honey { background: color-mix(in srgb, var(--honey) 22%, transparent); color: color-mix(in srgb, var(--honey) 70%, var(--ink)); }

.panel {
  position: relative;
  background: var(--surface-glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 6px;
  font-size: 0.78rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--crust-deep);
}
.eyebrow::before {
  content: ""; width: 14px; height: 10px; border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  background: radial-gradient(circle at 50% 22%, var(--dough-toast) 0 32%, var(--dough) 75%);
  box-shadow: inset 0 0 0 1.5px var(--dough-line);
}

.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.num { font-variant-numeric: tabular-nums; }

/* ---- holographic card ----------------------------------------------------------- */
.holo {
  --rx: 0deg; --ry: 0deg; --mx: 50%; --my: 50%; --px: 50%; --py: 50%; --hover: 0; --strength: 0.45;
  position: relative;
  aspect-ratio: 245 / 342;
  border-radius: 4.6% / 3.3%;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.2, .8, .2, 1), box-shadow .3s;
  box-shadow: 0 8px 18px -8px rgba(70, 35, 10, 0.45);
  background: var(--surface-2);
  overflow: hidden;
  isolation: isolate;
  will-change: transform;
}
.holo.is-active { transition: transform .08s linear, box-shadow .3s; box-shadow: 0 22px 40px -14px rgba(70, 35, 10, 0.6); }
.holo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; user-select: none; -webkit-user-drag: none; }
.holo::before, .holo::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
/* rainbow foil */
.holo::before {
  background:
    repeating-linear-gradient(115deg,
      hsl(283 90% 72%) 0%, hsl(190 95% 70%) 8%, hsl(140 80% 72%) 14%,
      hsl(52 95% 72%) 20%, hsl(330 90% 74%) 27%, hsl(283 90% 72%) 34%);
  background-size: 260% 260%;
  background-position: var(--px) var(--py);
  mix-blend-mode: color-dodge;
  filter: brightness(.55) contrast(1.6) saturate(1.3);
  opacity: calc(var(--hover) * var(--strength));
  transition: opacity .35s;
  z-index: 2;
}
/* glare */
.holo::after {
  background: radial-gradient(farthest-corner circle at var(--mx) var(--my),
    rgba(255, 255, 255, 0.75) 0%, rgba(255, 255, 255, 0.18) 28%, rgba(0, 0, 0, 0.28) 95%);
  mix-blend-mode: overlay;
  opacity: calc(var(--hover) * 0.9);
  transition: opacity .35s;
  z-index: 3;
}
/* Sideways cards: in a regular (portrait) frame, turn the card 90° so it fills the slot the way it
   sits in a binder pocket. Big views (.holo-wide) switch the frame itself to landscape instead.
   The frame is drawn flat: with preserve-3d, Firefox clips the turned image to its unturned box
   until something like hovering forces a repaint. Chrome already flattens it (overflow: hidden). */
.holo.is-landscape { transform-style: flat; }
.holo.is-landscape img, .r-img.is-landscape img {
  position: absolute; top: 50%; left: 50%;
  width: calc(100% * 342 / 245); height: calc(100% * 245 / 342); max-width: none;
  border-radius: 3.3% / 4.6%;
  transform: translate(-50%, -50%) rotate(90deg);
}
.holo-wide.is-landscape { aspect-ratio: 342 / 245; border-radius: 3.3% / 4.6%; }
.holo-wide.is-landscape img { position: static; width: 100%; height: 100%; border-radius: inherit; transform: none; }
.holo.is-foil { --strength: 0.8; }
.holo.is-plain { --strength: 0.18; }

/* ---- Riftbound accent --------------------------------------------------------------
   While Riftbound is picked (public page or admin), the accent is a matcha bun green.
   Ditto, the basket and the awning stay bakery gold; they're the brand. */
:root[data-game="riftbound"] {
  --crust: #55802f; --crust-deep: #46682a; --crust-light: #e1ecd0; --crust-milk: #bcd59c; --hero-tint: #9cc46c;
}
:root[data-theme="dark"][data-game="riftbound"] {
  --crust: #9cc46c; --crust-deep: #c2e09a; --crust-light: #263620; --crust-milk: #3a5229; --hero-tint: #e3efc0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"])[data-game="riftbound"] {
    --crust: #9cc46c; --crust-deep: #c2e09a; --crust-light: #263620; --crust-milk: #3a5229; --hero-tint: #e3efc0;
  }
}

/* ---- dialog ---------------------------------------------------------------------- */
dialog.sheet {
  border: none; padding: 0; background: transparent; color: var(--ink);
  max-width: min(980px, calc(100% - 24px)); width: 100%;
  max-height: calc(100dvh - 24px);
}
dialog.sheet::backdrop { background: rgba(45, 24, 8, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
dialog.sheet[open] { animation: sheet-in .35s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(20px) scale(.97); } }
.sheet-body {
  background: var(--surface); border-radius: 28px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); overflow: auto; max-height: calc(100dvh - 24px);
  position: relative;
}
.sheet-close { position: absolute; top: 14px; right: 14px; z-index: 5; }

/* ---- toast ------------------------------------------------------------------------- */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(420px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--bg);
  font-weight: 700; box-shadow: var(--shadow-lg);
  animation: toast-in .4s cubic-bezier(.2, .9, .3, 1.3);
}
.toast.error { background: var(--down); color: #fff; }
.toast.leaving { animation: toast-out .3s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(.9); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ---- ditto -------------------------------------------------------------------------- */
.ditto { overflow: visible; }
.ditto .ditto-body-wrap { transform-origin: 50% 95%; transform-box: fill-box; }
.ditto.is-idle .ditto-body-wrap { animation: ditto-wobble 3.2s ease-in-out infinite; }
.ditto .ditto-eyes { transform-origin: center; transform-box: fill-box; animation: ditto-blink 4.8s infinite; }
@keyframes ditto-wobble {
  0%, 100% { transform: scale(1, 1); }
  25% { transform: scale(1.04, 0.95); }
  50% { transform: scale(0.97, 1.04); }
  75% { transform: scale(1.02, 0.98); }
}
@keyframes ditto-blink { 0%, 94%, 100% { transform: scaleY(1); } 96% { transform: scaleY(0.1); } }

/* the bakery counter: brown, with cream scallops along the top and two awning stripes at the bottom */
footer.site-foot {
  position: relative; z-index: 1; margin-top: 48px; padding: 52px 0 64px;
  color: var(--counter-ink); font-size: 0.85rem; text-align: center;
  background:
    linear-gradient(to bottom, transparent calc(100% - 30px), var(--awning) calc(100% - 30px) calc(100% - 23px),
      transparent calc(100% - 23px) calc(100% - 15px), var(--awning) calc(100% - 15px) calc(100% - 10px), transparent calc(100% - 10px)),
    var(--counter);
}
footer.site-foot::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 22px;
  background: radial-gradient(circle at 22px 0, var(--bg) 21.5px, transparent 22px) 0 0 / 44px 22px repeat-x;
}
footer.site-foot a, footer.site-foot button.linkish { color: var(--counter-ink); }
footer.site-foot button.linkish { background: none; border: none; padding: 0; text-decoration: underline; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .snack-sky { display: none; }
}

.admin-link { gap: 6px; }

@media (max-width: 640px) {
  .brand-name { font-size: 1.1rem; }
  .btn-label { display: none; }
  .topbar .btn-sm { padding: 8px 10px; }
  .live-pill .live-text { display: none; }
}
