/* =========================================================
   TicTacToeFun — Global Stylesheet
   Aesthetic: paper-sketch arcade. Warm cream paper, ink lines,
   crisp modern type, hand-drawn marks. Light + dark theme.
   ========================================================= */

/* ---- CSS Reset (modern, minimal) ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, ul, ol, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---- Design Tokens ---- */
:root {
  --paper:        #f5efe1;
  --paper-dark:   #ebe2cf;
  --ink:          #1a1a1a;
  --ink-soft:     #3a3a3a;
  --muted:        #6b6357;
  --line:         #1a1a1a;

  --accent:       #d94f3a;   /* tomato red */
  --accent-2:     #2c5f8d;   /* deep blue  */
  --accent-3:     #e6b32a;   /* mustard    */
  --accent-soft:  #f8d7cf;

  --x-color:      #d94f3a;
  --o-color:      #2c5f8d;

  --shadow-sm:    3px 3px 0 var(--ink);
  --shadow-md:    5px 5px 0 var(--ink);
  --shadow-lg:    8px 8px 0 var(--ink);

  --radius-sm:    6px;
  --radius-md:    12px;
  --radius-lg:    20px;

  --font-display: "Fraunces", "Playfair Display", Georgia, serif;
  --font-body:    "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", "Courier New", monospace;

  --container:    1100px;
}

[data-theme="dark"] {
  --paper:       #1c1a18;
  --paper-dark:  #15130f;
  --ink:         #f0e7d4;
  --ink-soft:    #d4cab5;
  --muted:       #a89e8a;
  --line:        #f0e7d4;
  --accent-soft: #3a2520;
  --shadow-sm:   3px 3px 0 var(--line);
  --shadow-md:   5px 5px 0 var(--line);
  --shadow-lg:   8px 8px 0 var(--line);
}

/* ---- Body / Base ---- */
body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,0.06) 1px, transparent 0);
  background-size: 22px 22px;
  min-height: 100vh;
  overflow-x: hidden;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0);
}

/* ---- Typography ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); margin-bottom: 0.8rem; }
h3 { font-size: 1.3rem; margin-bottom: 0.5rem; }
p  { margin-bottom: 1rem; color: var(--ink-soft); }

a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

.container { max-width: var(--container); margin: 0 auto; padding: 0 1.25rem; }

/* ---- Header / Nav ---- */
.site-header {
  border-bottom: 3px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 50;
}
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  max-width: var(--container);
  margin: 0 auto;
}
.logo {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  text-decoration: none;
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--ink);
}
.logo-mark {
  display: inline-grid;
  grid-template-columns: repeat(3, 12px);
  grid-template-rows: repeat(3, 12px);
  gap: 2px;
  padding: 4px;
  border: 2px solid var(--ink);
  border-radius: 4px;
}
.logo-mark span { background: var(--ink); border-radius: 1px; }
.logo-mark span:nth-child(1),
.logo-mark span:nth-child(5),
.logo-mark span:nth-child(9) { background: var(--accent); }

.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { text-decoration: none; font-weight: 600; }
.nav-links a:hover { color: var(--accent); }

.nav-toggle { display: none; }
.theme-toggle {
  border: 2px solid var(--ink);
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  background: var(--paper);
  transition: transform 0.15s;
}
.theme-toggle:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-sm); }

/* ---- Buttons ---- */
.btn {
  display: inline-block;
  padding: 0.8rem 1.4rem;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-md); color: var(--paper); }
.btn-accent { background: var(--accent); border-color: var(--ink); color: #fff; }
.btn-outline { background: var(--paper); color: var(--ink); }

/* ---- Card ---- */
.card {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  transition: transform 0.2s, box-shadow 0.2s;
}
.card:hover { transform: translate(-3px, -3px); box-shadow: var(--shadow-lg); }
.card h3 a { text-decoration: none; }

/* ---- Hero ---- */
.hero {
  padding: 4rem 1.25rem 3rem;
  text-align: center;
  position: relative;
}
.hero h1 {
  margin-bottom: 1rem;
}
.hero h1 .accent { color: var(--accent); }
.hero h1 .accent-2 { color: var(--accent-2); }
.hero .lead {
  font-size: 1.2rem;
  max-width: 640px;
  margin: 0 auto 2rem;
  color: var(--ink-soft);
}
.hero-cta { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

/* Decorative floating marks */
.hero::before, .hero::after {
  content: ''; position: absolute; font-family: var(--font-display);
  font-size: 6rem; font-weight: 900; opacity: 0.08;
  pointer-events: none;
}
.hero::before { content: 'X'; top: 10%; left: 5%; color: var(--accent); transform: rotate(-15deg); }
.hero::after  { content: 'O'; bottom: 10%; right: 5%; color: var(--accent-2); transform: rotate(12deg); }

/* ---- Sections ---- */
.section { padding: 3rem 0; }
.section-title {
  display: inline-block;
  position: relative;
  margin-bottom: 2rem;
}
.section-title::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -6px;
  height: 6px; background: var(--accent-3); border-radius: 3px; z-index: -1;
}

.grid {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* ---- Footer ---- */
.site-footer {
  border-top: 3px solid var(--line);
  background: var(--paper-dark);
  padding: 2.5rem 1.25rem 1.5rem;
  margin-top: 4rem;
}
.footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
}
.footer-inner h4 { font-family: var(--font-display); margin-bottom: 0.8rem; }
.footer-inner ul li { margin-bottom: 0.4rem; }
.footer-inner a { text-decoration: none; color: var(--ink-soft); }
.footer-inner a:hover { color: var(--accent); }
.footer-bottom {
  max-width: var(--container);
  margin: 2rem auto 0;
  padding-top: 1.5rem;
  border-top: 1px dashed var(--muted);
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---- Game Board (shared) ---- */
.game-wrap {
  max-width: 520px;
  margin: 2rem auto;
  text-align: center;
}
.game-status {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1rem;
  min-height: 2rem;
}
.scoreboard {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.score-box {
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  background: var(--paper);
  font-weight: 700;
  min-width: 90px;
}
.score-box.x { color: var(--x-color); }
.score-box.o { color: var(--o-color); }
.score-box .label { display: block; font-size: 0.75rem; color: var(--muted); letter-spacing: 0.05em; }
.score-box .value { display: block; font-size: 1.6rem; font-family: var(--font-display); }

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--ink);
  padding: 8px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  aspect-ratio: 1 / 1;
  max-width: 420px;
  margin: 0 auto;
}
.cell {
  background: var(--paper);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 12vw, 4.5rem);
  font-weight: 900;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
  aspect-ratio: 1/1;
}
.cell:hover:not(.filled):not(.disabled) { background: var(--accent-soft); }
.cell.x { color: var(--x-color); }
.cell.o { color: var(--o-color); }
.cell.win { background: var(--accent-3); animation: pulse 0.5s ease 2; }
.cell.filled, .cell.disabled { cursor: not-allowed; }

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

.game-controls {
  display: flex; gap: 0.8rem; justify-content: center; margin-top: 1.5rem;
  flex-wrap: wrap;
}

.options {
  display: flex; gap: 0.8rem; justify-content: center; margin-bottom: 1.5rem;
  flex-wrap: wrap; align-items: center;
}
.options label { font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.options select {
  border: 2px solid var(--ink); padding: 0.4rem 0.6rem; border-radius: var(--radius-sm);
  background: var(--paper); font-family: var(--font-body); font-weight: 600;
  color: var(--ink);
}

/* ---- Article / Blog ---- */
.article {
  max-width: 720px;
  margin: 2rem auto;
  padding: 0 1.25rem;
}
.article h1 { margin-bottom: 0.5rem; }
.article .meta { color: var(--muted); margin-bottom: 2rem; font-size: 0.95rem; }
.article h2 { margin-top: 2.2rem; }
.article h3 { margin-top: 1.8rem; }
.article p, .article li { font-size: 1.05rem; line-height: 1.75; }
.article ul, .article ol { margin: 1rem 0 1.5rem 1.5rem; }
.article ul li { list-style: disc; margin-bottom: 0.4rem; }
.article ol li { list-style: decimal; margin-bottom: 0.4rem; }
.article blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.5rem 1rem;
  margin: 1.5rem 0;
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}
.article code {
  font-family: var(--font-mono);
  background: var(--paper-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}
.article pre {
  background: var(--ink); color: var(--paper);
  padding: 1rem; border-radius: var(--radius-sm);
  overflow-x: auto; margin: 1.5rem 0;
}
.article pre code { background: transparent; color: inherit; padding: 0; }

/* ---- AdSense placeholder ---- */
.ad-slot {
  display: block;
  margin: 2rem auto;
  text-align: center;
  min-height: 90px;
  max-width: 728px;
}

/* ---- Mobile ---- */
@media (max-width: 720px) {
  .nav-links {
    position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; background: var(--paper);
    padding: 1rem 1.25rem;
    border-bottom: 3px solid var(--line);
    gap: 0.8rem;
    display: none;
  }
  .nav-links.open { display: flex; }
  .nav-toggle {
    display: block;
    border: 2px solid var(--ink); padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm); font-weight: 700;
  }
  .hero { padding: 2.5rem 1.25rem 2rem; }
  .hero::before, .hero::after { font-size: 4rem; }
}

/* ---- Skip link for accessibility ---- */
.skip-link {
  position: absolute; top: -40px; left: 0;
  background: var(--ink); color: var(--paper);
  padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { top: 0; }