/* =========================================================
   TerraKomet — Design System
   Read. Play. Discover.
   Mobile-first, lightweight, no framework dependencies.
   ========================================================= */

:root {
  --bg: #F8F7F4;
  --surface: #FFFFFF;
  --text: #1A1A1A;
  --text-muted: #5B5B5B;
  --accent: #E8500A;        /* orange — primary CTA */
  --accent-ink: #FFFFFF;
  --cosmic: #4C3BCF;        /* indigo — secondary / futuristic accent */
  --cosmic-soft: #EFEDFC;
  --border: #E7E3DC;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 2px 8px rgba(26,26,26,0.05);
  --shadow: 0 6px 20px rgba(26,26,26,0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --maxw: 1160px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

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

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
ul { padding: 0; margin: 0; list-style: none; }
button { font-family: inherit; cursor: pointer; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 18px;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 { line-height: 1.25; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3.6vw, 1.9rem); }
h3 { font-size: clamp(1.15rem, 2.8vw, 1.35rem); }
p { margin: 0 0 1em; color: var(--text); }
.lede { font-size: 1.1rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--cosmic);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border-radius: var(--radius); border: none;
  font-weight: 700; font-size: .95rem; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
  min-height: 46px;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--cosmic-soft); color: var(--cosmic); }
.btn-secondary:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-block { width: 100%; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(248,247,244,0.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.3rem; }
.logo .dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--cosmic));
  box-shadow: 0 0 0 4px var(--cosmic-soft);
}
.logo span.k { color: var(--cosmic); }

.nav-links { display: none; gap: 26px; align-items: center; }
.nav-links a { font-weight: 600; font-size: .95rem; padding: 6px 2px; border-bottom: 2px solid transparent; }
.nav-links a:hover, .nav-links a.active { border-bottom-color: var(--accent); }

.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface);
}
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after {
  content: ""; display: block; width: 18px; height: 2px; background: var(--text); position: relative;
  transition: transform .2s ease;
}
.nav-toggle span::before { position: absolute; top: -6px; }
.nav-toggle span::after { position: absolute; top: 6px; }

.mobile-nav {
  display: none; flex-direction: column; gap: 2px;
  border-top: 1px solid var(--border); background: var(--surface);
}
.mobile-nav.open { display: flex; }
.mobile-nav a {
  padding: 14px 18px; font-weight: 600; border-bottom: 1px solid var(--border);
  min-height: 48px; display: flex; align-items: center;
}

@media (min-width: 860px) {
  .nav-links { display: flex; }
  .nav-toggle { display: none; }
  .mobile-nav { display: none !important; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 52px 0 44px;
  background:
    radial-gradient(600px 300px at 85% -10%, var(--cosmic-soft), transparent 60%),
    radial-gradient(500px 260px at 5% 110%, #FCE6D8, transparent 60%);
}
.hero-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.hero-brand .dot { width: 14px; height: 14px; }
.hero-brand-name { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; }
.hero h1 { max-width: 30ch; margin-bottom: .3em; }
.hero .tagline { font-weight: 700; color: var(--cosmic); font-size: 1.05rem; margin-bottom: .6em; }
.hero p.lede { max-width: 46ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 22px; }

/* ---------- Section headers ---------- */
.section { padding: 40px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head .see-all { font-weight: 700; color: var(--cosmic); font-size: .92rem; white-space: nowrap; }

/* ---------- Cards ---------- */
.card-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 620px) { .card-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 860px) {
  .card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .card-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .15s ease, box-shadow .15s ease;
  display: flex; flex-direction: column;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.card-media { aspect-ratio: 16/9; width: 100%; background: var(--cosmic-soft); overflow: hidden; }
.card-media svg, .card-media img { width: 100%; height: 100%; display: block; object-fit: cover; }
.article-hero img { width: 100%; height: auto; display: block; aspect-ratio: 1200/630; object-fit: cover; }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-cat { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.card h3 { font-size: 1.05rem; margin: 0; }
.card p { font-size: .92rem; color: var(--text-muted); margin: 0; flex: 1; }
.card-meta { font-size: .8rem; color: var(--text-muted); display: flex; gap: 10px; margin-top: 6px; }

/* compact card row for tools/games */
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile .icon {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--cosmic-soft); font-size: 1.3rem;
}
.tile h3 { font-size: 1rem; margin: 0; }
.tile p { font-size: .86rem; color: var(--text-muted); margin: 0; }

/* ---------- Breadcrumbs ---------- */
.breadcrumbs { font-size: .82rem; color: var(--text-muted); padding: 14px 0 0; }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--cosmic); }
.breadcrumbs .sep { margin: 0 6px; }

/* ---------- Article ---------- */
.article-head { padding: 18px 0 6px; }
.article-head .card-cat { display: inline-block; margin-bottom: 10px; }
.article-head h1 { margin-bottom: 10px; }
.article-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-muted); font-size: .88rem; margin-bottom: 18px; }
.article-hero { border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 22px; box-shadow: var(--shadow-sm); }

.article-layout { display: grid; grid-template-columns: 1fr; gap: 32px; }
@media (min-width: 980px) { .article-layout { grid-template-columns: minmax(0,1fr) 300px; } }

.prose h2 { margin-top: 1.6em; }
.prose h3 { margin-top: 1.3em; }
.prose p { font-size: 1.02rem; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.3em; }
.prose li { margin-bottom: .5em; }
.prose blockquote {
  margin: 1.5em 0; padding: 14px 18px; border-left: 4px solid var(--accent);
  background: var(--cosmic-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-style: italic;
}
.callout {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; margin: 1.6em 0;
}
.callout strong { color: var(--cosmic); }

.share-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 22px 0; }
.share-btn {
  width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--cosmic-soft); color: var(--cosmic); font-weight: 700; font-size: .85rem; border: none;
}

.sidebar { display: flex; flex-direction: column; gap: 20px; }
.sidebar-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; }
.sidebar-box h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin-bottom: 12px; }
.sidebar-box .mini-list a { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .92rem; }
.sidebar-box .mini-list a:last-child { border-bottom: none; }

/* ---------- Ad slots ---------- */
.ad-slot {
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: #FCFBF9; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  min-height: 100px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em;
  margin: 26px 0; padding: 10px; text-align: center;
}
.ad-slot.ad-sidebar { min-height: 250px; }
.ad-slot.ad-leaderboard { min-height: 90px; }

/* ---------- FAQ ---------- */
.faq-item { border-bottom: 1px solid var(--border); padding: 16px 0; }
.faq-item h3 { font-size: 1rem; margin: 0 0 6px; }
.faq-item p { margin: 0; color: var(--text-muted); }

/* ---------- Tool box ---------- */
.tool-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; box-shadow: var(--shadow-sm); margin: 18px 0 10px;
}
.tool-box .field { margin-bottom: 14px; }
.tool-box label { display: block; font-weight: 700; font-size: .88rem; margin-bottom: 6px; }
.tool-box input[type=text], .tool-box input[type=number], .tool-box input[type=date],
.tool-box select, .tool-box textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  font-size: 1rem; font-family: inherit; background: var(--bg); min-height: 46px;
}
.tool-box textarea { min-height: 140px; resize: vertical; }
.tool-row { display: flex; gap: 12px; flex-wrap: wrap; }
.tool-row > * { flex: 1; min-width: 140px; }
.tool-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.result-box {
  margin-top: 16px; padding: 16px 18px; border-radius: var(--radius); background: var(--cosmic-soft);
  font-weight: 700; color: var(--cosmic); font-size: 1.05rem;
}
.result-box.empty { display: none; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.stat-pill { background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 8px 14px; font-size: .85rem; font-weight: 700; }

/* ---------- Game box ---------- */
.game-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 26px; box-shadow: var(--shadow-sm); margin: 18px 0; text-align: center;
}
.game-stage {
  min-height: 220px; border-radius: var(--radius); background: var(--cosmic-soft);
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  padding: 20px; margin-bottom: 18px; transition: background .12s ease;
}
.game-stage.go { background: #DDF5E3; }
.game-stage.wait { background: #F3E3E1; }
.game-big { font-size: 2rem; font-weight: 800; }
.game-controls { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.memory-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 420px; margin: 0 auto; }
.memory-card {
  aspect-ratio: 1; border-radius: 12px; background: var(--cosmic); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; font-weight: 800;
  user-select: none;
}
.memory-card.hidden-face { background: var(--cosmic); }
.memory-card.revealed { background: var(--surface); border: 2px solid var(--cosmic); color: var(--text); }
.memory-card.matched { background: #DDF5E3; border: 2px solid #2E9E4F; color: #1A1A1A; }

.quiz-progress { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.quiz-progress-bar { height: 100%; background: var(--accent); width: 0%; transition: width .25s ease; }
.quiz-question { text-align: left; font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.quiz-option {
  padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); font-weight: 600; font-size: .96rem; text-align: left; min-height: 48px;
}
.quiz-option.correct { background: #DDF5E3; border-color: #2E9E4F; }
.quiz-option.wrong { background: #FBE1DD; border-color: #E8500A; }
.quiz-option:disabled { opacity: .85; }

/* ---------- Category / hub header ---------- */
.hub-head { padding: 34px 0 10px; }
.hub-head .icon-badge {
  width: 52px; height: 52px; border-radius: 16px; background: var(--cosmic-soft); color: var(--cosmic);
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin-bottom: 14px;
}

/* ---------- Next Up (continuous reading) ---------- */
.next-up {
  display: flex; gap: 16px; align-items: stretch; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm); margin: 30px 0; transition: transform .15s ease, box-shadow .15s ease;
}
.next-up:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.next-up .next-up-media { width: 130px; flex-shrink: 0; }
.next-up .next-up-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.next-up .next-up-body { padding: 16px 18px 16px 4px; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.next-up .next-up-eyebrow { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); }
.next-up h3 { font-size: 1.05rem; margin: 0; }
.next-up p { font-size: .86rem; color: var(--text-muted); margin: 0; }
@media (max-width: 480px) { .next-up .next-up-media { width: 96px; } .next-up h3 { font-size: .96rem; } }

/* ---------- CTA band ---------- */
.cta-band {
  background: linear-gradient(120deg, var(--cosmic), #6C5CE7);
  color: #fff; border-radius: var(--radius-lg); padding: 34px 26px; text-align: center; margin: 10px 0;
}
.cta-band h2 { color: #fff; }
.cta-band p { color: rgba(255,255,255,.85); }
.cta-band .btn-primary { background: #fff; color: var(--cosmic); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 40px; padding: 40px 0 26px; }
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 28px; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 1.4fr 1fr 1fr 1fr; } }
.footer-grid h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 12px; }
.footer-grid a, .footer-grid p { font-size: .92rem; color: var(--text-muted); }
.footer-grid ul li { margin-bottom: 9px; }
.footer-grid ul a:hover { color: var(--cosmic); }
.footer-bottom {
  border-top: 1px solid var(--border); margin-top: 28px; padding-top: 18px;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  font-size: .82rem; color: var(--text-muted);
}
.footer-legal { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Utility ---------- */
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.pill {
  display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--cosmic-soft);
  color: var(--cosmic); font-size: .78rem; font-weight: 700;
}
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 10px 16px;
  border-radius: 0 0 10px 0; z-index: 100;
}
.skip-link:focus { left: 0; }

@media (max-width: 619px) {
  .hero-cta .btn { width: 100%; }
  .footer-legal { flex-direction: column; gap: 6px; }
}
