/* ==========================================================================
   TOKENS & 5-AGE EDITORIAL COLLAGE PALETTES v2.0 (WITH WINDOW LIGHT ATMOSPHERE)
   ========================================================================== */

:root {
  --paper-bg: #f5efe4;
  --paper-card: #fbf8f1;
  --paper-warm: #efe6d5;
  --paper-edge: #dfd4be;
  --ink-primary: #2c2621;
  --ink-secondary: #5c534a;
  --ink-muted: #8b8074;
  --ink-faint: #b6aa9c;

  --accent: #c86d51;
  --accent-soft: #e8cfc3;
  --accent-deep: #9c4a33;
  --sage: #6f8672;
  --sage-soft: #dce5dc;
  --gold: #c99a45;
  --gold-soft: #f2e4c2;
  --emotion-ink: #5a4e73;
  --emotion-bg: #ebe5f2;
  --emotion-border: #b8a8cf;
  --danger: #b84a39;

  --tape-1: rgba(215, 195, 148, 0.72);
  --tape-2: rgba(154, 177, 159, 0.65);
  --tape-3: rgba(214, 149, 130, 0.62);

  --case-shell: #b89166;
  --case-shell-dark: #8c6943;
  --case-lining: #f1e8d9;
  --case-grid-line: rgba(110, 92, 72, 0.22);
  --case-cell-bg: rgba(255, 252, 245, 0.56);

  --font-serif: "Noto Serif TC", "Songti TC", "Hiragino Mincho ProN", Georgia, serif;
  --font-sans: "Noto Sans TC", "PingFang TC", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, monospace;

  --cell-size: 60px;
  --cell-gap: 4px;

  --shadow-paper: 0 2px 8px rgba(44, 38, 33, 0.07), 0 1px 2px rgba(44, 38, 33, 0.05);
  --shadow-card: 0 12px 32px rgba(44, 38, 33, 0.1), 0 2px 6px rgba(44, 38, 33, 0.05);
  --shadow-lift: 0 20px 42px rgba(44, 38, 33, 0.22), 0 6px 14px rgba(44, 38, 33, 0.12);

  --radius-sm: 4px;
  --radius-md: 11px;
  --radius-lg: 18px;
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Age 18: Sunlit Dorm Canvas & Butter Yellow */
body[data-age="18"] {
  --paper-bg: #f6f0e2;
  --accent: #c96f4b;
  --accent-soft: #f0d7c7;
  --accent-deep: #9c4d2e;
  --case-shell: #b48a5a;
  --case-shell-dark: #856038;
  --case-lining: #f3ebd8;
  --tape-1: rgba(232, 203, 129, 0.72);
  --tape-2: rgba(145, 174, 189, 0.62);
}

/* Age 22: First Job Cool Slate & Scuffed Teal */
body[data-age="22"] {
  --paper-bg: #eef1ef;
  --paper-card: #f8faf8;
  --paper-warm: #e2e8e4;
  --accent: #4c727d;
  --accent-soft: #cde0e5;
  --accent-deep: #325059;
  --case-shell: #5c7d87;
  --case-shell-dark: #3d5760;
  --case-lining: #e8efee;
  --tape-1: rgba(143, 176, 184, 0.65);
  --tape-2: rgba(214, 174, 138, 0.64);
}

/* Age 26: 3AM Breakup Rain — Twilight Indigo & Dried Rose */
body[data-age="26"] {
  --paper-bg: #e9e6ec;
  --paper-card: #f6f4f8;
  --paper-warm: #dfdae4;
  --ink-primary: #27232d;
  --ink-secondary: #564f61;
  --accent: #8f5c6e;
  --accent-soft: #e4cfd7;
  --accent-deep: #663d4c;
  --case-shell: #4e5369;
  --case-shell-dark: #34384a;
  --case-lining: #e8e5ee;
  --tape-1: rgba(173, 147, 168, 0.64);
  --tape-2: rgba(133, 147, 173, 0.62);
}

/* Age 30: Career Pivot — Dusk Ochre & Brushed Aluminum */
body[data-age="30"] {
  --paper-bg: #f1ebe1;
  --paper-card: #faf7f2;
  --paper-warm: #e7ded0;
  --accent: #a66a3c;
  --accent-soft: #ebd6c3;
  --accent-deep: #7a4a24;
  --case-shell: #7a7772;
  --case-shell-dark: #54514d;
  --case-lining: #eeeae4;
  --tape-1: rgba(196, 155, 110, 0.68);
  --tape-2: rgba(146, 156, 138, 0.64);
}

/* Age 35: Settling Home — Golden Hour Cedar & Sage */
body[data-age="35"] {
  --paper-bg: #f6f1e6;
  --paper-card: #fdfbf5;
  --paper-warm: #efe5d5;
  --accent: #5e7a63;
  --accent-soft: #d7e4d8;
  --accent-deep: #3f5944;
  --case-shell: #945d3a;
  --case-shell-dark: #683d22;
  --case-lining: #f5ecdc;
  --tape-1: rgba(154, 179, 154, 0.68);
  --tape-2: rgba(217, 184, 126, 0.72);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--paper-bg);
  color: var(--ink-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.8s ease;
}

/* Subtle linen desk mat pattern across background */
body {
  background-image:
    radial-gradient(rgba(120, 104, 86, 0.055) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 252, 245, 0.35), rgba(44, 38, 33, 0.03));
  background-size: 20px 20px, 100% 100%;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
.hidden { display: none !important; }

.paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 240 240' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.18'/%3E%3C/svg%3E");
}

/* 5-Age Window Light & Weather Atmosphere */
.ambient-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

body[data-age="18"] .ambient-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(122deg, rgba(255, 236, 178, 0.24) 0%, rgba(255, 236, 178, 0) 48%);
}

body[data-age="26"] .ambient-layer::before {
  content: "";
  position: absolute;
  inset: -40px;
  background-image: repeating-linear-gradient(
    102deg,
    transparent 0,
    transparent 34px,
    rgba(108, 120, 158, 0.065) 34px,
    rgba(108, 120, 158, 0.065) 35px
  );
  animation: rainDrift 2.4s linear infinite;
}

body[data-age="30"] .ambient-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(227, 174, 114, 0.16) 0%, transparent 52%);
}

body[data-age="35"] .ambient-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 86% 12%, rgba(255, 224, 152, 0.28), transparent 55%);
}

@keyframes rainDrift {
  from { transform: translateY(-28px) translateX(-8px); }
  to { transform: translateY(28px) translateX(8px); }
}

.washi-tape {
  position: absolute;
  width: 88px;
  height: 24px;
  background: var(--tape-1);
  pointer-events: none;
  z-index: 6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  clip-path: polygon(
    2% 4%, 98% 0%, 100% 25%, 97% 50%, 100% 78%, 97% 100%,
    3% 96%, 0% 72%, 2% 48%, 0% 22%
  );
}

.tape-top-left { top: -11px; left: 26px; transform: rotate(-6deg); background: var(--tape-1); }
.tape-top-right { top: -10px; right: 28px; transform: rotate(5deg); background: var(--tape-2); }
.tape-bottom-right { bottom: -10px; right: 44px; transform: rotate(-4deg); background: var(--tape-3); }
.tape-center-top { top: -12px; left: 50%; transform: translateX(-50%) rotate(-1.5deg); width: 108px; }
.tape-inspector { top: -11px; right: 24px; transform: rotate(4deg); width: 76px; background: var(--tape-2); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 26px;
  background: var(--ink-primary);
  color: #faf6ee;
  border-radius: 999px;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.04em;
  box-shadow: 0 6px 18px rgba(44, 38, 33, 0.18);
  transition: transform 0.2s var(--ease-spring), background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(44, 38, 33, 0.22);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--paper-card);
  color: var(--ink-primary);
  border: 1.5px solid var(--paper-edge);
  border-radius: 999px;
  font-weight: 500;
  font-size: 13.5px;
  transition: transform 0.2s var(--ease-spring), border-color 0.2s ease, background-color 0.2s ease;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  background: #fffdf8;
  transform: translateY(-1px);
}

.screen {
  display: none;
  position: relative;
  z-index: 2;
  min-height: 100vh;
}

.screen.active {
  display: flex;
  animation: fadeScreen 0.45s var(--ease-spring);
}

@keyframes fadeScreen {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1360px) { :root { --cell-size: 52px; } }
@media (max-width: 1120px) { :root { --cell-size: 44px; } }
