/* ── Palette ────────────────────────────────────────────────────────── */
:root {
  --electric-blue: #0a6cff;
  --cyan:          #00d4ff;
  --magenta:       #d400ff;
  --pink:          #ff2d78;
  --purple:        #7b2fff;

  /* gradients */
  --grad-tech:     linear-gradient(135deg, var(--electric-blue), var(--cyan));
  --grad-creative: linear-gradient(135deg, var(--magenta), var(--pink), var(--purple));
  --grad-full:     linear-gradient(135deg, var(--electric-blue), var(--cyan) 40%, var(--magenta) 70%, var(--pink));

  /* neutrals */
  --bg:      #0d0d14;
  --surface: #13131f;
  --border:  #1e1e32;
  --muted:   #7a7a9a;
  --text:    #e8e8f0;

  --radius: 10px;
}

/* ── Base ───────────────────────────────────────────────────────────── */
body {
  font-size: 1rem;
  line-height: 1.7;
  background-color: var(--bg);
  color: var(--text);
}

a {
  color: #5b9fd4;
  text-decoration: none;
}
a:hover { color: #a06898; }

h1, h2, h3 { color: var(--text); }

/* ── Header / Nav ───────────────────────────────────────────────────── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
  margin-bottom: 2rem;
  background: var(--surface);
}

.site-brand {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.site-logo {
  height: 40px;
  width: auto;
  display: block;
}

.nav-link {
  position: relative;
  color: var(--muted) !important;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none !important;
  padding-bottom: 3px;
  transition: color 0.25s;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1.5px;
  background: var(--grad-tech);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover {
  color: #5b9fd4 !important;
}

.nav-link:hover::after {
  width: 100%;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding: 1.5rem 0;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
}

/* ── Buttons ────────────────────────────────────────────────────────── */
[role="button"],
button,
input[type="submit"] {
  background: var(--grad-tech) !important;
  border: none !important;
  color: #fff !important;
  border-radius: var(--radius) !important;
  font-weight: 600 !important;
  letter-spacing: 0.03em;
  transition: opacity 0.2s, transform 0.15s;
}
[role="button"]:hover,
button:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

[role="button"].secondary,
button.secondary {
  background: var(--grad-creative) !important;
}

[role="button"].outline,
button.outline {
  background: transparent !important;
  border: 1px solid var(--cyan) !important;
  color: var(--cyan) !important;
}
[role="button"].outline:hover,
button.outline:hover {
  background: var(--grad-tech) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* ── Hero (homepage) ────────────────────────────────────────────────── */
.hero {
  padding: 3.5rem 0 2.5rem;
}

.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: var(--grad-full);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--muted);
  max-width: 600px;
  margin-bottom: 1.75rem;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Home grid ──────────────────────────────────────────────────────── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.home-grid article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  transition: border-color 0.2s, transform 0.2s;
}
.home-grid article:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}

/* ── About ──────────────────────────────────────────────────────────── */
.about-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3rem;
  align-items: start;
  margin-top: 1.5rem;
}

@media (max-width: 640px) {
  .about-layout { grid-template-columns: 1fr; }
}

.about-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

/* ── Blog ───────────────────────────────────────────────────────────── */
.post-card {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
}
.post-card:last-of-type { border-bottom: none; }

.post-meta { color: var(--muted); font-size: 0.9rem; }

.tag {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 6px;
  font-size: 0.78rem;
  color: #5b9fd4;
  margin-left: 2px;
}

.post-body {
  max-width: 720px;
  line-height: 1.8;
}
.post-body h2, .post-body h3 { margin-top: 2rem; }
.post-body code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  font-size: 0.88em;
  color: #5b9fd4;
}
.post-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius);
  overflow-x: auto;
}

/* ── Projects grid ──────────────────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.2s, transform 0.2s;
}
.project-card:hover {
  border-color: var(--magenta);
  transform: translateY(-2px);
}

/* ── Game of Life ────────────────────────────────────────────────────── */
.gol-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.gol-controls button { margin: 0; }

.gol-canvas {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: crosshair;
  width: 100%;
  max-width: 100%;
}

.gol-hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.5rem; }

/* ── N-gram Generator ───────────────────────────────────────────────── */
.ngram-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}

@media (max-width: 700px) {
  .ngram-layout { grid-template-columns: 1fr; }
}

.ngram-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}
.ngram-options button { margin: 0; }

.ngram-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-height: 200px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text);
}

.ngram-stats {
  display: block;
  color: var(--muted);
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

/* ── Inputs & textareas ─────────────────────────────────────────────── */
input, textarea, select {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--radius) !important;
}
input:focus, textarea:focus {
  border-color: var(--cyan) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15) !important;
}

/* ── Range slider ───────────────────────────────────────────────────── */
input[type="range"] {
  accent-color: var(--cyan);
  border: none !important;
  background: transparent !important;
}

/* ── HR ─────────────────────────────────────────────────────────────── */
hr {
  border: none;
  height: 1px;
  background: var(--grad-full);
  opacity: 0.35;
  margin: 2rem 0;
}

/* ── Chess ──────────────────────────────────────────────────────────── */
.chess-wrap {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.chess-sidebar {
  min-width: 160px;
  flex-shrink: 0;
}

.chess-status {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.chess-status[data-state="check"] { border-color: #ff8c00; color: #ff8c00; }
.chess-status[data-state="over"]  { border-color: var(--cyan); color: var(--cyan); }

.chess-captured-row {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.chess-captured-label { display: block; }

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(480px, 100%);
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.chess-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.chess-cell span {
  font-size: clamp(1.2rem, 4.5vw, 2.6rem);
  line-height: 1;
  z-index: 1;
}
.chess-cell span.wp {
  color: #fff;
  text-shadow:
    -1px -1px 0 #333, 1px -1px 0 #333,
    -1px  1px 0 #333, 1px  1px 0 #333;
}
.chess-cell span.bp {
  color: #111;
  text-shadow: 0 1px 2px rgba(255,255,255,0.3);
}
.chess-cell.light { background: #f0d9b5; }
.chess-cell.dark  { background: #b58863; }
.chess-cell.selected  { background: #f6f669 !important; }
.chess-cell.legal::before {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(0,0,0,0.18);
  z-index: 0;
}
.chess-cell.legal:not(:empty)::before { background: rgba(0,0,0,0); box-shadow: inset 0 0 0 3px rgba(0,0,0,0.2); width: 92%; height: 92%; }
.chess-cell.in-check { background: rgba(220,50,50,0.7) !important; }

.coord-r, .coord-f {
  position: absolute;
  font-size: 0.55rem;
  font-style: normal;
  font-weight: 600;
  color: rgba(0,0,0,0.45);
  line-height: 1;
}
.coord-r { top: 2px; left: 3px; }
.coord-f { bottom: 2px; right: 3px; }

/* ── Chess mobile ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .chess-wrap { flex-direction: column; }
  .chess-sidebar {
    width: 100%;
    min-width: unset;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
  }
  .chess-status { flex: 1 1 100%; }
}

/* ── Tetris ─────────────────────────────────────────────────────────── */
.tetris-wrap {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.tetris-canvas {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.tetris-next-canvas {
  display: block;
  background: var(--bg);
  border-radius: 4px;
}

.tetris-sidebar {
  min-width: 120px;
  flex-shrink: 0;
}

.tetris-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.tetris-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 0.15rem;
}

.tetris-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Tetris mobile controls ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .tetris-wrap { flex-direction: column; align-items: center; }
  .tetris-sidebar { display: flex; flex-wrap: wrap; gap: 0.5rem; width: 100%; min-width: unset; }
  .tetris-panel { flex: 1; }
  .tetris-mobile-btns { display: flex; }
}

.tetris-mobile-btns {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  width: 100%;
}

.tetris-btn-row {
  display: flex;
  gap: 0.75rem;
}

.tetris-btn {
  width: 68px;
  height: 68px;
  font-size: 1.6rem;
  border-radius: var(--radius) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  padding: 0 !important;
}
