/* ============================================
   1to9 Puzzle — Design System
   North Star: "The Daily Notebook"
   Register: product
   ============================================ */

/* --- Design Tokens (Light Theme) --- */
:root {
  /* Backgrounds */
  --bg-page: #fcfaf5;
  --bg-surface: #f8f6f0;

  /* Text */
  --text-primary: #3a3835;
  --text-secondary: #5a5754;
  --text-muted: #706b65;

  /* Borders */
  --border-default: #ddd8d0;
  --border-hover: #c8c3ba;
  --border-divider: #eeeade;

  /* Interactive */
  --hover-surface: #f3f0e8;
  --btn-active-bg: #666;
  --btn-active-text: #fff;

  /* Focus & Glow */
  --focus-ring: #2e7d32;
  --focus-glow: rgba(46, 125, 50, 0.12);

  /* Puzzle Grid */
  --cell-green: #B6E3AB;
  --cell-yellow: #f3ef9b;
  --cell-coral: #e8a088;
  --cell-hint-bg: #CAD0D4;
  --cell-hint-text: #943020;
  --cell-border: #4CAF50;

  /* Primary / Accent */
  --primary: #2e7d32;
  --primary-hover: #256b29;
  --accent: #d45f4a;

  /* Difficulty */
  --difficulty-easy: #66BB6A;
  --difficulty-medium: #E5A93D;
  --difficulty-hard: #B85C44;

  /* Difficulty Pictogram Scale (OKLCH-interpolated: 1=easy, 5=medium, 9=hard) */
  --pictogram-1: #66BB6A;
  --pictogram-2: #8eb951;
  --pictogram-3: #b0b53d;
  --pictogram-4: #cdaf33;
  --pictogram-5: #E5A93D;
  --pictogram-6: #de943a;
  --pictogram-7: #d3803c;
  --pictogram-8: #c76d40;
  --pictogram-9: #B85C44;

  /* Status */
  --error-bg: #fdf0ee;
  --error-text: #b94030;
  --success: #3a7d40;

  /* Secondary text on dark or tinted surfaces */
  --text-on-accent: #fff;

  /* Code */
  --code-bg: #f0ece4;

  /* Shadows (tinted for warmth) */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 6px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-dropdown: 0 4px 16px rgba(0,0,0,0.10);

  /* Misc */
  --privacy-divider: #e8e4dc;
  --footer-text: #666;
  --link-hover: #3a3835;
}

/* --- Dark Theme --- */
@media (prefers-color-scheme: dark) {
  :root {
    /* Backgrounds — 3-step elevation: deeper → mid → elevated (depth from lightness, not shadows) */
    --bg-page: #141211;
    --bg-surface: #1c1917;
    --bg-elevated: #242120;

    /* Text — light-on-dark reads heavier, so we use slightly muted secondaries */
    --text-primary: #ede8e0;
    --text-secondary: #a8a098;
    --text-muted: #8a8480;

    /* Borders */
    --border-default: #3a3835;
    --border-hover: #504c46;
    --border-divider: #353330;

    /* Interactive */
    --hover-surface: #242120;
    --btn-active-bg: #a09890;
    --btn-active-text: #1a1916;

    /* Focus — explicit colors, no alpha transparency */
    --focus-ring: #66BB6A;
    --focus-glow: #1e2e1c;

    /* Puzzle Grid — hue identity preserved, chroma tuned for dark bg */
    --cell-green: #2a4a28;
    --cell-yellow: #4d4727;
    --cell-coral: #502822;
    --cell-hint-bg: #303538;
    --cell-hint-text: #d87868;
    --cell-border: #4a9a4e;

    /* Primary / Accent — coral desaturated slightly for dark surfaces */
    --primary: #2d6a2e;
    --primary-hover: #388e3c;
    --accent: #d06050;

    /* Difficulty (brightened for dark bg) */
    --difficulty-easy: #80d084;
    --difficulty-medium: #edb04f;
    --difficulty-hard: #d07058;

    /* Difficulty Pictogram Scale */
    --pictogram-1: #80d084;
    --pictogram-2: #a2ca6a;
    --pictogram-3: #bfc355;
    --pictogram-4: #d9ba4b;
    --pictogram-5: #edb04f;
    --pictogram-6: #e99f4d;
    --pictogram-7: #e38e4f;
    --pictogram-8: #da7e53;
    --pictogram-9: #d07058;

    /* Status */
    --error-bg: #3a2020;
    --error-text: #f0a090;
    --success: #7dca80;

    /* Secondary text on dark or tinted surfaces */
    --text-on-accent: #fff;

    /* Code */
    --code-bg: #242120;

    /* Shadows — reduced (depth comes from surface lightness, not shadow density) */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.10);
    --shadow-md: 0 2px 6px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.15);
    --shadow-dropdown: 0 4px 16px rgba(0,0,0,0.18);

    /* Misc */
    --privacy-divider: #353330;
    --footer-text: #a09890;
    --link-hover: #ede8e0;
  }

  /* Reduce body text weight — light-on-dark reads heavier than dark-on-light */
  body {
    font-weight: 350;
  }
}

/* --- Screen Reader Only --- */
.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 --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 200;
  padding: 8px 16px;
  background-color: var(--primary);
  color: var(--text-on-accent);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
  outline: 2.5px solid var(--text-on-accent);
  outline-offset: 2px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.site-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 16px 8px;
  position: relative;
}

.site-logo {
  height: 36px;
  width: auto;
  display: block;
  transition: transform 0.3s ease-out;
}

.site-logo:hover {
  transform: rotate(-4deg) scale(1.05);
}

.site-title {
  font-family: "Lora", "Times New Roman", serif;
  font-size: clamp(1.25rem, 4vw, 1.75rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 0;
}

.site-header-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

/* --- Main Content --- */
.main-content {
  width: 100%;
  max-width: 480px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* --- Footer --- */
.site-footer {
  width: 100%;
  text-align: center;
  padding: 32px 16px 24px;
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--footer-text);
}

.footer-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-link:hover {
  color: var(--link-hover);
}

/* --- Responsive --- */
@media (max-width: 400px) {
  .site-header {
    gap: 8px;
    padding: 16px 12px 4px;
  }

  .site-logo {
    height: 28px;
  }

  .main-content {
    gap: 14px;
    padding: 0 12px;
  }
}
