/* ── Variables & reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:        #211e1a;
  --ink-light:  #6b6259;
  --paper:      #f7f4ee;
  --paper2:     #efe8da;
  --card:       #ffffff;
  --accent:     #6f2a2a;
  --accent-light: #8a3d3d;
  --gold:       #a3874f;
  --line:       rgba(33, 30, 26, .12);
  --radius:     8px;
  --shadow:     0 6px 24px rgba(33, 30, 26, .08);
  --nav-h:      72px;
  --sq-light:   #efe6d3;
  --sq-dark:    #8a6a49;
  --sq-select:  rgba(111, 42, 42, .38);
  --sq-target:  rgba(163, 135, 79, .55);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.75;
  font-size: 16px;
}

h1, h2, h3, h4 { font-family: 'Lora', 'Georgia', serif; line-height: 1.3; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

section { padding: 88px 0; }
section.bg-paper2 { background: var(--paper2); }
section.bg-ink { background: var(--ink); color: rgba(247,244,238,.92); }

.section-header { text-align: center; margin-bottom: 52px; }
.eyebrow {
  display: block; font-size: .78rem; font-weight: 700; letter-spacing: .16em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 12px;
}
section.bg-ink .eyebrow { color: var(--gold); }
.section-header h2 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); margin-bottom: 14px; }
.section-header p { color: var(--ink-light); max-width: 600px; margin: 0 auto; }
section.bg-ink .section-header p { color: rgba(247,244,238,.7); }

.hairline {
  width: 52px; height: 1px; background: var(--gold); margin: 0 auto 20px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 13px 30px; border-radius: var(--radius);
  font-size: .86rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; cursor: pointer; border: 1.5px solid transparent;
  transition: background .2s, color .2s, border-color .2s, transform .15s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-light); border-color: var(--accent-light); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost-light { background: transparent; color: #fff; border-color: rgba(255,255,255,.4); }
.btn-ghost-light:hover { border-color: #fff; }

/* ── Navbar ── */
#navbar {
  position: fixed; top: 0; left: 0; width: 100%; height: var(--nav-h);
  background: rgba(247,244,238,.96); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 36px; z-index: 1000;
  border-bottom: 1px solid var(--line);
}
.nav-logo { display: flex; align-items: center; gap: 10px; font-family: 'Lora', serif; font-size: 1.15rem; font-weight: 700; color: var(--ink); }
.nav-logo .knight { font-size: 1.5rem; color: var(--accent); }
.nav-links { display: flex; gap: 30px; align-items: center; }
.nav-links a {
  font-size: .8rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); padding: 4px 0; border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.nav-links a:hover { color: var(--accent); border-color: var(--accent); }
.nav-links a.btn-nav { background: var(--accent); color: #fff; padding: 9px 18px; border-radius: var(--radius); }
.nav-links a.btn-nav:hover { background: var(--accent-light); }
.nav-toggle { display: none; background: none; border: none; color: var(--ink); font-size: 1.4rem; cursor: pointer; }

/* ── Hero ── */
#hero {
  margin-top: var(--nav-h);
  min-height: calc(100vh - var(--nav-h));
  display: flex; align-items: center;
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper2) 100%);
  position: relative; overflow: hidden;
}
#hero::after {
  content: '♞'; position: absolute; right: -60px; bottom: -90px;
  font-size: 34rem; color: rgba(111,42,42,.05); line-height: 1; pointer-events: none;
}
.hero-inner {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center;
  position: relative; z-index: 1;
}
.hero-eyebrow { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.hero-eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.hero-eyebrow span { font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.4rem); margin-bottom: 18px; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p.lead { font-size: 1.08rem; color: var(--ink-light); max-width: 520px; margin-bottom: 30px; }
.hero-btns { display: flex; gap: 14px; flex-wrap: wrap; }

.hero-avatar-wrap { display: flex; justify-content: center; }
.hero-avatar {
  width: 250px; height: 250px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Lora', serif; font-size: 4.2rem; font-weight: 700;
  box-shadow: var(--shadow); border: 6px solid var(--card); position: relative;
}
.hero-avatar::before {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 1px solid var(--gold);
}
.hero-elo {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700;
  letter-spacing: .06em; padding: 7px 18px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(111,42,42,.35);
}

@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero p.lead { margin-left: auto; margin-right: auto; }
  .hero-btns { justify-content: center; }
  .hero-avatar-wrap { order: -1; }
}

/* ── Chessdoku ── */
.chessdoku-card {
  max-width: 640px; margin: 0 auto; text-align: center;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 48px; border: 1px solid var(--line);
}
.chessdoku-text h3 { font-size: 1.5rem; margin-bottom: 14px; }
.chessdoku-text p { color: var(--ink-light); margin-bottom: 22px; }

@media (max-width: 760px) {
  .chessdoku-card { padding: 32px 24px; }
}

/* ── Cards grid (cours, finales) ── */
.cards-grid {
  display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 34px 30px; border: 1px solid var(--line);
  transition: transform .25s, box-shadow .25s;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 14px 32px rgba(33,30,26,.12); }
.card .card-icon {
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--paper2); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; margin-bottom: 18px;
}
.card h3 { font-size: 1.2rem; margin-bottom: 10px; }
.card p { font-size: .93rem; color: var(--ink-light); }

/* ── Finales list ── */
.finales-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 8px; }
.finale-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px; background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line);
}
.finale-item .num { font-family: 'Lora', serif; font-weight: 700; color: var(--gold); font-size: 1.1rem; }
.finale-item h4 { font-size: .98rem; margin-bottom: 4px; }
.finale-item p { font-size: .85rem; color: var(--ink-light); }

/* ── Lichess band ── */
.lichess-band {
  display: grid; grid-template-columns: auto 1fr auto; gap: 32px; align-items: center;
  background: var(--ink); color: rgba(247,244,238,.92);
  border-radius: var(--radius); padding: 40px 44px;
}
.lichess-band .lichess-icon { font-size: 2.4rem; color: var(--gold); }
.lichess-band h3 { font-size: 1.3rem; margin-bottom: 8px; color: #fff; }
.lichess-band p { font-size: .93rem; color: rgba(247,244,238,.72); max-width: 520px; }
@media (max-width: 760px) {
  .lichess-band { grid-template-columns: 1fr; text-align: center; padding: 36px 26px; }
}

/* ── Contact form ── */
.contact-wrap { max-width: 560px; margin: 0 auto; text-align: center; }
.contact-form {
  display: flex; gap: 12px; margin-top: 30px; flex-wrap: wrap; justify-content: center;
}
.contact-form input[type="email"] {
  flex: 1; min-width: 240px; padding: 14px 18px;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-family: 'Nunito', sans-serif; font-size: .95rem;
  background: var(--card); color: var(--ink); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.contact-form input[type="email"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111,42,42,.12); }
.contact-note { margin-top: 14px; font-size: .82rem; color: var(--ink-light); }

.flash-list { max-width: 560px; margin: 0 auto 24px; }
.flash {
  padding: 13px 18px; border-radius: var(--radius); font-size: .9rem;
  margin-bottom: 10px; border: 1px solid var(--line);
}
.flash.success { background: #eef4ea; color: #3a5a30; border-color: #cfe0c6; }
.flash.error { background: #f7e9e9; color: var(--accent); border-color: #e6c6c6; }

/* ── Puzzle ── */
.puzzle-wrap {
  display: grid; grid-template-columns: minmax(0, 460px) 1fr; gap: 48px; align-items: start;
}
.board-shell { position: relative; }
.board {
  position: relative; width: 100%; aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  border-radius: 4px; overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.sq { position: relative; cursor: pointer; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.selected::after {
  content: ''; position: absolute; inset: 0; background: var(--sq-select);
}
.sq.target::after {
  content: ''; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.sq.target::before {
  content: ''; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 26%; height: 26%; border-radius: 50%; background: var(--sq-target); z-index: 2;
}
.sq.mate-square { background: #7a2626 !important; }
.sq-coord {
  position: absolute; bottom: 2px; left: 4px; font-size: .6rem; font-weight: 700;
  opacity: .45; pointer-events: none;
}
.sq.light .sq-coord { color: var(--sq-dark); }
.sq.dark .sq-coord { color: var(--sq-light); }

.piece {
  position: absolute; width: 12.5%; height: 12.5%;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(1.6rem, 5.2vw, 2.6rem); line-height: 1;
  transition: top .45s cubic-bezier(.4,0,.2,1), left .45s cubic-bezier(.4,0,.2,1);
  pointer-events: none; user-select: none; z-index: 3;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.25));
}
.piece.white { color: #fbf8f2; -webkit-text-stroke: 1.2px #221f1b; }
.piece.black { color: #1b1815; -webkit-text-stroke: 1.2px #f2ede3; }
.piece.pulse-mate { animation: pulseMate 1s ease-in-out infinite; }
@keyframes pulseMate { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

.shake { animation: shakeBoard .35s; }
@keyframes shakeBoard {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.puzzle-side h3 { font-size: 1.35rem; margin-bottom: 8px; }
#puzzle-status {
  min-height: 52px; font-size: .98rem; color: var(--ink-light);
  padding: 16px 18px; background: var(--paper2); border-radius: var(--radius);
  margin: 18px 0 22px; border-left: 3px solid var(--gold);
}
#puzzle-status.mate {
  background: #eef4ea; color: #3a5a30; border-left-color: #6f9a5c; font-weight: 700;
}
.puzzle-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.puzzle-actions button {
  font-family: inherit; padding: 11px 22px; border-radius: var(--radius);
  font-size: .82rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  cursor: pointer; border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  transition: border-color .2s, color .2s;
}
.puzzle-actions button:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 860px) {
  .puzzle-wrap { grid-template-columns: 1fr; }
}

/* ── Footer ── */
footer { background: var(--ink); color: rgba(247,244,238,.65); padding: 48px 0 24px; }
.footer-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.footer-inner .knight { font-size: 1.8rem; color: var(--gold); }
.footer-inner a:hover { color: var(--gold); }
.footer-bottom { margin-top: 10px; font-size: .82rem; opacity: .7; }

/* ── Responsive nav ── */
@media (max-width: 780px) {
  #navbar { padding: 0 18px; }
  .nav-links {
    display: none; flex-direction: column; gap: 0; position: absolute; top: var(--nav-h);
    left: 0; width: 100%; background: var(--paper); border-bottom: 1px solid var(--line); padding: 8px 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a { display: block; padding: 13px 24px; border-bottom: none; }
  .nav-links a.btn-nav { margin: 10px 24px; }
  .nav-toggle { display: block; }
}
