/* ===== QUIRKS - Design System ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

:root {
  /* Surface colors - warm museum-paper light theme */
  --bg: #faf9f6;
  --bg-elevated: #ffffff;
  --bg-card: rgba(0,0,0,0.025);
  --bg-glass: rgba(255,255,255,0.7);

  /* Text - Apple-style neutral, not pure black */
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;

  /* Accents - indigo for "mind", amber for "warmth" */
  --accent: #5856d6;
  --accent-dim: rgba(88,86,214,0.10);
  --accent-2: #bf5af2;            /* gradient companion to --accent (violet) */
  --accent2: #d4860f;
  --accent2-dim: rgba(212,134,15,0.10);

  /* Status */
  --success: #34c759;
  --danger: #ff3b30;

  /* Structure */
  --border: rgba(0,0,0,0.08);
  --border-hover: rgba(0,0,0,0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 100px;

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Motion */
  --transition: 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* Glow */
  --glow: 0 0 40px rgba(88,86,214,0.12);

  /* Layout */
  --max-w: 1400px;
  --max-w-text: 720px;
  --nav-h: 64px;
  --nav-bg: rgba(250,249,246,0.72);
}

[data-theme="dark"] {
  --bg: #07070a;
  --bg-elevated: #15151a;
  --bg-card: rgba(255,255,255,0.04);
  --bg-glass: rgba(255,255,255,0.06);

  --text: #f5f5f7;
  --text-secondary: #98989d;
  --text-tertiary: #5e5e63;

  --accent: #7270ee;
  --accent-dim: rgba(114,112,238,0.15);
  --accent-2: #d97aff;
  --accent2: #f0a83c;
  --accent2-dim: rgba(240,168,60,0.15);

  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.16);

  --glow: 0 0 40px rgba(114,112,238,0.18);

  --nav-bg: rgba(7,7,10,0.72);
}

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.78; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; color: var(--text); }

/* Keyboard-only focus ring. Uses :focus-visible so mouse clicks don't
   leave focus halos on every button, but tab/arrow keyboard navigation
   gets a clear, accessible outline in the page's accent color. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
/* Rounded controls get a softer ring shape that respects their radius. */
button:focus-visible,
.bl-option:focus-visible,
.jr-option:focus-visible,
.cb-option:focus-visible,
.cb-confidence-btn:focus-visible,
.wys-toggle-btn:focus-visible,
.wys-input:focus-visible,
.wys-action:focus-visible,
.bl-cta-primary:focus-visible,
.bl-cta-secondary:focus-visible,
.bl-next:focus-visible,
.jr-next:focus-visible,
.jr-action:focus-visible,
.cb-next:focus-visible,
.cb-action:focus-visible,
.next-room-card:focus-visible,
.room-card:focus-visible,
.nav-logo:focus-visible,
.theme-toggle:focus-visible {
  outline-offset: 3px;
  outline-color: var(--accent);
}
/* Remove the default browser focus on mouse click. */
:focus:not(:focus-visible) { outline: none; }

/* ===== NAV ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 48px);
  background: var(--nav-bg);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.nav-logo {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
  background: linear-gradient(135deg, var(--accent) 0%, #8b89e8 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
[data-theme="dark"] .nav-logo {
  background: linear-gradient(135deg, var(--accent) 0%, #b0aef5 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-links { display: flex; gap: 28px; align-items: center; }
.nav-links a { color: var(--text-secondary); font-size: 0.9rem; font-weight: 500; transition: color var(--transition); }
.nav-links a:hover { color: var(--text); opacity: 1; }
.nav-links a[aria-current="page"] { color: var(--text); }

/* Theme Toggle */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
/* Show the icon for the theme you'd switch TO. On light theme show the moon
   (click to go dark); on dark theme show the sun (click to go light). */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ===== HERO ===== */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: calc(var(--nav-h) + 60px) 24px 60px;
  overflow: hidden;
}
.hero-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.hero-content { position: relative; z-index: 1; max-width: 820px; }
.hero-title {
  font-size: clamp(2rem, 8vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  background: linear-gradient(45deg, #5856d6, #bf5af2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 24px;
}
[data-theme="dark"] .hero-title {
  background: linear-gradient(45deg, #7270ee, #d97aff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-subtitle {
  font-weight: 500;
  color: var(--text);
  max-width: 760px;
  display: inline-block;
  line-height: 1.4;
  margin: 0 auto 32px;
  font-size: clamp(1.05rem, 2.4vw, 1.45rem);
}
.hero-meta {
  font-size: 0.85rem; color: var(--text-tertiary);
  letter-spacing: 0.02em;
}

/* ===== ROOMS GRID (lobby) ===== */
.rooms {
  padding: clamp(40px, 6vw, 80px) clamp(20px, 4vw, 48px) 80px;
  max-width: var(--max-w);
  margin: 0 auto;
}
.rooms-intro {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 48px;
}
.rooms-intro h2 {
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.rooms-intro p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.6;
}
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
/* Room cards - apple-card pattern, image area + content area */
.room-card {
  display: flex; flex-direction: column;
  height: 440px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.05);
}
[data-theme="dark"] .room-card {
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.room-card--ready { cursor: pointer; }
.room-card--ready:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(88,86,214,0.12);
  border-color: rgba(88,86,214,0.2);
}
.room-card--soon { opacity: 0.6; cursor: default; }

/* Completed-in-this-session marker. Subtle - a small chip in the corner
   of the room image. Set by /js/core/init.js when the module's storage
   shows a finished run. */
.room-card--completed { position: relative; }
.room-card--completed::after {
  content: 'Completed';
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 4px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-pill);
  pointer-events: none;
}
[data-theme="dark"] .room-card--completed::after {
  background: rgba(255,255,255,0.16);
}

.room-image {
  width: 100%;
  height: 60%;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #5856d6 0%, #bf5af2 100%);
}
/* Placeholder gradient + emoji sits behind the real image. When the real
   image loads, it overlays the placeholder. If the image is missing /
   404s, the onerror handler removes it and we fall back to placeholder. */
.room-image-placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 5rem;
  background: linear-gradient(135deg, var(--placeholder-from, #5856d6) 0%, var(--placeholder-to, #bf5af2) 100%);
  transition: transform 0.5s ease;
  z-index: 0;
}
.room-image img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s ease;
  z-index: 1;
}
.room-card--ready:hover .room-image img,
.room-card--ready:hover .room-image-placeholder { transform: scale(1.05); }

.room-content {
  padding: 24px 26px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}
.room-title {
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
  color: var(--text);
}
.room-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 auto;
}
.room-cta {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 18px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.01em;
  transition: gap var(--transition);
}
.room-card--ready:hover .room-cta { gap: 10px; }
.room-card--soon .room-cta { color: var(--text-tertiary); }

@media (max-width: 540px) {
  .room-card { height: 380px; }
  .room-image-placeholder { font-size: 4rem; }
}

/* ===== SECTIONS (used inside modules) ===== */
.section {
  position: relative;
  padding: clamp(80px, 10vw, 120px) clamp(20px, 4vw, 48px);
  max-width: var(--max-w);
  margin: 0 auto;
}
.section--text { max-width: var(--max-w-text); }
.section-header {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 56px;
}
.section-step {
  display: inline-block;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 14px;
}
.section-title {
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  font-weight: 700; letter-spacing: -0.02em; line-height: 1.12;
  margin-bottom: 16px;
}
.section-desc {
  font-size: clamp(0.98rem, 1.8vw, 1.1rem);
  color: var(--text-secondary);
  line-height: 1.65;
}
.section-note {
  max-width: 640px;
  margin: 36px auto 0;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.65;
  font-style: italic;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 32px;
  font-family: var(--font);
  font-size: 1rem; font-weight: 600;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 60px rgba(88,86,214,0.22); }
.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ===== NEXT ROOMS (shared across all results screens) =====
   Renders full lobby-style .room-card.room-card--ready elements
   (defined above), wrapped in a .rooms-grid so the layout matches
   the home page exactly. This section just adds the heading + width
   constraints - the card visuals come from the lobby styles. */
.next-rooms {
  max-width: var(--max-w);
  margin: 56px auto 0;
  padding: 0 clamp(16px, 4vw, 48px);
}
.next-rooms-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-secondary);
  margin-bottom: 20px;
  text-align: center;
}

/* ===== FOOTER ===== */
.footer {
  position: relative;
  margin-top: 80px;
  padding: 28px clamp(20px, 4vw, 48px);
  border-top: 1px solid var(--border);
  text-align: center;
  overflow: hidden;
  min-height: 96px;
}
.footer-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.footer-inner {
  position: relative; z-index: 1;
  display: flex; justify-content: center; align-items: center;
  min-height: 40px;
}
.footer-phrase {
  display: inline-block;
  padding: 8px 24px;
  background: rgba(255,255,255,0.78);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.88rem; font-weight: 500;
  color: var(--text);
  letter-spacing: 0.01em;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 18px rgba(0,0,0,0.04);
  max-width: 92%;
}
[data-theme="dark"] .footer-phrase {
  background: rgba(20,20,22,0.78);
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}

/* ===== ABOUT PAGE ===== */
.about-hero {
  position: relative;
  min-height: 42vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  padding: calc(var(--nav-h) + 60px) 24px 40px;
  overflow: hidden;
}
.about-content {
  max-width: var(--max-w-text);
  margin: 0 auto;
  padding: 0 24px 80px;
}
.about-content p {
  color: var(--text-secondary); line-height: 1.8;
  margin-bottom: 22px;
  font-size: 1.05rem;
}
.about-content em { color: var(--text); font-style: italic; }
.about-content h2 {
  font-size: 1.3rem; font-weight: 600;
  margin: 56px 0 16px;
  letter-spacing: -0.01em;
}

/* Other-project cards (about page) */
.project-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 32px;
}
@media (min-width: 720px) {
  .project-cards { grid-template-columns: 1fr 1fr; }
}
.project-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 24px 28px;
  border-radius: var(--radius);
  text-decoration: none;
  background: linear-gradient(135deg, #1b1e2e 0%, #2d324d 100%);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  position: relative; overflow: hidden;
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.project-card:hover {
  transform: translateY(-3px);
  border-color: rgba(88,86,214,0.4);
  box-shadow: 0 16px 36px rgba(0,0,0,0.32);
}
.project-card-content { flex: 1; min-width: 0; }
.project-card h3 {
  font-size: 1.05rem; font-weight: 600;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #8b89e8 0%, #c0bef5 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.project-card p {
  font-size: 0.88rem; color: #a1a1a6; line-height: 1.5;
  margin: 0;
}
.project-card-arrow {
  flex-shrink: 0;
  width: 22px; height: 22px;
  color: #8b89e8;
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.project-card:hover .project-card-arrow {
  transform: translate(3px, -3px);
}

/* ===== HIDDEN / UTIL ===== */
.hidden { display: none !important; }
.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;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 540px) {
  .nav-links { gap: 18px; }
  .nav-links a { font-size: 0.85rem; }
  .rooms-grid { grid-template-columns: 1fr; }
}
