/* =========================================================
   RETRO B&W / ASCII THEME
   ========================================================= */
:root {
  /* Night (default) */
  --bg: #0a0a0a;
  --fg: #f2f2f2;
  --dim: #9a9a9a;
  --line: #f2f2f2;
  --shadow: #333;
  --faint: #333;
  --stripe: #1a1a1a;
  --invert-dim: #333;
  --scan: rgba(255, 255, 255, 0.025);
  --mono: "Space Mono", ui-monospace, monospace;
  --pixel: "VT323", "Space Mono", monospace;
  --text: "VT323", "Courier New", monospace; /* CRT terminal font for long text & prompts */
}

/* Day */
:root[data-theme="light"] {
  --bg: #efeee9;
  --fg: #0a0a0a;
  --dim: #555;
  --line: #0a0a0a;
  --shadow: #b5b5b0;
  --faint: #c9c8c2;
  --stripe: #dcdbd5;
  --invert-dim: #bdbdbd;
  --scan: rgba(0, 0, 0, 0.03);
}

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

html { scroll-behavior: smooth; scroll-padding-top: 64px; }

body {
  transition: background .2s, color .2s;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.75;
  letter-spacing: -0.01em;
}

/* CRT scanlines */
body::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background: repeating-linear-gradient(to bottom, var(--scan) 0 1px, transparent 1px 3px);
}

::selection { background: var(--fg); color: var(--bg); }

a { color: inherit; text-decoration: none; }

.container { width: min(1000px, 100% - 32px); margin-inline: auto; }

.cursor { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}
.nav__inner { display: flex; justify-content: space-between; align-items: center; height: 56px; gap: 12px; }
.nav { font-family: var(--pixel); }
.nav__logo { font-size: 1.6rem; line-height: 1; }
.tilde { font-family: var(--mono); font-size: 0.75em; } /* VT323 draws "~" like an "N" */
.nav__links { display: flex; gap: 6px; font-size: 1.35rem; line-height: 1; }
.nav__links a { padding: 2px 6px; }
.nav__links a:hover { background: var(--fg); color: var(--bg); }
.nav__links { margin-left: auto; }

/* Toggles: [ ☀|☾ ]  [ EN|ES ] — active option is inverted */
.nav__toggles { display: flex; gap: 8px; }
.toggle {
  display: inline-flex; border: 2px solid var(--line); background: var(--bg); color: var(--fg);
  font: 400 1.2rem/1.1 var(--pixel); cursor: pointer; padding: 0;
  box-shadow: 3px 3px 0 var(--shadow);
}
.toggle span { padding: 2px 7px; min-width: 28px; text-align: center; }
.toggle span + span { border-left: 2px solid var(--line); }
.toggle .is-active { background: var(--fg); color: var(--bg); }
.toggle:hover span:not(.is-active) { background: var(--stripe); }
.toggle:active { transform: translate(3px, 3px); box-shadow: none; }
.toggle:focus-visible, .btn:focus-visible { outline: 2px dashed var(--fg); outline-offset: 3px; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 40px;
  padding: 96px 0 72px;
}
.prompt { color: var(--dim); margin-bottom: 8px; }
.prompt span { color: var(--fg); }
.hero__name {
  font-family: "Jersey 15", var(--pixel); font-weight: 400;
  font-size: clamp(4rem, 11vw, 7.5rem); line-height: 0.92;
  text-transform: uppercase; letter-spacing: 0;
  text-shadow: 4px 4px 0 var(--shadow);
}
.hero__role { margin-top: 20px; max-width: 620px; line-height: 1.5; }
.hero__role span { color: var(--dim); font-weight: 400; }
.hero__meta { margin-top: 6px; color: var(--dim); font-family: var(--text); font-size: 1.3rem; line-height: 1.2; }
.hero__meta::before { content: "@ "; }
.hero__clock { margin-top: 2px; color: var(--dim); font-family: var(--text); font-size: 1.3rem; line-height: 1.2; }
.hero__clock time { color: var(--fg); }
.clock-colon { animation: blink 1s steps(1) infinite; }

/* ASCII avatar: 105 cols x 36 rows, scales with the viewport */
.ascii-art {
  font-family: "Courier New", var(--mono); font-weight: 700;
  font-size: min(7px, calc((100vw - 32px) / 64));
  line-height: 1.1; letter-spacing: 0;
  color: var(--fg); margin: 0; user-select: none;
}
/* Each theme shows its own version of the avatar */
.ascii-art--light { display: none; }
:root[data-theme="light"] .ascii-art--dark { display: none; }
:root[data-theme="light"] .ascii-art--light {
  display: block; color: #000;
  text-shadow: 0.35px 0 0 #000, -0.35px 0 0 #000; /* thicker strokes = more contrast */
}

/* ---------- Buttons: [ LABEL ] ---------- */
.btn {
  display: inline-block; padding: 8px 14px;
  border: 2px solid var(--line);
  font-weight: 700; font-size: 0.9rem; text-transform: uppercase;
  box-shadow: 4px 4px 0 var(--dim);
  transition: transform .1s, box-shadow .1s;
}
.btn::before { content: "[ "; }
.btn::after  { content: " ]"; }
.btn:hover { background: var(--fg); color: var(--bg); }
.btn:active { transform: translate(4px, 4px); box-shadow: none; }
.btn--primary { background: var(--fg); color: var(--bg); }
.btn--primary:hover { background: var(--bg); color: var(--fg); }

/* ---------- Dividers & section titles ---------- */
.divider { overflow: hidden; white-space: nowrap; color: var(--dim); user-select: none; }
.divider::before { content: "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="; }

.section { padding: 64px 0; }
.section__title {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--pixel); font-weight: 400; font-size: 2.4rem; line-height: 1;
  margin-bottom: 32px; white-space: nowrap; overflow: hidden;
}
.section__title::before { content: "~/"; color: var(--dim); margin-right: -12px; font-family: var(--mono); font-size: 0.75em; }
.section__title::after {
  content: "########################################################################################################";
  color: var(--faint); letter-spacing: 2px;
}

.sub-label { color: var(--dim); margin: 0 0 12px; }

/* Long-form text: retro typewriter face, tuned for legibility */
.hero__role, .card p, .now, .project__desc, .contact p {
  font-family: var(--text); font-size: 1.4rem; line-height: 1.3; letter-spacing: 0.01em;
}
/* VT323 has a single weight: emphasis by color, not faux-bold */
.hero__role, .card p strong, .now, .project__desc { font-weight: 400; } /* emphasis comes from .card strong color */

/* Shell prompts */
.prompt, .sub-label, .project__label { font-family: var(--text); font-size: 1.3rem; line-height: 1.2; }

/* ---------- About cards ---------- */
.about-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.card {
  border: 2px solid var(--line); padding: 22px;
  color: var(--dim); background: var(--bg);
  box-shadow: 6px 6px 0 var(--shadow);
}
.card strong { color: var(--fg); font-weight: 700; }
.card--wide { grid-column: 1 / -1; }
.card--invert { background: var(--fg); color: var(--invert-dim); box-shadow: 6px 6px 0 var(--dim); }
.card--invert strong, .card--invert .card__label { color: var(--bg); }
/* Education: one line per course, prefixed like terminal output */
.edu-item { display: block; margin-top: 10px; padding-left: 2ch; text-indent: -2ch; }
.edu-item::before { content: "> "; }
.edu-item--next { opacity: 0.8; }
.edu-link { font-weight: 700; border-bottom: 1px dashed currentColor; }
.edu-link:hover { background: var(--bg); color: var(--fg); }
.edu-item--next::before { content: "+ "; } /* upcoming */

/* $ cat hobbies.txt */
.sub-label--spaced { margin-top: 32px; }
.hobbies {
  max-width: 900px; color: var(--dim);
  font-family: var(--text); font-size: 1.4rem; line-height: 1.3;
  padding-left: 14px; border-left: 2px solid var(--line);
}
.hobbies strong { color: var(--fg); font-weight: 400; }

/* Stack grouped by area */
.stack-groups { display: grid; gap: 18px; }

.card__label { font-size: 1rem; line-height: 1.4; font-weight: 700; color: var(--fg); margin-bottom: 8px; letter-spacing: 0.05em; }

.now { margin: 32px 0 28px; }
.now__status { font-weight: 700; background: var(--fg); color: var(--bg); padding: 0 6px; margin-right: 6px; }

/* ---------- Tech badges ---------- */
.stack, .project__techs { display: flex; flex-wrap: wrap; gap: 8px; }
.tech {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--dim);
  font-size: 0.85rem;
  transition: background .1s;
}
.tech:hover { background: var(--fg); color: var(--bg); }
.tech__icon { display: grid; place-items: center; width: 22px; height: 22px; background: #fff; outline: 1px solid var(--dim); }
.tech__icon img {
  width: 16px; height: 16px; object-fit: contain;
  filter: grayscale(1) brightness(0.55) contrast(1.8);
}

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 28px; }
.project {
  display: flex; flex-direction: column;
  border: 2px solid var(--line);
  box-shadow: 8px 8px 0 var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.project:hover { transform: translate(-3px, -3px); box-shadow: 11px 11px 0 var(--dim); }

.project__bar {
  display: flex; justify-content: space-between;
  background: var(--fg); color: var(--bg);
  padding: 2px 10px; font-size: 0.8rem; font-weight: 700;
}
.project__body { display: flex; flex-direction: column; flex: 1; padding: 20px; }
.project__head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.project__logo {
  width: 60px; height: 60px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  border: 2px solid var(--line);
  font-family: var(--pixel); font-size: 2rem;
  background:
    repeating-linear-gradient(45deg, var(--stripe) 0 2px, transparent 2px 6px);
}
.project__logo img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) contrast(1.15); }
.project__name { font-family: var(--pixel); font-weight: 400; font-size: 1.9rem; line-height: 1; text-transform: uppercase; }
.project__desc { color: var(--dim); flex: 1; }
.project__label { color: var(--dim); margin: 18px 0 10px; }
.project__links {
  display: flex; gap: 16px; margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed var(--dim);
}
.project__links a { font-size: 0.85rem; font-weight: 700; padding: 0 4px; }
.project__links a:hover { background: var(--fg); color: var(--bg); }

/* ---------- Contact / Footer ---------- */
.contact p { color: var(--dim); }
.contact__links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 28px; }
.btn--contact {
  display: inline-flex; align-items: center; gap: 10px;
  text-transform: none; font-size: 0.95rem; padding: 10px 16px;
}
.btn--contact svg { width: 20px; height: 20px; flex-shrink: 0; fill: currentColor; }
.footer { padding: 24px 0 48px; color: var(--dim); font-size: 0.8rem; text-align: center; }
.footer pre { overflow: hidden; margin-bottom: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; padding: 64px 0 48px; }
  .ascii-art { justify-self: center; }
}
@media (max-width: 640px) {
  .about-grid { grid-template-columns: 1fr; }
  .projects { grid-template-columns: 1fr; }
  .nav__inner { flex-wrap: wrap; height: auto; padding: 10px 0; row-gap: 6px; }
  .nav__links { order: 3; width: 100%; margin-left: 0; font-size: 1.2rem; gap: 0; justify-content: space-between; }
  .nav__links a { padding: 2px 0; }
  .section__title { font-size: 2rem; }
  .btn--contact { width: 100%; font-size: 0.85rem; overflow-wrap: anywhere; }
}

/* =========================================================
   CV BUTTON
   ========================================================= */
.hero__cta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 28px; }
.btn--cmd { text-transform: none; font-weight: 700; }
/* CV buttons: same color as the page (black at night, white by day); invert only on hover/focus */
.btn--cv { background: var(--bg); color: var(--fg); }
.btn--cv:hover, .btn--cv:focus-visible { background: var(--fg); color: var(--bg); }

/* =========================================================
   TERMINAL WINDOW BAR (snake.exe)
   ========================================================= */
.term__bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--fg); color: var(--bg);
  padding: 2px 10px; font-size: 0.8rem; font-weight: 700;
}
.term__rerun {
  background: none; border: 0; color: inherit; cursor: pointer;
  font: inherit; padding: 0 2px;
}
.term__rerun:hover { background: var(--bg); color: var(--fg); }
.term__rerun:focus-visible { outline: 2px dashed var(--bg); outline-offset: 1px; }

/* =========================================================
   SNAKE
   ========================================================= */
.footer__egg { margin-top: 10px; font-family: var(--text); font-size: 1.15rem; }
.footer__snake {
  background: none; border: 1px dashed var(--dim); color: var(--fg);
  font: inherit; padding: 0 6px; cursor: pointer;
}
.footer__snake:hover { background: var(--fg); color: var(--bg); border-style: solid; }

body.no-scroll { overflow: hidden; }
.snake {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(2px);
}
.snake[hidden] { display: none; }
.snake__win {
  border: 2px solid var(--line); background: var(--bg);
  box-shadow: 10px 10px 0 var(--shadow);
  max-width: 100%;
}
.snake__hud {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 10px 16px 0; font-family: var(--text); font-size: 1.3rem;
}
.snake__board {
  margin: 6px 16px 0; font-family: var(--mono); line-height: 1.05;
  font-size: min(18px, calc((100vw - 80px) / 30 / 0.62));
  user-select: none; touch-action: none;
}
.snake__msg { min-height: 1.2em; padding: 8px 16px 0; font-family: var(--text); font-size: 1.3rem; line-height: 1.2; }
.snake__help { padding: 6px 16px 14px; color: var(--dim); font-family: var(--text); font-size: 1.1rem; }
.snake__pad {
  display: none; grid-template-columns: repeat(3, 56px); grid-template-areas: ". up ." "left action right" ". down .";
  gap: 6px; justify-content: center; padding: 12px 16px 16px;
}
.snake__pad button {
  background: var(--bg); color: var(--fg); border: 2px solid var(--line);
  font: 1.3rem var(--pixel); padding: 6px 0; cursor: pointer;
}
.snake__pad button:active { background: var(--fg); color: var(--bg); }
.snake__pad [data-dir="up"] { grid-area: up; }
.snake__pad [data-dir="down"] { grid-area: down; }
.snake__pad [data-dir="left"] { grid-area: left; }
.snake__pad [data-dir="right"] { grid-area: right; }
.snake__pad [data-dir="action"] { grid-area: action; }
@media (hover: none), (max-width: 640px) {
  .snake__pad { display: grid; }
  .snake__help { display: none; }
}
