:root {
  --paper: #F4F2EC;
  --card: #FDFCF8;
  --ink: #1A1A18;
  --ink-soft: #6B695F;
  --line: #E4E1D5;
  --accent: #0A8A4F;        /* italic word, accents — swap to #FF5C00 for corgi-orange */
  --accent-dark: #086B3D;
  --btn-green: #0A8A4F;
  --cell: #0FA968;
  --food: #1A1A18;
  --snake-head: #0FA968;
  --snake-tail: #A8CDB6;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
}

[data-theme="dark"] {
  --paper: #121311;
  --card: #1B1C19;
  --ink: #ECEAE1;
  --ink-soft: #97958A;
  --line: #272823;
  --accent: #2FBF7F;
  --accent-dark: #06482A;
  --cell: #0FA968;
  --food: #ECEAE1;
  --snake-head: #0FA968;
  --snake-tail: #3A5A46;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  /* faint pixel-grid ruling, same 14px pitch as the snake's board */
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 14px 14px;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.25s, color 0.25s;
}

#board {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

::selection { background: rgba(15, 169, 104, 0.25); }

.card {
  position: relative;
  z-index: 1;
  width: min(100%, 620px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 16px 48px -24px rgba(0, 0, 0, 0.3);
  padding: clamp(1.6rem, 4.5vw, 2.75rem);
  transition: background-color 0.25s, border-color 0.25s, translate 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* konami robot scene — card slides up to give the CAD the floor */
body.bg-robot .card { translate: 0 clamp(-170px, -18vh, 0px); }

/* escape hatch out of a konami backdrop, back to the snake */
.bg-exit {
  position: fixed;
  left: 1.2rem;
  bottom: 1.2rem;
  z-index: 2;
  font-family: var(--sans);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.bg-exit:hover { color: var(--ink); border-color: var(--ink-soft); }
.bg-exit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.card > * { opacity: 0; animation: rise 0.55s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
.card > *:nth-child(2) { animation-delay: 0.08s; }
.card > *:nth-child(3) { animation-delay: 0.16s; }
.card > *:nth-child(4) { animation-delay: 0.24s; }
.card > *:nth-child(5) { animation-delay: 0.32s; }
.card > *:nth-child(6) { animation-delay: 0.4s; }
.card > *:nth-child(7) { animation-delay: 0.48s; }
.card > *:nth-child(8) { animation-delay: 0.56s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.meta .place::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.55em;
  border-radius: 50%;
  background: var(--cell);
  box-shadow: 0 0 0 0 rgba(15, 169, 104, 0.4);
  animation: ping 2.4s ease-out infinite;
}
@keyframes ping {
  0%   { box-shadow: 0 0 0 0 rgba(15, 169, 104, 0.4); }
  70%  { box-shadow: 0 0 0 7px rgba(15, 169, 104, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 169, 104, 0); }
}
.meta time { font-variant-numeric: tabular-nums; }
.meta a { color: inherit; text-decoration: none; }
.meta a:hover { color: var(--ink); }

h1 {
  margin-top: 1.5rem;
  font-size: clamp(3rem, 10.5vw, 4.9rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.02;
}
h1 em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--accent);
}
/* secret: the accent period links to the robot. left visually identical;
   a faint glow only on hover rewards the curious. */
h1 em .dot {
  color: inherit;
  text-decoration: none;
  cursor: default;
  transition: text-shadow 0.3s, color 0.3s;
}
h1 em .dot:hover { color: var(--cell); text-shadow: 0 0 12px var(--cell); }
h1 em .dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.bio {
  margin-top: 1.25rem;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--ink-soft);
  max-width: 44ch;
}
.bio a, .entry a {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: border-color 0.2s;
}
.bio a:hover, .entry a:hover { border-bottom-color: var(--accent); }

.links {
  margin-top: 1.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-decoration: none;
  padding: 0.72rem 1.25rem;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
}
.btn .arr { transition: transform 0.2s; }
.btn:hover .arr { transform: translate(2px, -2px); }
.btn:hover .arr-r { transform: translateX(2px); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.green {
  background: var(--btn-green);
  color: #fff;
  box-shadow: 0 2px 0 var(--accent-dark);
}
.btn.green:hover { background: #0B9857; }
.btn.green:active { box-shadow: 0 0 0 var(--accent-dark); }

.btn.dark {
  background: var(--ink);
  color: var(--card);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
}
.btn.dark:hover { opacity: 0.92; }
.btn.dark:active { box-shadow: 0 0 0 rgba(0, 0, 0, 0.55); }

.btn.ghost {
  border-color: var(--line);
  color: var(--ink);
  background: transparent;
}
.btn.ghost:hover { border-color: var(--ink-soft); }

.foot {
  margin-top: 2.1rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.84rem;
  color: var(--ink-soft);
}
.foot a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: color 0.2s, border-color 0.2s;
}
.foot a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.hint { font-family: var(--serif); font-style: italic; font-size: 0.92rem; }

/* about page */
.card.about h1 { font-size: clamp(2.4rem, 7vw, 3.6rem); }
.sec { margin-top: 2.1rem; }
.sec h2 {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line);
}
.entry { margin-top: 1.05rem; }
.e-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.e-head strong { font-weight: 600; }
.e-head .when {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.entry p {
  margin-top: 0.2rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 56ch;
}

/* theme toggle — keycap-styled, fixed top right */
.theme {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 2;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  font-size: 15px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}
.theme:hover { color: var(--ink); }
.theme:active { transform: translateY(1px); }
.theme:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* arrow-key overlay — lights up as you steer */
.keys {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0.8;
}
.krow { display: flex; gap: 4px; }
.key {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 7px;
  transition: background 0.1s, color 0.1s, transform 0.1s, border-color 0.1s;
}
.key.on {
  background: var(--btn-green);
  border-color: var(--accent-dark);
  color: #fff;
  transform: translateY(1px);
}
@media (pointer: coarse) { .keys { display: none; } }

@media (max-width: 480px) {
  .btn { flex: 1 1 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .card > * { animation: none; opacity: 1; }
  .meta .place::before { animation: none; }
  .btn, .btn .arr, .key, .theme, body, .card { transition: none; }
}
