/* ============================================================
   CodePossum — the fun layer (fun.css)
   Personality: quips, toasts, secrets, trail, celebrations,
   seasonal ambience, physics, terminal, arcade, playground.
   Client-side only; nothing stored; reduced-motion safe.
   ============================================================ */

/* ---------- Small pill buttons (footer fun controls) ---------- */
.chip-btn {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .82rem;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .2s var(--ease), background .2s var(--ease), color .2s var(--ease);
}
.chip-btn:hover { border-color: var(--blue); color: var(--blue-text); }
.chip-btn[aria-pressed="true"] { background: var(--blue-cta); border-color: var(--blue-cta); color: #fff; }
.fun-controls { display: inline-flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toast-host {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 300; display: grid; gap: 8px; justify-items: center;
  pointer-events: none; width: max-content; max-width: min(92vw, 500px);
}
.toast {
  background: var(--ink); color: #fff;
  border-radius: 14px; padding: 11px 16px;
  font-family: var(--font-display); font-weight: 800; font-size: .9rem;
  box-shadow: var(--shadow-m);
  animation: toast-in .35s var(--ease);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast.is-out { opacity: 0; transform: translateY(10px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@media (prefers-color-scheme: dark) { .toast { color: #0b1322; } }

/* ---------- Quip bubble (the possum speaks) ---------- */
.quip {
  position: absolute; top: -20px; right: -6px; z-index: 6;
  max-width: 255px;
  background: #fff; color: #15181d;
  border: 1px solid var(--line-2);
  border-radius: 16px 16px 16px 5px;
  padding: 12px 15px;
  font-family: var(--font-display); font-weight: 800; font-size: .88rem; line-height: 1.45;
  box-shadow: var(--shadow-m);
  opacity: 0; transform: translateY(8px) scale(.96);
  transition: opacity .3s var(--ease), transform .35s var(--ease);
  pointer-events: none;
}
.quip.is-show { opacity: 1; transform: none; }
.quip::after {
  content: ""; position: absolute; left: 18px; bottom: -8px;
  width: 14px; height: 14px; background: #fff;
  border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2);
  transform: rotate(45deg);
}
@media (max-width: 900px) { .quip { right: 4px; top: -14px; font-size: .82rem; max-width: 210px; } }

/* ---------- Time-of-day greeting ---------- */
.tod-hello { font-family: var(--font-display); font-weight: 900; color: var(--ink); }

/* ---------- Watermark secret ---------- */
.hero-watermark { pointer-events: auto; cursor: pointer; }
.hero-watermark.is-flip { animation: wm-flip .9s var(--ease); }
@keyframes wm-flip { to { rotate: 360deg; } }
@media (prefers-reduced-motion: reduce) { .hero-watermark.is-flip { animation: none; } }

/* ---------- Mascot reactions (compose via rotate/scale props) ---------- */
.hero-art-frame { cursor: pointer; }
.is-boop { animation: boop .5s var(--ease); }
@keyframes boop { 0%, 100% { scale: 1; } 30% { scale: .965; } 62% { scale: 1.018; } }
.is-wiggle { animation: wiggle .8s ease-in-out; }
@keyframes wiggle { 0%, 100% { rotate: 0deg; } 22% { rotate: -1.7deg; } 55% { rotate: 1.3deg; } 80% { rotate: -.5deg; } }

/* ---------- Possum Mode (Konami) ---------- */
.brace-rain {
  position: fixed; top: -48px; z-index: 250;
  font-family: var(--font-display); font-weight: 900;
  color: var(--blue); opacity: .75;
  pointer-events: none; user-select: none;
  animation: brace-fall linear forwards;
}
@keyframes brace-fall { to { transform: translateY(112vh) rotate(320deg); opacity: .15; } }
html.possum-mode .section .container { animation: pm-wobble 2.6s ease-in-out infinite; }
@keyframes pm-wobble { 0%, 100% { rotate: 0deg; } 50% { rotate: .38deg; } }
html.possum-mode .hero-watermark { color: rgba(4, 117, 254, .12); }

/* ---------- Curly-brace cursor trail ---------- */
#funTrail { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 240; }

/* ---------- Confetti + seasonal canvases ---------- */
#funConfetti, #funSeason { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#funConfetti { z-index: 270; }
#funSeason { z-index: 230; }

/* ---------- Grab & fling ---------- */
.draggable { touch-action: none; cursor: grab; }
.draggable.is-dragging { cursor: grabbing; animation-play-state: paused !important; user-select: none; }

/* ---------- Terminal (about page) ---------- */
.term-window {
  background: #0a1020;
  border: 1px solid rgba(120, 160, 230, .22);
  border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-l);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.term-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: rgba(255, 255, 255, .05); border-bottom: 1px solid rgba(120, 160, 230, .14); }
.term-bar span { width: 9px; height: 9px; border-radius: 50%; background: #3a4a66; }
.term-bar span:first-child { background: #f3b6b0; }
.term-bar span:nth-child(2) { background: #f6d7a8; }
.term-bar span:nth-child(3) { background: #a8e2bd; }
.term-bar em { margin-left: 8px; font-style: normal; font-size: .78rem; color: #7f93b5; }
.term-body { padding: 16px 18px; min-height: 200px; max-height: 330px; overflow-y: auto; display: grid; gap: 8px; align-content: start; font-size: .86rem; line-height: 1.65; color: #c6d4ea; }
.term-line { margin: 0; white-space: pre-wrap; }
.term-line b { color: #7fb2ff; }
.term-line .term-ok { color: #7ee2a8; }
.term-input-row { display: flex; align-items: center; gap: 9px; padding: 0 18px 14px; color: #7fb2ff; font-size: .9rem; }
.term-input-row input { flex: 1; background: transparent; border: 0; outline: none; color: #eaf1fb; font: inherit; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; padding: 6px 0; }
.term-input-row input:focus-visible { outline: 2px solid rgba(127, 178, 255, .6); outline-offset: 2px; border-radius: 4px; }
.term-input-row input::placeholder { color: #5b6c8c; }
.term-chips { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 18px 16px; }
.term-chips button {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: .78rem;
  background: rgba(127, 178, 255, .12); border: 1px solid rgba(127, 178, 255, .3);
  color: #9cc2ff; border-radius: 999px; padding: 5px 11px; cursor: pointer;
}
.term-chips button:hover { background: rgba(127, 178, 255, .22); }

/* ---------- Arcade (404) ---------- */
.arcade-wrap { display: grid; gap: 14px; }
.arcade-hud { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; font-family: var(--font-display); font-weight: 800; }
.arcade-hud .arcade-score { font-size: 1.05rem; }
.arcade-canvas {
  width: 100%; height: 360px; display: block; touch-action: none;
  border-radius: 18px; border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--mist), var(--mist-2));
}
@media (max-width: 700px) { .arcade-canvas { height: 300px; } }
.arcade-note { color: var(--muted); font-size: .9rem; }

/* ---------- Playground ---------- */
.lab-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 980px) { .lab-grid { grid-template-columns: 1fr; } }
.lab-card {
  background: #fff; border: 1px solid var(--line); border-radius: 24px;
  padding: clamp(20px, 2.6vw, 28px); display: grid; gap: 14px; align-content: start;
  box-shadow: var(--shadow-s);
}
.lab-card--wide { grid-column: 1 / -1; }
.lab-card h2 { font-size: 1.18rem; }
.lab-card > p { color: var(--muted); font-size: .94rem; }
.lab-fluid { width: 100%; height: 320px; border-radius: 14px; background: var(--mist); border: 1px solid var(--line); display: block; cursor: crosshair; }
.lab-trail { width: 100%; height: 230px; border-radius: 14px; background: var(--mist); border: 1px solid var(--line); display: block; touch-action: none; }
.lab-controls { display: grid; gap: 10px; }
.lab-row { display: grid; grid-template-columns: 130px 1fr 58px; gap: 10px; align-items: center; font-size: .86rem; font-weight: 700; }
.lab-row input[type="range"] { width: 100%; accent-color: var(--blue-cta); }
.lab-row output { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; color: var(--muted); text-align: right; }
.lab-track { height: 140px; overflow-y: auto; border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--mist); }
.lab-track-inner { transform: skewY(var(--labskew, 0deg)); transform-origin: 50% 50%; }
.lab-track-inner p { margin-bottom: 12px; color: var(--muted); }
.lab-track-inner strong { color: var(--ink); }
.lab-type-out { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.35rem, 2.8vw, 2rem); line-height: 1.25; font-variation-settings: 'wght' 700; }
.lab-type-in { width: 100%; border: 1.5px solid var(--line-2); border-radius: 12px; background: var(--mist); color: var(--ink); padding: 11px 13px; }
.lab-type-in:focus-visible { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(4, 117, 254, .16); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { width: 62px; height: 62px; border-radius: 14px; border: 1px solid var(--line-2); cursor: pointer; position: relative; padding: 0; }
.swatch[aria-pressed="true"]::after {
  content: "\2713"; position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 1.1rem; text-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}
.lab-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lab-note { font-size: .84rem; color: var(--muted); }

/* ---------- Explorer thank-you dialog ---------- */
.fun-dialog {
  border: 0; border-radius: 24px; padding: clamp(24px, 4vw, 38px);
  max-width: 480px; width: calc(100vw - 40px);
  background: #fff; color: var(--ink); box-shadow: var(--shadow-l);
}
.fun-dialog::backdrop { background: rgba(4, 16, 36, .55); }
.fun-dialog h2 { font-size: 1.5rem; }
.fun-dialog p { margin-top: 12px; color: var(--muted); }
.fun-dialog .btn { margin-top: 20px; }
@media (prefers-color-scheme: dark) {
  .fun-dialog { background: #0d1626; }
  .lab-card { background: #0d1626; }
  .lab-type-in { background: #101b2f; }
  .lab-track { background: #101b2f; }
}

/* ---------- Time-of-day aurora warmth ---------- */
html[data-daypart="evening"] .aurora i:nth-child(1) {
  background: radial-gradient(circle at 35% 35%, rgba(4, 117, 254, .30), rgba(255, 152, 96, .15) 58%, transparent 76%);
}
html[data-daypart="night"] .aurora i:nth-child(1) {
  background: radial-gradient(circle at 35% 35%, rgba(64, 112, 220, .34), rgba(128, 96, 208, .16) 58%, transparent 78%);
}

/* ---------- Reduced motion: quiet everything that is ours ---------- */
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .quip { transition: none; }
  .is-boop, .is-wiggle, html.possum-mode .section .container { animation: none; }
  .brace-rain { display: none; }
  #funTrail { display: none; }
}
