/* ============================================================
   VeryFreeSudoku — Main Stylesheet
   Modern, minimal, professional. System fonts only.
   ============================================================ */

:root {
  /* Palette — warm neutrals + ocean accent */
  --bg: #f8f7f4;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --text-light: #999;
  --accent: #1e40af;
  --accent-hover: #1e3a8a;
  --accent-light: #dbeafe;
  --border: #e5e5e5;
  --border-strong: #1a1a1a;
  --cell-highlight: #eef2ff;
  --cell-selected: #c7d2fe;
  --cell-same: #fef3c7;
  --cell-conflict: #fee2e2;
  --cell-given: #1a1a1a;
  --cell-user: #1e40af;
  --cell-revealed: #16a34a;
  --note-color: #6b7280;
  --success: #16a34a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.1);
  --radius: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Layout ── */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.site-logo:hover { text-decoration: none; color: var(--accent); }
.site-logo span { color: var(--accent); }

.est-badge {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-light);
  letter-spacing: 0.04em;
  margin-left: 0.5rem;
  white-space: nowrap;
}

.site-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.site-nav a {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .15s, color .15s;
}
.site-nav a:hover, .site-nav a.active {
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
}

main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}
.page-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 1rem;
}

/* Hero section — homepage only */
.hero-section {
  position: relative;
  padding: 1.5rem 0 1rem;
}
.hero-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(to right, rgba(0,0,0,.03) 0px, rgba(0,0,0,.03) 1px, transparent 1px, transparent calc(100% / 9)),
    repeating-linear-gradient(to bottom, rgba(0,0,0,.03) 0px, rgba(0,0,0,.03) 1px, transparent 1px, transparent calc(100% / 9));
  background-size: 100% 100%;
  pointer-events: none;
  z-index: 0;
  border-radius: var(--radius-lg);
}
.hero-section > * {
  position: relative;
  z-index: 1;
}
.hero-section .page-title {
  font-size: 2rem;
  line-height: 1.25;
  margin-bottom: 0.375rem;
}
.hero-section .page-subtitle {
  font-size: 0.9375rem;
  margin-bottom: 1.25rem;
}

.content-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem;
  margin-bottom: 2rem;
}
.content-section h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.content-section p { margin-bottom: 0.75rem; color: var(--text); }

.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-light);
  font-size: 0.8125rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.site-footer a { color: var(--text-muted); }

/* ── Sudoku Container ── */
.sudoku-container {
  max-width: 540px;
  margin: 0 auto;
}

/* Toolbar */
.sudoku-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.difficulty-picker {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.diff-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 0.25rem;
}
.diff-btn {
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.diff-btn:hover { border-color: var(--accent); color: var(--accent); }
.diff-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sudoku-actions {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn.active {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}
.btn-icon { font-size: 0.9rem; }

.sudoku-timer {
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  padding: 0.3rem 0.75rem;
  background: var(--bg);
  border-radius: 6px;
  min-width: 4rem;
  text-align: center;
}

/* ── Grid ── */
.sudoku-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 2.5px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  aspect-ratio: 1;
  max-width: 100%;
}

.sudoku-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 600;
  border: 0.5px solid var(--border);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background .1s;
  outline: none;
}
.sudoku-cell:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
  z-index: 1;
}

/* Box borders */
.sudoku-cell.box-left { border-left: 2.5px solid var(--border-strong); }
.sudoku-cell.box-top { border-top: 2.5px solid var(--border-strong); }

/* States */
.sudoku-cell.given { color: var(--cell-given); font-weight: 700; }
.sudoku-cell.user-value { color: var(--cell-user); }
.sudoku-cell.revealed { color: var(--cell-revealed); }
.sudoku-cell.highlighted { background: var(--cell-highlight); }
.sudoku-cell.selected { background: var(--cell-selected) !important; }
.sudoku-cell.same-number { background: var(--cell-same); }
.sudoku-cell.conflict { background: var(--cell-conflict) !important; }

.sudoku-grid.completed .sudoku-cell { cursor: default; }

/* Notes 3x3 mini-grid */
.note-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 1px;
}
.note-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.45rem, 1.5vw, 0.65rem);
  font-weight: 500;
  color: var(--note-color);
  line-height: 1;
}

/* ── Number Pad ── */
.sudoku-numpad {
  display: flex;
  gap: 0.375rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.num-btn {
  width: clamp(2.25rem, 8vw, 3rem);
  height: clamp(2.25rem, 8vw, 3rem);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .12s;
  box-shadow: var(--shadow-sm);
}
.num-btn:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.num-btn:active { transform: translateY(0); }
.erase-btn { color: var(--text-muted); font-size: 1rem; }

/* ── Status ── */
.sudoku-status {
  text-align: center;
  margin-top: 1rem;
  font-size: 1rem;
  font-weight: 600;
  min-height: 1.5em;
}
.sudoku-status.complete { color: var(--success); font-size: 1.25rem; }

/* ── Links page ── */
.link-list { list-style: none; }
.link-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.link-list li:last-child { border-bottom: none; }
.link-list a { font-weight: 500; }
.link-list .link-desc { display: block; font-size: 0.875rem; color: var(--text-muted); margin-top: 0.2rem; }

/* ── Contact ── */
.contact-info p { margin-bottom: 0.5rem; }

/* ── Mobile hamburger ── */
.nav-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; padding: 0.25rem; color: var(--text); }

@media (max-width: 640px) {
  .site-header { padding: 0.5rem 1rem; }
  .nav-toggle { display: block; }
  .site-nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    padding: 0.5rem 1rem 1rem;
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 99;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 0.5rem 0.75rem; }
  main { padding: 1.25rem 1rem; }
  .page-title { font-size: 1.375rem; }
  .content-section { padding: 1.25rem; }
  .sudoku-toolbar { gap: 0.5rem; }
  .difficulty-picker { gap: 0.25rem; }
}

/* ── Print ── */
@media print {
  .site-header, .site-footer, .sudoku-toolbar,
  .sudoku-numpad, .sudoku-status, .nav-toggle,
  .no-print { display: none !important; }

  body { background: #fff; }
  main { padding: 0; max-width: 100%; }

  .sudoku-grid {
    max-width: 500px;
    margin: 1rem auto;
    box-shadow: none;
    border: 3px solid #000;
    page-break-inside: avoid;
  }
  .sudoku-cell {
    border-color: #ccc;
    font-size: 14pt;
  }
  .sudoku-cell.box-left { border-left: 3px solid #000; }
  .sudoku-cell.box-top { border-top: 3px solid #000; }
  .sudoku-cell.highlighted,
  .sudoku-cell.selected,
  .sudoku-cell.same-number { background: none !important; }
  .sudoku-cell.user-value { color: #333; }
  .sudoku-cell.revealed { color: #666; }

  .page-title { text-align: center; margin-bottom: 0.5rem; }
  .content-section { box-shadow: none; padding: 0; }
}
