/*
  YoursCalmly — shared stylesheet
  ------------------------------------------------------------
  Design intent: warm, adult, calm. Large text, large tap targets,
  low visual noise, strong contrast, reduced-motion friendly.
  All pages (home + games) load this single stylesheet.
*/

/* ---------- Design tokens ---------- */
:root {
  /* Clean white base — warmth comes from the icons/accents, not the page */
  --color-bg: #FFFFFF;
  --color-bg-soft: #F6F0E4;
  --color-surface: #FFFFFF;
  --color-surface-alt: #FBF8F2;
  --color-border: #E4D8C2;
  --color-border-strong: #C6B491;

  /* Text */
  --color-text: #2A241D;
  --color-text-muted: #5A5142;
  --color-text-on-accent: #FFFFFF;

  /* Accents — matched to the logo mark: warm ring-brown + wave-teal */
  --color-primary: #7C6A4A;       /* logo ring brown — primary actions */
  --color-primary-hover: #5E5036;
  --color-primary-tint: #EDE7D9;
  --color-accent: #4F7A82;        /* logo wave teal — secondary accent */
  --color-accent-tint: #E1EAEB;
  --color-gold: #C2903F;          /* logo sun gold — decorative accent */

  /* Wordmark colors — same values as the accents above, kept as aliases */
  --logo-ring: var(--color-primary);
  --logo-wave: var(--color-accent);

  /* Feedback */
  --color-success-bg: #E5EADD;
  --color-success-text: #3C4E34;
  --color-success-border: #B9C7A9;
  --color-gentle-bg: #EFE6D2;
  --color-gentle-text: #665B3E;
  --color-gentle-border: #D7C79E;

  /* Focus ring — high-contrast, distinct from palette so it is always visible */
  --color-focus: #1D5C8A;

  /* Type scale (mobile-first; large by default) */
  --fs-body: 1.15rem;
  --fs-lead: 1.3rem;
  --fs-small: 1rem;
  --fs-h1: clamp(2rem, 5vw + 1rem, 3.2rem);
  --fs-h2: clamp(1.6rem, 3vw + 1rem, 2.3rem);
  --fs-h3: clamp(1.3rem, 2vw + 1rem, 1.7rem);
  --fs-card-title: 1.3rem;

  --line-height-body: 1.65;
  --line-height-tight: 1.25;

  --font-heading: Georgia, 'Iowan Old Style', 'Noto Serif', 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Spacing scale */
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1.25rem;
  --space-4: 1.75rem;
  --space-5: 2.5rem;
  --space-6: 3.5rem;
  --space-7: 5rem;

  /* Shape — moderate, adult rounding rather than full "pill" bubbliness */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-btn: 10px;
  --shadow-soft: 0 4px 14px rgba(42, 36, 29, 0.1);
  --shadow-card: 0 1px 6px rgba(42, 36, 29, 0.07);

  --max-width: 1080px;
  --tap-min: 56px;

  --transition-fast: 160ms ease;
  --transition-medium: 240ms ease;
}

/* Dark mode kept gentle and optional — respects OS preference, still warm not cold */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #221E19;
    --color-bg-soft: #2A251F;
    --color-surface: #2E2822;
    --color-surface-alt: #332C25;
    --color-border: #453C31;
    --color-border-strong: #5A4E3D;

    --color-text: #F3ECE0;
    --color-text-muted: #CBBFA9;

    --color-primary: #C9B48C;
    --color-primary-hover: #D9C6A0;
    --color-primary-tint: #362F22;

    --color-accent: #7FB0B8;
    --color-accent-tint: #24302F;
    --color-gold: #E0B36B;

    --logo-ring: var(--color-primary);
    --logo-wave: var(--color-accent);

    --color-success-bg: #29352A;
    --color-success-text: #B7D8AF;
    --color-success-border: #445642;

    --color-gentle-bg: #362F22;
    --color-gentle-text: #E4D3A5;
    --color-gentle-border: #564A31;

    --color-focus: #6FB6E8;
    --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.3);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--line-height-body);
  -webkit-font-smoothing: antialiased;
}

/* Chinese text: prefer clean system sans for readability over serif */
:lang(zh), :lang(zh) h1, :lang(zh) h2, :lang(zh) h3 {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', var(--font-body);
}

h1, h2, h3 {
  font-family: var(--font-heading);
  line-height: var(--line-height-tight);
  margin: 0 0 var(--space-2);
  color: var(--color-text);
  font-weight: 600;
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--color-primary); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--color-primary-hover); }

ul, ol { padding-left: 1.4em; }
li { margin-bottom: var(--space-2); }

img, svg { max-width: 100%; display: block; }

/* ---------- Accessibility helpers ---------- */
.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;
}

.skip-link {
  position: absolute;
  top: -60px;
  left: var(--space-3);
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top var(--transition-fast);
  font-size: var(--fs-small);
}
.skip-link:focus {
  top: var(--space-2);
}

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
/* Ensure default focus is visible even without :focus-visible support */
a:focus, button:focus, input:focus, [tabindex]:focus {
  outline: 3px solid var(--color-focus);
  outline-offset: 3px;
}

/* ---------- Layout ---------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.site-main { display: block; }

section {
  padding: var(--space-6) 0;
}
section + section {
  border-top: 1px solid var(--color-border);
}

.section-header {
  max-width: 46rem;
  margin: 0 0 var(--space-5);
}
.section-header .eyebrow {
  display: inline-block;
  color: var(--color-accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.9rem;
  margin-bottom: var(--space-1);
}
.section-header p {
  font-size: var(--fs-lead);
  color: var(--color-text-muted);
}

.section-alt { background: var(--color-bg-soft); }

/* ---------- Header / Nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(140%) blur(6px);
  border-bottom: 1px solid var(--color-border);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(34, 30, 25, 0.92); }
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { opacity: 0.85; }
.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  object-fit: contain;
}
.brand-word-a { color: var(--logo-ring); }
.brand-word-b { color: var(--logo-wave); }

.nav-links {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--space-4);
  align-items: center;
}
.nav-links a {
  color: var(--color-text);
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 600;
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

@media (min-width: 780px) {
  .nav-links { display: flex; }
}

.nav-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.lang-toggle {
  display: inline-flex;
  align-items: stretch;
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-btn);
  overflow: hidden;
  background: var(--color-surface);
}
.lang-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  min-width: 3rem;
  padding: 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  min-height: 40px;
}
.lang-toggle button + button {
  border-left: 1.5px solid var(--color-border-strong);
}
.lang-toggle button[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
}
.lang-toggle button:not([aria-pressed="true"]):hover {
  color: var(--color-text);
  background: var(--color-bg-soft);
}

.lang-note {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-left: var(--space-1);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap-min);
  padding: 0.9rem 1.75rem;
  border-radius: var(--radius-btn);
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-body);
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { background: var(--color-primary-hover); color: #fff; }

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-secondary:hover { background: var(--color-primary-tint); }

.btn-ghost {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn-ghost:hover { background: var(--color-bg-soft); }

.btn-block { width: 100%; }
.btn-lg { min-height: 64px; font-size: 1.25rem; padding: 1rem 2rem; }

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------- Hero ---------- */
.hero {
  padding: var(--space-7) 0 var(--space-6);
  position: relative;
  overflow: hidden;
}
.hero-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0.35;
  z-index: 0;
}
.hero-shape.one {
  width: 300px; height: 300px;
  background: var(--color-primary-tint);
  top: -140px; right: -120px;
}
.hero-shape.two {
  width: 200px; height: 200px;
  background: var(--color-accent-tint);
  bottom: -100px; left: -80px;
}
.hero .container { position: relative; z-index: 1; }
.hero-content { max-width: 40rem; }
.hero .eyebrow {
  display: inline-block;
  color: var(--color-accent);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.9rem;
  margin-bottom: var(--space-2);
}
.hero h1 { margin-bottom: var(--space-3); }
.hero .lead {
  font-size: var(--fs-lead);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ---------- How it works ---------- */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .steps { grid-template-columns: repeat(3, 1fr); }
}
.step {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--color-accent-tint);
  color: var(--color-accent);
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: var(--space-2);
}
.step h3 { font-size: 1.2rem; margin-bottom: var(--space-1); }
.step p { color: var(--color-text-muted); margin: 0; }

/* ---------- Games hub / cards ---------- */
.game-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
}

.game-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--shadow-card);
}
.game-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--color-accent-tint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: var(--space-1);
}
.game-card h3 { font-size: var(--fs-card-title); margin-bottom: 0.25rem; }
.game-card p { color: var(--color-text-muted); flex-grow: 1; }
.game-card .btn { margin-top: var(--space-2); align-self: flex-start; }

/* ---------- Game shell (used across all mini-games) ---------- */
.game-page-header {
  padding-top: var(--space-4);
  padding-bottom: var(--space-2);
}
.game-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--color-text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 1rem;
  min-height: var(--tap-min);
}
.game-breadcrumb:hover { color: var(--color-primary); }

.game-shell {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.game-intro { max-width: 42rem; margin-bottom: var(--space-4); }
.game-intro p { color: var(--color-text-muted); }

.game-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.game-progress-label {
  font-weight: 700;
  color: var(--color-text-muted);
  font-size: 1rem;
}
.progress-dots {
  display: flex;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.progress-dots li {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-border-strong);
  margin: 0;
}
.progress-dots li[data-state="done"] { background: var(--color-accent); }
.progress-dots li[data-state="current"] {
  background: var(--color-primary);
  transform: scale(1.25);
}

.game-prompt {
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  margin-bottom: var(--space-4);
}

.take-your-time {
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  margin-top: var(--space-2);
}

/* Choice cards used by Memory Lane / Find the Group / Tune Match */
.choice-grid {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: var(--space-4);
}

.choice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-surface-alt);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-2);
  min-height: 116px;
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
  text-align: center;
}
.choice-card .choice-icon { font-size: 1.85rem; line-height: 1; opacity: 0.9; }
.choice-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
}
.choice-card[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: var(--color-primary-tint);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}
.choice-card[data-result="correct"] {
  border-color: var(--color-success-border);
  background: var(--color-success-bg);
  box-shadow: none;
}
.choice-card[data-result="missed"] {
  border-color: var(--color-gold);
  background: var(--color-gentle-bg);
  box-shadow: none;
}
.choice-card[disabled] { cursor: default; }

/* Feedback banner */
.feedback-banner {
  display: none;
  align-items: flex-start;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 1.1rem;
}
.feedback-banner.is-visible { display: flex; }
.feedback-banner.success {
  background: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}
.feedback-banner.gentle {
  background: var(--color-gentle-bg);
  color: var(--color-gentle-text);
  border: 1px solid var(--color-gentle-border);
}
.feedback-icon { font-size: 1.4rem; flex-shrink: 0; }

.game-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: flex-start;
}

/* Results screen */
.results-panel { text-align: left; }
.results-panel .results-icon {
  font-size: 2.1rem;
  margin-bottom: var(--space-2);
  opacity: 0.9;
}
.results-summary {
  background: var(--color-accent-tint);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  margin-bottom: var(--space-4);
  font-size: 1.1rem;
}

/* Tune Match play button */
.tune-player {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.tune-play-btn {
  min-width: 220px;
}
.tune-hint {
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}

/* ---------- Why section / Accessibility section ---------- */
.info-grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .info-grid { grid-template-columns: repeat(2, 1fr); }
}
.info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.info-card h3 {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.info-card p { color: var(--color-text-muted); margin: 0; }

.disclaimer-box {
  margin-top: var(--space-5);
  background: var(--color-bg-soft);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}
.disclaimer-box strong { color: var(--color-text); }

/* ---------- Language section ---------- */
.language-note-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  max-width: 42rem;
}
.language-note-card .icon { font-size: 2rem; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-5) 0 var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}
.footer-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  list-style: none;
  padding: 0;
  margin: var(--space-1) 0;
}
.footer-links a { color: var(--color-text-muted); }
.footer-links a:hover { color: var(--color-primary); }

/* Toast for language coming-soon note */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-4);
  transform: translate(-50%, 0);
  background: var(--color-text);
  color: var(--color-bg);
  padding: var(--space-2) var(--space-4);
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: var(--shadow-soft);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-medium);
}
.toast.is-visible { opacity: 1; }

/* Utility */
.center { text-align: center; }
.mt-0 { margin-top: 0; }
.hidden { display: none !important; }
