/* Roberto Sabanal: plain black and white, built on a visible 12-column grid.
   Everything snaps to the column lines drawn by .grid-lines. */

@font-face {
  font-family: 'Satoshi Variable';
  src: url('../fonts/Satoshi-Variable.ttf') format('truetype');
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --bg: #000;
  --fg: #fff;
  --dim: #8a8a8a;
  --line: #2a2a2a;
  --grid: #151515; /* background column rules: barely there */
  --surface: #0a0a0a;
  --accent: #daffd6; /* the old site's mint green, used for the call to action */
  --on-accent: #000;
  --text2: #d4d4d4;
  color-scheme: dark;
  --line-strong: #fff;
  --cols: 12;
  --pad: 20px; /* inner padding of every grid cell */
  --max: 1440px;
  --font: 'Satoshi Variable', 'Satoshi', Arial, sans-serif;
}

[data-theme='light'] {
  --bg: #fff;
  --fg: #000;
  --dim: #6b6b6b;
  --line: #d6d6d6;
  --line-strong: #000;
  --grid: #f7f7f7;
  --surface: #f4f4f4;
  --accent: #a6efa0; /* same mint family as dark mode, deeper so it reads on white */
  --text2: #333;
  color-scheme: light;
}

@media (max-width: 767px) {
  :root { --cols: 4; --pad: 14px; }
}

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

html { -webkit-text-size-adjust: 100%; }

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

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--fg); color: var(--bg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

/* ---- the grid ------------------------------------------------------------ */

.page {
  position: relative;
  max-width: var(--max);
  margin: 0 auto;
  border-left: 1px solid var(--grid);
  border-right: 1px solid var(--grid);
}

/* column rules, drawn once behind everything so content visibly sits on them */
.grid-lines {
  position: fixed;
  inset: 0 0 0 0;
  max-width: var(--max);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  pointer-events: none;
  z-index: 0;
}
.grid-lines i { border-left: 1px solid var(--grid); }
.grid-lines i:first-child { border-left: 0; }

.page > * { position: relative; z-index: 1; }

.row {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  border-top: 1px solid var(--line);
}
.row.first { border-top: 0; }
.row.strong { border-top-color: var(--line-strong); }

.cell { padding: var(--pad); min-width: 0; }

/* column spans: .cN spans N of 12 columns on desktop; on mobile (4 cols) every cell is full width, .m2 spans half */
@media (min-width: 768px) {
  .c1 { grid-column: span 1; } .c2 { grid-column: span 2; } .c3 { grid-column: span 3; }
  .c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
  .c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; }
  .c10 { grid-column: span 10; } .c12 { grid-column: 1 / -1; }
  .s4 { grid-column-start: 4; } .s5 { grid-column-start: 5; } .s7 { grid-column-start: 7; } .s9 { grid-column: 9 / -1; } .s10 { grid-column-start: 10; }
}
@media (max-width: 767px) {
  .cell { grid-column: 1 / -1; }
  .cell.m2 { grid-column: span 2; }
}

/* ---- type ---------------------------------------------------------------- */

.label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 0;
}
.fg { color: var(--fg); }

h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.03em; line-height: 1.02; }

.display {
  font-size: clamp(56px, 13.4vw, 200px);
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 0.88;
  text-transform: uppercase;
}
.h2 { font-size: clamp(32px, 4.4vw, 64px); }
.h3 { font-size: clamp(22px, 2.2vw, 32px); letter-spacing: -0.02em; line-height: 1.1; }
.lead { font-size: clamp(18px, 1.7vw, 24px); line-height: 1.35; letter-spacing: -0.01em; margin: 0; }
p { margin: 0; }
.dim { color: var(--dim); }

/* ---- header -------------------------------------------------------------- */

.site-header { position: sticky; top: 0; z-index: 10 !important; background: var(--bg); }
.site-header .row { align-items: center; }
.logo { font-weight: 700; letter-spacing: -0.02em; font-size: 18px; }

.nav { display: flex; gap: 28px; justify-content: center; align-items: center; }
/* desktop: nav spans the full row so it centers on the page; the logo sits above it at the left */
@media (min-width: 768px) {
  .site-header .head-left, .site-header .nav { grid-row: 1; }
  .site-header .nav { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto 1fr; pointer-events: none; }
  .nav-main { grid-column: 2; display: flex; align-items: center; gap: 28px; }
  .nav-end { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 24px; }
  .site-header .nav > * { pointer-events: auto; }
  .site-header .head-left { grid-column: 1 / span 4; position: relative; z-index: 1; align-self: center; justify-self: start; }
}
.nav a { font-size: 14px; position: relative; padding: 2px 0; }
.nav a::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--fg); transform: scaleX(0); transform-origin: left; transition: transform 150ms ease; }
.nav a:hover::after, .nav a[aria-current='page']::after { transform: scaleX(1); }
.nav a.cta { background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); padding: 10px 18px; font-size: 15px; font-weight: 600; }
.nav .cta::after { display: none; }
.nav .cta { --gl-bg: var(--accent); }

/* mobile menu button: hidden on desktop */
.menu-btn { display: none; font: inherit; font-size: 14px; font-weight: 500; color: var(--fg); background: none; border: 1px solid var(--fg); padding: 6px 14px; cursor: pointer; }
.head-left { display: flex; justify-content: space-between; align-items: center; }

/* plus icon: two bars, turns into a cross when the menu is open */
.plus { position: relative; width: 12px; height: 12px; flex: none; transition: transform 150ms ease; }
.plus::before, .plus::after { content: ''; position: absolute; background: currentColor; }
.plus::before { left: 0; right: 0; top: 5.5px; height: 1px; }
.plus::after { top: 0; bottom: 0; left: 5.5px; width: 1px; }
.menu-btn[aria-expanded='true'] .plus { transform: rotate(45deg); }

@media (max-width: 767px) {
  .nav-main, .nav-end { display: contents; }
  .site-header .row { grid-template-columns: 1fr; }
  .site-header .cell { padding-top: 12px; padding-bottom: 12px; }
  .head-left { position: relative; z-index: 2; background: var(--bg); }
  .menu-btn { display: inline-flex; align-items: center; gap: 10px; }

  /* full-screen menu */
  .nav {
    display: none;
    position: fixed; inset: 0; z-index: 1;
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0;
    background: var(--bg);
    overflow-y: auto;
  }
  .site-header .nav { padding: 76px var(--pad) 24px; }
  .menu-open .nav { display: flex; }
  .menu-open { overflow: hidden; }
  .nav a, .nav .theme-toggle {
    font-size: clamp(36px, 11vw, 56px); font-weight: 900; letter-spacing: -0.04em; line-height: 1;
    text-transform: uppercase; text-align: left;
    padding: 20px 0; border-bottom: 1px solid var(--line);
  }
  .nav a::after { display: none; }
  .nav a[aria-current='page'] { text-decoration: underline; text-underline-offset: 8px; text-decoration-thickness: 3px; }
  .nav .theme-toggle { font-size: clamp(36px, 11vw, 56px); padding: 20px 0; }
  .nav .theme-toggle span.on { text-underline-offset: 8px; text-decoration-thickness: 3px; }
  .nav a.cta { margin-top: auto; border: 1px solid var(--accent); border-bottom: 1px solid var(--accent); font-size: 22px; font-weight: 500; letter-spacing: 0; text-transform: none; text-align: center; padding: 16px; }
  .nav .cta { --gl-bg: var(--accent); }
}

/* ---- hero ---------------------------------------------------------------- */

.hero .display { padding: clamp(28px, 6vw, 88px) var(--pad) clamp(16px, 3vw, 40px); }
.hero .meta { display: flex; flex-direction: column; justify-content: space-between; gap: 16px; }

/* ---- buttons / links ------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--fg); padding: 12px 20px;
  font-size: 15px; font-weight: 500;
  transition: background 150ms, color 150ms;
}
.btn:hover { background: var(--fg); color: var(--bg); }
.btn svg { width: 18px; height: 18px; }

.arrow { display: inline-block; transition: transform 150ms ease; }
a:hover .arrow { transform: translate(3px, -3px); }

/* ---- marquee ------------------------------------------------------------- */

.marquee { overflow: hidden; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); background: var(--bg); }
.marquee-track { display: flex; width: max-content; animation: slide 36s linear infinite; }
.marquee span { padding: 14px 0; font-size: 13px; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; }
.marquee span::after { content: '/'; padding: 0 28px; color: var(--dim); }
@keyframes slide { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee-track { animation: none; } }

/* ---- services ------------------------------------------------------------ */

.service { display: flex; flex-direction: column; gap: 14px; min-height: 240px; border-top: 1px solid var(--line); }
.service:nth-child(-n + 3) { border-top: 0; }
.service .num { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.service h3 { margin-top: auto; }
.service p { color: var(--dim); font-size: 15px; max-width: 36ch; }

/* ---- work ---------------------------------------------------------------- */

.project { display: flex; flex-direction: column; gap: 18px; border-top: 1px solid var(--line); }
.project:nth-child(-n + 2) { border-top: 0; }
.project figure { margin: 0; border: 1px solid var(--line); background: var(--surface); aspect-ratio: 16 / 10; overflow: hidden; }
.project img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform 150ms ease; }
.project:hover img { transform: scale(1.03); }
.project-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.project .num { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.project .role { color: var(--dim); font-size: 15px; max-width: 52ch; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.tags li { border: 1px solid var(--line); padding: 3px 10px; font-size: 12px; color: var(--dim); }
.project .visit { margin-top: auto; font-size: 14px; font-weight: 500; border-bottom: 1px solid var(--fg); align-self: flex-start; padding-bottom: 1px; }

/* ---- connect / footer ---------------------------------------------------- */

.connect-big { font-size: clamp(40px, 9vw, 140px); font-weight: 900; letter-spacing: -0.05em; line-height: 0.9; text-transform: uppercase; display: block; padding: clamp(24px, 5vw, 72px) var(--pad); }
.connect-big:hover { background: var(--fg); color: var(--bg); }
.links { display: flex; flex-direction: column; gap: 6px; }
.links a { display: inline-flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 15px; }
.links a:hover { border-bottom-color: var(--fg); }
.links a:last-child { border-bottom: 0; }
.links .lk { display: inline-flex; align-items: center; gap: 10px; }
.links .ico { width: 16px; height: 16px; fill: none; stroke: var(--dim); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.links .ico-fill { fill: var(--dim); stroke: none; }
.foot { font-size: 13px; color: var(--dim); }

/* ---- blog list ----------------------------------------------------------- */

.post-card { display: flex; flex-direction: column; gap: 16px; height: 100%; }
.post-card figure { margin: 0; border: 1px solid var(--line); aspect-ratio: 3 / 2; overflow: hidden; background: var(--surface); }
.post-card img { width: 100%; height: 100%; object-fit: cover; transition: transform 150ms ease; }
.post-card:hover img { transform: scale(1.03); }
.post-card .h3 { text-wrap: balance; }
.post-card .byline { display: flex; justify-content: space-between; gap: 12px; }
.post-card-wrap { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.post-card-wrap:nth-child(3n + 1) { border-left: 0; }
.posts .post-card-wrap:nth-child(-n + 3) { border-top: 0; }
@media (max-width: 767px) { .post-card-wrap { border-left: 0 !important; } .posts .post-card-wrap:nth-child(-n + 3) { border-top: 1px solid var(--line); } .posts .post-card-wrap:first-child { border-top: 0; } }

/* ---- blog post ----------------------------------------------------------- */

.post-title { font-size: clamp(36px, 6vw, 88px); font-weight: 900; letter-spacing: -0.045em; line-height: 0.96; text-wrap: balance; }
.post-cover { margin: 0; border: 1px solid var(--line); aspect-ratio: 21 / 9; overflow: hidden; background: var(--surface); }
.post-cover img { width: 100%; height: 100%; object-fit: cover; }

.prose { font-size: 18px; line-height: 1.65; max-width: 68ch; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { font-size: clamp(26px, 2.6vw, 36px); margin-top: 2em; line-height: 1.1; }
.prose h3 { font-size: 22px; margin-top: 1.8em; }
.prose a { border-bottom: 1px solid var(--fg); }
.prose a:hover { background: var(--fg); color: var(--bg); }
.prose strong { font-weight: 700; }
.prose blockquote { margin-left: 0; padding-left: 20px; border-left: 2px solid var(--fg); font-size: inherit; line-height: inherit; font-weight: 700; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 0.4em; }
.prose img { border: 1px solid var(--line); }
.prose code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.9em; border: 1px solid var(--line); padding: 1px 5px; }
.prose pre { overflow-x: auto; border: 1px solid var(--line); padding: 16px; }
.prose pre code { border: 0; padding: 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

/* ---- 404 ----------------------------------------------------------------- */

.notfound { min-height: 60vh; display: flex; flex-direction: column; justify-content: flex-end; gap: 20px; }

/* ---- motion: subtle reveal ----------------------------------------------- */

@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
}

/* ---- resume -------------------------------------------------------------- */

.job { display: flex; flex-direction: column; gap: 14px; }
.job .meta { display: flex; flex-wrap: wrap; gap: 4px 20px; color: var(--dim); font-size: 14px; }
.job .meta a { color: var(--fg); border-bottom: 1px solid var(--fg); }
.job ul { margin: 0; padding-left: 1.1em; max-width: 72ch; display: flex; flex-direction: column; gap: 8px; color: var(--text2); }
.job p { max-width: 72ch; }

/* ---- theme toggle -------------------------------------------------------- */

.theme-toggle { font: inherit; font-size: 14px; color: inherit; background: none; border: 0; padding: 2px 0; cursor: pointer; }
.theme-toggle > span { color: var(--dim); }
.theme-toggle .gl { color: inherit; }
.theme-toggle > span.on { color: var(--fg); font-weight: 600; text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
@media (hover: hover) { .theme-toggle:hover > span { color: var(--fg); } }

.visit-all { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; white-space: nowrap; padding: 10px 18px; background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); --gl-bg: var(--accent); transition: background 150ms, color 150ms; }
.visit-all:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); --gl-bg: var(--fg); }
section[id] { scroll-margin-top: 90px; }

/* ---- hero glitch: the word is cut along a slanted line; both halves jitter sideways on a loop ---- */

.glitch { position: relative; display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .glitch::before, .glitch::after {
    content: attr(data-text);
    position: absolute; left: 0; width: 100%;
    background: var(--bg);
  }
  .glitch::before { top: 0; clip-path: polygon(0 0, 100% 0, 100% 57%, 0 66%); animation: glitch-top 3s infinite ease-in-out 1s; }
  .glitch::after { bottom: 0; clip-path: polygon(0 100%, 100% 100%, 100% 57%, 0 66%); animation: glitch-bottom 3s infinite ease-in-out 1s; }

  @keyframes glitch-top {
    0%, 10%, 90%, 100% { transform: none; opacity: 1; }
    1% { transform: translateX(-10px); } 2% { transform: translateX(5px); opacity: 0; }
    3% { transform: translateX(-5px); opacity: 1; } 4% { transform: translateX(10px); }
    5% { transform: none; } 6% { transform: translateX(5px); } 7% { transform: translateX(-5px); } 8% { transform: translateX(15px); } 9% { transform: none; }
    91% { transform: translateX(-10px); } 92% { transform: translateX(5px); opacity: 0; }
    93% { transform: translateX(-5px); opacity: 1; } 94% { transform: translateX(10px); }
    95% { transform: none; } 96% { transform: translateX(5px); } 97% { transform: translateX(-5px); } 98% { transform: translateX(15px); } 99% { transform: none; }
  }
  @keyframes glitch-bottom {
    0%, 80%, 100% { transform: none; opacity: 1; }
    81% { transform: translateX(-10px); } 82% { transform: translateX(5px); opacity: 0; }
    83% { transform: translateX(-5px); opacity: 1; } 84% { transform: translateX(10px); }
    85% { transform: none; } 86% { transform: translateX(5px); } 87% { transform: translateX(-5px); } 88% { transform: translateX(15px); } 89%, 99% { transform: none; }
  }
}

.d1 { animation-delay: 0.15s; } .d2 { animation-delay: 0.3s; } .d3 { animation-delay: 0.45s; }

/* hero intro text: top-right of the headline on desktop, under it on smaller screens */
.hero-lead { padding-top: 0; }
@media (min-width: 1100px) {
  .hero .row.first { align-items: start; }
  .hero-lead { grid-row: 1; grid-column: 9 / -1; padding-top: clamp(36px, 6.4vw, 96px); font-size: clamp(18px, 1.9vw, 30px); line-height: 1.28; letter-spacing: -0.015em; }
  .hero .display { grid-row: 1; }
  .hero-cta { grid-row: 1; grid-column: 9 / -1; align-self: end; display: flex; justify-content: flex-end; padding-bottom: clamp(24px, 3.4vw, 52px); }
}

/* primary call to action: solid, inverts on hover */
.btn-solid { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-solid, .btn-solid:hover { --gl-bg: var(--accent); background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

/* hero call to action: large on desktop */
@media (min-width: 1100px) {
  .hero-cta .btn { padding: clamp(16px, 1.5vw, 24px) clamp(28px, 2.6vw, 44px); font-size: clamp(18px, 1.7vw, 28px); gap: 14px; }
  .hero-cta .btn svg, .hero-cta .arrow { font-size: 1.1em; }
}

/* hover glitch for navigation links and buttons: same slanted split as the hero word, looping while hovered */
.gl { position: relative; display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  :is(a, button):is(:hover, :focus-visible) .gl::before,
  :is(a, button):is(:hover, :focus-visible) .gl::after {
    content: attr(data-text);
    position: absolute; left: 0; width: 100%; white-space: nowrap;
    background: var(--gl-bg, var(--bg)); text-decoration: none;
  }
  :is(a, button):is(:hover, :focus-visible) .gl::before { top: 0; clip-path: polygon(0 0, 100% 0, 100% 55%, 0 65%); animation: gl-top 0.6s infinite; }
  :is(a, button):is(:hover, :focus-visible) .gl::after { bottom: 0; clip-path: polygon(0 100%, 100% 100%, 100% 55%, 0 65%); animation: gl-bottom 0.6s infinite; }

  @keyframes gl-top {
    0% { transform: translateX(-4px); } 8% { transform: translateX(3px); } 16% { transform: translateX(-2px); } 24%, 100% { transform: none; }
  }
  @keyframes gl-bottom {
    0% { transform: translateX(4px); } 10% { transform: translateX(-3px); } 18% { transform: translateX(2px); } 26%, 100% { transform: none; }
  }
}

/* the underline has to sit on the inline-block label, it doesn't pass through it */
.theme-toggle span.on { text-decoration: none; }
.theme-toggle span.on .gl { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.nav .theme-toggle span.on .gl { text-underline-offset: 8px; text-decoration-thickness: 3px; }
@media (min-width: 768px) { .nav .theme-toggle span.on .gl { text-underline-offset: 5px; text-decoration-thickness: 1px; } }
@media (max-width: 767px) { .nav .theme-toggle > span.on { font-weight: inherit; } }

/* room after the end of an article */
.prose.cell { padding-bottom: clamp(56px, 9vw, 140px); }

/* ---- contact form --------------------------------------------------------- */

.contact-intro { margin: 20px 0 0; max-width: 56ch; }
.contact-form { max-width: 720px; display: grid; gap: 28px; }
.field { display: grid; gap: 10px; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 18px; line-height: 1.4; color: var(--fg);
  background: transparent; border: 1px solid var(--line-strong); border-radius: 0; padding: 14px 16px;
}
.field textarea { resize: vertical; min-height: 160px; }
.field input::placeholder, .field textarea::placeholder { color: var(--dim); }
.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
.field.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.form-actions .btn { font: inherit; font-size: 15px; font-weight: 500; cursor: pointer; }
.form-actions .btn:disabled { opacity: 0.5; cursor: default; }
.form-status { margin: 0; font-size: 15px; }
.form-status[data-kind='error'] { text-decoration: underline; text-underline-offset: 4px; }
.form-alt { margin: 0; font-size: 15px; }
.form-alt a { border-bottom: 1px solid var(--fg); color: var(--fg); }
.cf-turnstile { min-height: 65px; }
