/* ==========================================================================
   The Taro Binder - shared theme ("taro milk tea" light, "taro night" dark)
   ========================================================================== */

:root {
  --bg: #f6efe7;
  --bg-2: #efe3f4;
  --surface: #fffaf4;
  --surface-2: #f4ebf7;
  --surface-glass: rgba(255, 250, 244, 0.72);
  --line: rgba(92, 64, 122, 0.14);
  --line-strong: rgba(92, 64, 122, 0.28);
  --ink: #3a2849;
  --ink-soft: #76648c;
  --ink-faint: #a595b8;
  --taro: #9a7ed2;
  --taro-deep: #6c4bb0;
  --taro-light: #dccbf2;
  --taro-milk: #cdb5ea;
  --on-taro: #ffffff;
  --ditto: #c297dc;
  --ditto-deep: #8d5fae;
  --pearl: #35252b;
  --pearl-shine: #8a6a70;
  --tea: #e9d6bd;
  --honey: #e8b04e;
  --up: #2f9f6e;
  --up-bg: rgba(47, 159, 110, 0.12);
  --down: #d9577a;
  --down-bg: rgba(217, 87, 122, 0.12);
  --shadow-sm: 0 2px 6px rgba(70, 40, 100, 0.08);
  --shadow: 0 10px 30px -10px rgba(70, 40, 100, 0.25);
  --shadow-lg: 0 30px 60px -20px rgba(60, 30, 90, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
  --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: #19121f;
    --bg-2: #231833;
    --surface: #251b31;
    --surface-2: #2f233f;
    --surface-glass: rgba(37, 27, 49, 0.78);
    --line: rgba(210, 190, 255, 0.12);
    --line-strong: rgba(210, 190, 255, 0.24);
    --ink: #f3eafc;
    --ink-soft: #bcaad3;
    --ink-faint: #85739d;
    --taro: #b79cf2;
    --taro-deep: #d4c3ff;
    --taro-light: #3f2f5a;
    --taro-milk: #5a4480;
    --on-taro: #1c1326;
    --pearl: #0e0a10;
    --pearl-shine: #5e4a52;
    --tea: #4b3a33;
    --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: #19121f;
  --bg-2: #231833;
  --surface: #251b31;
  --surface-2: #2f233f;
  --surface-glass: rgba(37, 27, 49, 0.78);
  --line: rgba(210, 190, 255, 0.12);
  --line-strong: rgba(210, 190, 255, 0.24);
  --ink: #f3eafc;
  --ink-soft: #bcaad3;
  --ink-faint: #85739d;
  --taro: #b79cf2;
  --taro-deep: #d4c3ff;
  --taro-light: #3f2f5a;
  --taro-milk: #5a4480;
  --on-taro: #1c1326;
  --pearl: #0e0a10;
  --pearl-shine: #5e4a52;
  --tea: #4b3a33;
  --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(--taro-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; }

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

/* ---- floating boba pearls behind everything -------------------------------- */
.pearl-sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.pearl-sky span {
  position: absolute;
  bottom: -40px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, var(--pearl-shine) 0 12%, var(--pearl) 45%);
  opacity: 0.1;
  animation: pearl-rise linear infinite;
}
:root[data-theme="dark"] .pearl-sky span { background: radial-gradient(circle at 32% 30%, #fff 0 10%, var(--taro) 55%); opacity: 0.07; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pearl-sky span { background: radial-gradient(circle at 32% 30%, #fff 0 10%, var(--taro) 55%); opacity: 0.07; }
}
@keyframes pearl-rise {
  from { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(var(--drift, 20px), -55vh, 0); }
  to { transform: translate3d(0, -115vh, 0); }
}

/* ---- 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-bottom: 1px solid var(--line);
}
.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-display); font-weight: 600; font-size: 1.3rem; 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(--taro-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(--taro), var(--taro-deep)); color: var(--on-taro); box-shadow: 0 6px 16px -6px var(--taro-deep); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 10px 22px -8px var(--taro-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(--taro); box-shadow: 0 0 0 4px color-mix(in srgb, var(--taro) 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='%239a7ed2' 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.taro { background: var(--taro-light); color: var(--taro-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(--taro-deep);
}
.eyebrow::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--pearl-shine) 0 15%, var(--pearl) 55%);
}

.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(50, 20, 80, 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(50, 20, 80, 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;
}
.holo.is-foil { --strength: 0.8; }
.holo.is-plain { --strength: 0.18; }

/* ---- 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(30, 16, 45, 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); } }

footer.site-foot { position: relative; z-index: 1; padding: 40px 0 60px; color: var(--ink-faint); font-size: 0.85rem; text-align: center; }
footer.site-foot a { color: var(--ink-soft); }
footer.site-foot button.linkish { background: none; border: none; padding: 0; color: var(--ink-soft); 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; }
  .pearl-sky { display: none; }
}

@media (max-width: 640px) {
  .brand-name { font-size: 1.1rem; }
  .live-pill .live-text { display: none; }
}
