/* Matt's Teddy Bear Home: shared design system.
   Cocoa night, honey gold, patchwork-quilt stitching, soft glass panels.
   Cozy on the outside, with a teddy bear peeking in from the corner.
   Rules that matter here: big targets, high contrast, nothing flashes,
   no hover-only UI (tablet + phone), predictable layouts, and every
   animation respects "reduce motion" and the Snow switch. */

@font-face {
  font-family: "Fraunces";
  src: url("/shared/fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/shared/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #1c110b;
  --bg-2: #2a1a10;
  --ink: #fff3e0;
  --muted: #dcc7ad;
  --gold: #f2b24a;
  --gold-hi: #ffd88a;
  --gold-ink: #3a1f06;
  --red: #e0574a;
  --green: #4cae7e;
  --glass: rgba(52, 33, 21, .62);
  --glass-hi: rgba(74, 48, 30, .72);
  --line: rgba(255, 238, 214, .17);
  --line-hi: rgba(242, 178, 74, .55);
  --radius: 26px;
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .75), 0 2px 0 rgba(255, 255, 255, .05) inset;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;           /* no double-tap zoom (pinch still works) */
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.2rem/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- Backdrop: a patchwork quilt, dimmed, with slow parallax ---------- */
.backdrop {
  position: fixed;
  inset: -4vh -4vw;
  z-index: -3;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Crect width='120' height='120' fill='%23311d12'/%3E%3Crect x='120' width='120' height='120' fill='%232a190f'/%3E%3Crect y='120' width='120' height='120' fill='%232a190f'/%3E%3Crect x='120' y='120' width='120' height='120' fill='%23361f13'/%3E%3Cg fill='none' stroke='%23f2b24a' stroke-opacity='.28' stroke-width='2' stroke-dasharray='7 7' stroke-linecap='round'%3E%3Crect x='6' y='6' width='108' height='108'/%3E%3Crect x='126' y='6' width='108' height='108'/%3E%3Crect x='6' y='126' width='108' height='108'/%3E%3Crect x='126' y='126' width='108' height='108'/%3E%3C/g%3E%3Cg fill='%23f2b24a' fill-opacity='.2'%3E%3Cpath d='M60 44l5 10 11 1.6-8 7.8 1.9 11L60 69l-9.9 5.4 1.9-11-8-7.8 11-1.6z'/%3E%3Cpath d='M180 164c-14-10-12-22-4-22 3 0 4 3 4 3s1-3 4-3c8 0 10 12-4 22z'/%3E%3C/g%3E%3Cg fill='%23e0574a' fill-opacity='.22'%3E%3Ccircle cx='180' cy='60' r='9'/%3E%3Ccircle cx='60' cy='180' r='9'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 240px 240px;
  transform: translate3d(var(--px, 0), var(--py, 0), 0) scale(1.06);
  transition: transform .9s cubic-bezier(.2, .7, .2, 1);
  will-change: transform;
}
.backdrop-shade {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(90% 60% at 15% 0%, rgba(242, 178, 74, .16), transparent 70%),
    radial-gradient(70% 50% at 100% 100%, rgba(224, 87, 74, .14), transparent 70%),
    radial-gradient(130% 100% at 50% 0%, rgba(28, 17, 11, .28) 0%, rgba(28, 17, 11, .82) 70%, #1c110b 100%);
}
#snow {
  position: fixed;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Layout ---------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2.5rem) 8rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem 0 1.25rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  gap: .6rem;
  color: var(--ink);
  font: 600 1.15rem var(--display);
  letter-spacing: .02em;
  text-decoration: none;
}
.brand-mark {
  position: relative; overflow: hidden;
  width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-hi), var(--gold));
  color: var(--gold-ink);
  font-size: 0; /* the glyph inside is only a fallback; the bear is drawn below */
  background: #4a2c18;
  border: 2px solid var(--gold);
  box-shadow: 0 6px 18px -6px rgba(242, 178, 74, .7);
}
.back {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: .5rem .25rem;
}
.back:focus-visible { color: var(--gold-hi); }
@media (hover: hover) { .back:hover { color: var(--gold-hi); } }

.eyebrow {
  margin: 0 0 .9rem;
  color: var(--gold);
  font: 700 .9rem var(--body);
  letter-spacing: .22em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.1; margin: 0; letter-spacing: -.01em; }

/* ---------- Glass ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 3.4rem;
  padding: .75rem 1.7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: 700 1.1rem var(--body);
  color: var(--gold-ink);
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
  box-shadow: 0 10px 26px -10px rgba(242, 178, 74, .75), 0 1px 0 rgba(255, 255, 255, .6) inset;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}
@media (hover: hover) { .btn:hover { transform: translateY(-2px); filter: brightness(1.05); } }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, .08);
  border-color: var(--line);
  box-shadow: none;
}
.btn:focus-visible, .tile:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--gold-hi);
  outline-offset: 3px;
}

/* ---------- Snow switch + teddy buddy ---------- */
.snow-toggle {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 20;
  min-height: 2.75rem;
  padding: .45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--muted);
  font: 600 .95rem var(--body);
  cursor: pointer;
}
.snow-toggle[aria-pressed="true"] { color: var(--gold-hi); border-color: var(--line-hi); }
.snow-toggle.in-bar { position: static; flex: none; }
.bar-tools { display: flex; align-items: center; gap: .5rem; flex: none; }
@media (max-width: 700px) {
  .snow-toggle .snow-label { display: none; }
  .snow-toggle { width: 2.75rem; padding: 0; font-size: 1.15rem; }
  .brand { font-size: 1.02rem; }
  .buddy { width: 96px; }
}

.buddy {
  position: fixed;
  right: clamp(.5rem, 3vw, 2.5rem);
  bottom: 0;
  z-index: 15;
  width: clamp(100px, 12vw, 140px);
  cursor: pointer;
  border: 0;
  padding: 0;
  background: none;
  transform: translateY(46%);
  translate: var(--px, 0px) 0;
  animation: buddy-in 1.1s .6s cubic-bezier(.2, 1.3, .4, 1) backwards;
  transition: transform .45s cubic-bezier(.2, 1.2, .4, 1);
  -webkit-tap-highlight-color: transparent;
}
.buddy svg { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 100%; }
.buddy .pupils { transition: transform .12s ease-out; }
@media (hover: hover) { .buddy:hover { transform: translateY(30%); } }
.buddy.run { transform: translateY(8%); }
.buddy.tucked { transform: translateY(105%); }
.buddy.run svg { animation: buddy-waddle .38s ease-in-out infinite; }
.buddy.asleep { transform: translateY(56%); }
.buddy.asleep .eyes { animation: none; transform: scaleY(.08); }
.buddy-zzz {
  position: absolute; right: 8%; bottom: 80%;
  font: 800 1rem var(--body); letter-spacing: .15em; color: var(--muted);
  opacity: 0; pointer-events: none;
}
.buddy.asleep .buddy-zzz { opacity: .9; animation: buddy-zzz 3s ease-in-out infinite; }
.buddy.hop { animation: buddy-hop .6s ease; }
.buddy-bubble {
  position: absolute;
  right: 62%;
  bottom: 70%;
  padding: .4rem .95rem;
  border-radius: 18px 18px 4px 18px;
  background: #fff;
  color: #3a1f06;
  font: 800 1.1rem var(--body);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px) scale(.8);
  transition: opacity .2s, transform .25s cubic-bezier(.2, 1.5, .4, 1);
  pointer-events: none;
}
.buddy.talk .buddy-bubble { opacity: 1; transform: none; }
.buddy .arm-r { transform-origin: 152px 144px; }
.buddy.talk .arm-r, .buddy:focus-visible .arm-r { animation: buddy-wave .5s ease-in-out 3; }
.buddy .eyes { transform-origin: 100px 88px; animation: buddy-blink 5.5s infinite; }
.buddy .ear-l { transform-origin: 56px 56px; animation: buddy-ear 6s ease-in-out infinite; }
.buddy .ear-r { transform-origin: 144px 56px; animation: buddy-ear 6s 2.2s ease-in-out infinite reverse; }

@keyframes buddy-in { from { transform: translateY(110%); } to { transform: translateY(46%); } }
@keyframes buddy-hop { 0%,100% { transform: translateY(46%); } 40% { transform: translateY(20%); } }
@keyframes buddy-waddle { 0%,100% { transform: translateY(0) rotate(-5deg); } 50% { transform: translateY(-7%) rotate(5deg); } }
@keyframes buddy-zzz { 0%,100% { transform: translateY(4px); opacity: .3; } 50% { transform: translateY(-6px); opacity: .9; } }
@keyframes buddy-wave { 0%,100% { transform: rotate(0); } 50% { transform: rotate(-38deg); } }
@keyframes buddy-blink { 0%,94%,100% { transform: scaleY(1); } 97% { transform: scaleY(.08); } }
@keyframes buddy-ear { 0%,88%,100% { transform: rotate(0); } 92% { transform: rotate(-7deg); } 96% { transform: rotate(3deg); } }

/* ---------- Entrance + reduced motion ---------- */
.rise { opacity: 0; transform: translateY(18px); animation: rise .8s cubic-bezier(.2, .7, .2, 1) forwards; animation-delay: calc(var(--i, 0) * 90ms + 120ms); }
@keyframes rise { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .buddy { transform: translateY(46%); }
  .rise { opacity: 1; transform: none; }
  .backdrop { transition: none; }
}

.brand-mark::after { content: ""; position: absolute; inset: 0; background: url("/shared/img/favicon.svg") center 55% / 128% no-repeat; }
