:root {
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --radius: 13px;
}

/* ── themes ─────────────────────────────────────────────────── */
html[data-theme="dark"] {            /* Rosé Pine */
  --bg: #191724; --surface: #1f1d2e; --overlay: #26233a;
  --text: #e0def4; --muted: #908caa; --subtle: #6e6a86;
  --line: #2a2740;
  --accent: #c4a7e7; --ok: #9ccfd8; --warn: #f6c177; --rose: #ebbcba; --love: #eb6f92; --pine: #3e8fb0;
  --kbd-bg: #26233a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
html[data-theme="light"] {           /* Periwinkle */
  --bg: #f2f3fc; --surface: #e9ebfa; --overlay: #e2e4f6;
  --text: #45456a; --muted: #6c6b93; --subtle: #8d8cb0;
  --line: #dde0f4;
  --accent: #6c63d8; --ok: #3f8fa6; --warn: #bd7b2c; --rose: #b5658f; --love: #d24f7a; --pine: #2f6f86;
  --kbd-bg: #e2e4f6;
  --shadow: 0 24px 60px rgba(70, 70, 120, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: clamp(8px, 3vw, 40px);
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}
/* a calm warm wash behind the window — the cozy opposite of dread-rain */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(58% 50% at 50% 30%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 72%);
}

/* ── the macOS window ───────────────────────────────────────── */
.window {
  position: relative; z-index: 1;
  width: min(960px, 92vw);
  height: min(82svh, 720px);
  display: flex; flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: width 0.4s ease, height 0.4s ease;
}
/* 🟢 zoom — bigger within the browser (not OS fullscreen) */
.window.zoomed { width: min(1400px, 96vw); height: 94svh; }
.titlebar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.6rem;
  padding: 0.55rem 0.8rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}
.lights { display: flex; gap: 8px; align-items: center; }
.lt {
  width: 12px; height: 12px; border-radius: 50%;
  padding: 0; border: 0; appearance: none; -webkit-appearance: none;
  display: inline-block; cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.lt.r { background: #ff5f57; } .lt.y { background: #febc2e; } .lt.g { background: #28c840; }
.lt:hover { filter: brightness(1.18); transform: scale(1.12); }
.lt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.title {
  text-align: center; font-family: var(--font-ui); font-size: 12.5px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.themebtn {
  justify-self: end; cursor: pointer;
  border: 1px solid var(--line); background: var(--overlay); color: var(--accent);
  border-radius: 999px; width: 30px; height: 30px; line-height: 1; font-size: 15px;
  display: grid; place-items: center;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.themebtn:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); transform: translateY(-1px); }
.themebtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── the scrolling console (output flows top-down; input pins at bottom) ── */
.console { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.term {
  font-size: clamp(13px, 1.1vw + 7px, 15px);
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap; word-break: break-word;
  padding: 14px 16px 0;
  cursor: text;
  -webkit-user-select: text; user-select: text;
}
.cmdline {
  display: flex; align-items: baseline; gap: 0.5ch;
  padding: 2px 16px 14px;
  font-size: clamp(13px, 1.1vw + 7px, 15px);
}
.cmdline .ps { color: var(--accent); white-space: nowrap; }
.cmdline input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  font: inherit; color: var(--text); caret-color: var(--accent);
}

/* ── inline output helpers ──────────────────────────────────── */
.welcome { color: var(--accent); font-weight: 700; }
.kbd {
  font-family: var(--font-mono); background: var(--kbd-bg); color: var(--accent);
  border: 1px solid var(--line); border-radius: 6px; padding: 0 0.4em; font-size: 0.92em;
}
.c-accent { color: var(--accent); } .c-ok { color: var(--ok); } .c-warn { color: var(--warn); }
.c-muted { color: var(--muted); } .c-rose { color: var(--rose); } .c-love { color: var(--love); }
.c-pine { color: var(--pine); } .c-text { color: var(--text); }
.bold { font-weight: 700; }

@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.spark { display: inline-block; animation: pop 0.5s ease; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 2rem; text-align: center; color: var(--accent); z-index: 5; }
.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; }

/* ── the arcade stage (a canvas game replaces the console) ───── */
.game-stage { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.game-hud {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 6px 14px; font-family: var(--font-ui); font-size: 12.5px;
  color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--line);
}
.game-hud-hint { color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-canvas { flex: 1 1 auto; width: 100%; min-height: 0; display: block; touch-action: none; background: var(--bg); }

/* ── 🟡 minimize → a calm, on-theme ambient scene ───────────── */
.ambient {
  position: fixed; inset: 0; z-index: 0; display: none; cursor: pointer; overflow: hidden;
  background: radial-gradient(125% 95% at 50% 120%, color-mix(in srgb, var(--accent) 28%, var(--bg)), var(--bg) 72%);
}
body.minimized .ambient { display: block; }
body.minimized .console, body.minimized .game-stage { display: none; }
body.minimized .window { height: auto; }
.ambient .steam {
  position: absolute; bottom: -40px; width: 130px; height: 60vh; border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 24%, transparent), transparent);
  filter: blur(24px); opacity: 0; animation: steam-rise 9s ease-in-out infinite;
}
.ambient .s0 { left: 30%; animation-delay: 0s; }
.ambient .s1 { left: 50%; animation-delay: 3s; }
.ambient .s2 { left: 68%; animation-delay: 6s; }
@keyframes steam-rise {
  0% { transform: translateY(40px) scaleX(0.8); opacity: 0; }
  40% { opacity: 0.5; }
  100% { transform: translateY(-32vh) scaleX(1.3); opacity: 0; }
}
.ambient .mote {
  position: absolute; bottom: -12px; width: 6px; height: 6px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 70%, var(--text));
  filter: blur(0.5px); opacity: 0;
  animation: mote-rise var(--d, 12s) linear var(--delay, 0s) infinite;
}
@keyframes mote-rise {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: var(--mo, 0.6); }
  86% { opacity: var(--mo, 0.6); }
  100% { transform: translate(var(--dx, 0), -100svh); opacity: 0; }
}
.ambient-hint {
  position: absolute; left: 0; right: 0; bottom: 8%; text-align: center;
  color: var(--muted); font-family: var(--font-ui); font-size: 13px; letter-spacing: 0.02em;
}

/* ── the /root → /cafe crossing ──────────────────────────────────────
   The terminal frame is a shared element across both pages (same
   view-transition-name), so the dread console smoothly resizes + restyles into
   this window — and if the boxes ever matched, it would simply stay put and
   crossfade style. Dark → dark, so no full-screen flash. A soft warm glow
   breathes on the window as it settles: a gentle dawn, not a blow-out. */
@view-transition { navigation: auto; }
.window { view-transition-name: cafe-terminal; }
::view-transition-group(cafe-terminal) {
  animation-duration: 600ms;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: 650ms;
  animation-timing-function: ease;
}
.window.arriving { animation: dawn-settle 1200ms ease both; }
@keyframes dawn-settle {
  0%   { box-shadow: var(--shadow); }
  50%  { box-shadow: var(--shadow), 0 0 60px color-mix(in srgb, var(--warn) 50%, transparent); }
  100% { box-shadow: var(--shadow); }
}

@media (max-width: 560px) {
  .window { width: 94vw; height: min(86svh, 720px); }
  .window.zoomed { width: 98vw; height: 96svh; }
  .title { font-size: 11.5px; }
  body { padding: 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .spark { animation: none; }
  .ambient .mote, .ambient .steam { animation: none; }
  .window.arriving { animation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: 1ms !important; }
  * { transition: none !important; }
}
