/* ───────────────────────────────────────────────────────────────
   Bruno Arnaiz Santamaría — portfolio
   Paper white, ink black, one lime highlighter.
   Background: the StudyFlow cockpit dot grid — grey dots everywhere,
   the same dots in ink inside a 200px circle around the cursor.
   ─────────────────────────────────────────────────────────────── */

:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --paper: #FFFFFF;
  --tint: #F7F8F9;
  --fg: #0E0E10;
  --muted: #5F6068;
  --faint: #8A8B93;
  --line: #E4E5E9;
  --line-strong: #CFD1D6;
  --dot: #D9DBE0;
  --dot-hi: #0E0E10;
  --lime: #C6EB2F;
  --lime-soft: rgba(198, 235, 47, 0.55);

  --f-display: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --f-body: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --gutter: clamp(16px, 3vw, 48px);
  --bar-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar-h) + 16px); background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 16px/1.6 var(--f-body);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
strong { font-weight: 600; }
::selection { background: var(--lime); color: var(--fg); }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; border-radius: 4px; }

.wrap { width: 100%; padding-inline: var(--gutter); }

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 50;
  background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 8px;
  font: 500 14px var(--f-body); text-decoration: none; transition: top .2s;
}
.skip:focus { top: 12px; }

/* ── background: dot grid + ink around the cursor ── */
.dots, .ink { position: fixed; inset: 0; pointer-events: none; z-index: 0; background-size: 22px 22px; background-position: 0 0; }
.dots { background-image: radial-gradient(var(--dot) 1px, transparent 1.3px); }
.ink {
  background-image: radial-gradient(var(--dot-hi) 1.3px, transparent 1.7px);
  -webkit-mask-image: radial-gradient(circle 200px at var(--mx, -999px) var(--my, -999px), rgba(0,0,0,.55), transparent);
          mask-image: radial-gradient(circle 200px at var(--mx, -999px) var(--my, -999px), rgba(0,0,0,.55), transparent);
}
.bar, main, .foot { position: relative; z-index: 1; }

/* ── top bar ── */
.bar {
  position: sticky; top: 0; z-index: 20; height: var(--bar-h);
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar-in { height: 100%; display: flex; align-items: center; gap: 24px; }
.mark {
  font: 500 15px/1 var(--f-mono); letter-spacing: 0; text-decoration: none; color: var(--fg);
  display: inline-flex; align-items: center; gap: 7px; margin-right: auto; white-space: nowrap;
}
.mark::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 1px var(--fg); }
.nav { display: flex; gap: 22px; }
.nav a {
  font: 400 13px/1 var(--f-mono); color: var(--muted); text-decoration: none; letter-spacing: .01em;
  padding: 6px 0; background: linear-gradient(var(--lime), var(--lime)) left 100% / 0 2px no-repeat;
  transition: color .2s, background-size .3s var(--ease);
}
.nav a:hover { color: var(--fg); background-size: 100% 2px; }
.lang { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px; background: var(--paper); }
.lang button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font: 500 12px/1 var(--f-mono); letter-spacing: .06em; color: var(--muted);
  padding: 7px 11px; border-radius: 999px; transition: background .2s, color .2s;
}
.lang button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.lang button:not([aria-pressed="true"]):hover { color: var(--fg); }

/* ── shared bits ── */
.k {
  margin: 0 0 12px; font: 500 12px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 10px;
}
.k::before { content: ""; width: 14px; height: 6px; background: var(--lime); border-radius: 2px; box-shadow: 0 0 0 1px var(--fg); }
.sq { display: inline-block; width: 9px; height: 9px; background: var(--lime); box-shadow: 0 0 0 1px var(--fg); border-radius: 2px; flex: none; }

/* ── hero ── */
.hero {
  min-height: calc(100svh - var(--bar-h));
  display: flex; flex-direction: column; justify-content: center;
  padding-block: clamp(56px, 10vh, 120px) clamp(48px, 8vh, 96px);
}
.label {
  margin: 0 0 22px; display: inline-flex; align-items: center; gap: 12px;
  font: 500 13px/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase;
}
/* name: always one line, sized to fill the width (main.js fits it exactly;
   the calc() is the no-JS approximation) */
.name {
  margin: 0; align-self: flex-start; white-space: nowrap;
  font: 400 calc((100vw - 2 * var(--gutter)) / 9.6)/.95 var(--f-display); letter-spacing: -0.025em;
}
.name em { font-style: italic; color: var(--muted); }
/* lede: one line on desktop (fitted by main.js), wraps on phones */
.lede {
  margin: clamp(22px, 3vw, 40px) 0 0; max-width: 40ch;
  font: 400 clamp(1.15rem, 1.9vw, 1.5rem)/1.45 var(--f-body); letter-spacing: -0.01em; text-wrap: pretty;
}
@media (min-width: 760px) {
  .lede { max-width: none; align-self: flex-start; white-space: nowrap; font-size: clamp(1.1rem, 1.5vw, 2.1rem); }
}
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: clamp(26px, 3.6vw, 40px); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 48px; padding: 0 24px;
  border-radius: 999px; font: 500 15px/1 var(--f-body); text-decoration: none; white-space: nowrap;
  transition: background .25s, color .25s, border-color .25s, transform .25s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn-solid { background: var(--fg); color: var(--bg); border: 1px solid var(--fg); }
.btn-solid:hover { background: var(--lime); color: var(--fg); }
.btn-line { background: var(--paper); color: var(--fg); border: 1px solid var(--fg); }
.btn-line:hover { background: var(--fg); color: var(--bg); }

.meta {
  margin: clamp(48px, 8vh, 88px) 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--fg);
}
.meta div { padding: 14px 18px 0 0; }
.meta div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.meta dt { font: 500 11px/1 var(--f-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.meta dd { margin: 0; font: 400 15px/1.4 var(--f-body); display: flex; align-items: center; gap: 8px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 1px var(--fg); position: relative; flex: none; }
.pulse::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid var(--fg); opacity: 0;
  animation: ping 2.4s var(--ease) infinite;
}
@keyframes ping { 0% { transform: scale(.6); opacity: .6; } 80%, 100% { transform: scale(1.8); opacity: 0; } }

/* ── sections ── */
.sec { padding-block: clamp(72px, 11vw, 140px); border-top: 1px solid var(--line); }
.sec-grid { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: start; }
.sec-head { position: sticky; top: calc(var(--bar-h) + 32px); }
.idx { display: block; font: 500 13px/1 var(--f-mono); color: var(--faint); letter-spacing: .06em; margin-bottom: 14px; }
.sec-head h2 { margin: 0; font: 400 clamp(2.6rem, 4.6vw, 4rem)/.95 var(--f-display); letter-spacing: -0.02em; }
.stamp { margin: 16px 0 0; font: 400 13px/1.5 var(--f-mono); color: var(--muted); max-width: 26ch; }
.sec-body { min-width: 0; }

/* ── now ── */
.now-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.now-item, .events {
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: clamp(20px, 2.6vw, 28px);
}
.now-item p, .events p { margin: 0; font-size: 16.5px; line-height: 1.6; text-wrap: pretty; }
.events { margin-top: 20px; }
.event-list { list-style: none; margin: 18px 0 0; padding: 0; border-top: 1px solid var(--fg); }
.event {
  display: grid; grid-template-columns: 150px auto 1fr; align-items: baseline; gap: 6px 22px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.event time { font: 500 13px/1.4 var(--f-mono); color: var(--muted); }
.event a { font: 400 1.75rem/1 var(--f-display); text-decoration: none; letter-spacing: -0.01em; }
.event a:hover { background: var(--lime-soft); }
.event span { color: var(--muted); font-size: 15px; }
.events-empty { margin-top: 16px !important; color: var(--muted); }
.events .note { margin-top: 16px; font: 400 13px/1.5 var(--f-mono); color: var(--muted); }

/* ── projects ── */
.projects { display: grid; gap: 28px; }
.project {
  display: grid; grid-template-columns: minmax(0, 1fr);
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  transition: border-color .3s, box-shadow .3s;
}
.project:hover { border-color: var(--line-strong); box-shadow: 0 18px 40px -24px rgba(14,14,16,.25); }
.p-visual {
  margin: 0; padding: clamp(18px, 3vw, 40px) clamp(14px, 4vw, 64px); background: var(--tint); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  background-image: radial-gradient(var(--dot) 1px, transparent 1.3px); background-size: 14px 14px;
}
.p-visual svg { width: 100%; max-width: 620px; height: auto; overflow: visible; }

/* open source: a real terminal screenshot instead of a schematic */
.p-shot { flex-direction: column; gap: 14px; }
.p-shot a { display: block; width: 100%; max-width: 760px; }
.p-shot img {
  display: block; width: 100%; height: auto; border-radius: 10px;
  box-shadow: 0 0 0 1px var(--fg), 5px 5px 0 var(--fg); transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.p-shot a:hover img { transform: translate(-2px, -2px); box-shadow: 0 0 0 1px var(--fg), 7px 7px 0 var(--lime); }
.p-shot figcaption { width: 100%; max-width: 760px; font: 400 12px/1.55 var(--f-mono); color: var(--muted); text-wrap: pretty; }
.spec dd a { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
/* on phones keep the terminal readable: it scrolls sideways like a code block */
@media (max-width: 640px) {
  .p-shot a { overflow-x: auto; padding: 0 6px 8px 0; -webkit-overflow-scrolling: touch; }
  .p-shot img { width: 640px; max-width: none; }
  .p-shot a:hover img { transform: none; }
}
.p-body { padding: clamp(22px, 3vw, 40px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 0 clamp(24px, 4vw, 48px); align-items: start; }
.p-body > .p-intro { grid-column: 1; }
.p-body > .spec { grid-column: 2; margin-top: 4px; }
.p-name { margin: 0; font: 400 clamp(2.2rem, 3.6vw, 3rem)/1 var(--f-display); letter-spacing: -0.02em; }
.p-name span { font-style: italic; color: var(--muted); }
.p-tag { margin: 8px 0 0; font: 400 13px/1.5 var(--f-mono); color: var(--muted); }
.p-what { margin: 18px 0 0; font-size: 16px; line-height: 1.6; text-wrap: pretty; }
.spec { margin: 22px 0 0; border-top: 1px solid var(--fg); }
.spec div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.spec dt { font: 500 11px/1.9 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.spec dd { margin: 0; font-size: 14.5px; line-height: 1.55; display: flex; align-items: baseline; gap: 9px; }
.state { width: 8px; height: 8px; border-radius: 50%; flex: none; transform: translateY(-1px); }
.state.live { background: var(--lime); box-shadow: 0 0 0 1px var(--fg); }
.state.dev { background: var(--paper); box-shadow: 0 0 0 1px var(--fg); }
.more { text-decoration: none; border-bottom: 1px solid var(--fg); }
.more:hover { background: var(--lime-soft); }

/* schematic SVG */
.p-visual text { font: 500 12px var(--f-mono); fill: var(--fg); text-anchor: middle; }
.p-visual .cap { font-size: 11px; fill: var(--muted); letter-spacing: .04em; }
.p-visual .caption { text-anchor: start; font-size: 10px; fill: var(--faint); letter-spacing: .08em; text-transform: uppercase; }
.p-visual .boxes rect { fill: var(--paper); stroke: var(--fg); stroke-width: 1; }
.p-visual .db path, .p-visual .db ellipse { fill: var(--paper); stroke: var(--fg); stroke-width: 1.2; }
.p-visual .db ellipse { fill: var(--lime); }
.p-visual .db .thin { fill: none; stroke: var(--line-strong); }
.p-visual .agents circle { fill: var(--fg); }
.p-visual .agents text:not(.cap) { fill: var(--bg); font-size: 11px; }
.p-visual .panel > rect:first-child { fill: var(--paper); stroke: var(--fg); stroke-width: 1.2; }
.p-visual .panel .bar-a, .p-visual .panel .bar-b { fill: var(--line-strong); }
.p-visual .panel .col { fill: var(--fg); }
.p-visual .panel .col.hi { fill: var(--lime); stroke: var(--fg); stroke-width: 1; }
.p-visual .human circle { fill: var(--paper); stroke: var(--fg); stroke-width: 1.2; }
.p-visual .human path { fill: none; stroke: var(--fg); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.p-visual .lits circle { fill: var(--fg); }
.p-visual .lits .lits-name { fill: var(--lime); font: 400 22px var(--f-display); }
.p-visual .lits .lits-sub { fill: #B9BAC0; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.p-visual .flow { fill: none; stroke: var(--fg); stroke-width: 1.2; stroke-dasharray: 3 6; animation: flow 1.4s linear infinite; }
.p-visual .flow.soft { stroke: var(--faint); }
@keyframes flow { to { stroke-dashoffset: -18; } }

/* ── how I build ── */
.manifesto p { margin: 0 0 18px; font-size: 17px; line-height: 1.7; text-wrap: pretty; }
/* big serif lines run the full width of the column */
.opener {
  font: 400 clamp(1.6rem, 2.8vw, 3.1rem)/1.2 var(--f-display) !important; letter-spacing: -0.012em;
  max-width: none !important; text-wrap: pretty; margin-bottom: clamp(22px, 2.6vw, 36px) !important;
}
/* body text under an opener: two columns on wide screens so it also fills the width */
.cols { column-count: 2; column-gap: clamp(28px, 4vw, 64px); }
.cols p { margin: 0 0 18px; break-inside: auto; }
@media (max-width: 760px) { .cols { column-count: 1; } }
.pieces {
  margin: 36px 0 18px; font: 500 13px/1.5 var(--f-mono); color: var(--muted); letter-spacing: .04em;
}
.formula {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px;
  padding: clamp(20px, 3vw, 32px); background: var(--paper); border: 1px solid var(--fg); border-radius: 16px;
  box-shadow: 6px 6px 0 var(--fg);
}
.grp { display: inline-flex; align-items: center; gap: 14px; max-width: 100%; }
.term {
  font: 400 clamp(1.35rem, 2.5vw, 2.05rem)/1.15 var(--f-display); letter-spacing: -0.01em;
  padding: .25em .55em .3em; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper);
}
.term.result { background: var(--lime); border-color: var(--fg); font-style: italic; }
.op { font: 400 clamp(1.4rem, 2.4vw, 2rem)/1 var(--f-mono); color: var(--faint); }
#how .k { margin-top: 56px; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.rules li { border-top: 2px solid var(--fg); padding-top: 16px; }
.rules .n { font: 500 13px/1 var(--f-mono); color: var(--faint); }
.rules p { margin: 12px 0 0; font: 400 1.35rem/1.3 var(--f-display); letter-spacing: -0.005em; text-wrap: pretty; }

/* ── stack ── */
.stack { border-top: 1px solid var(--fg); }
.stack .row { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.stack h3 { margin: 0; font: 500 12px/1.9 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stack p { margin: 0; font-size: 16.5px; line-height: 1.65; }
.stack i { font-style: normal; color: var(--faint); font-size: .9em; }

/* ── about ── */
.about p { margin: 0 0 18px; font-size: 18px; line-height: 1.65; text-wrap: pretty; }
.about em { font-style: normal; background: linear-gradient(transparent 58%, var(--lime-soft) 58%); }

/* ── contact ── */
.contact-lede { margin: 0 0 clamp(28px, 3vw, 44px); font: 400 clamp(2rem, 4.3vw, 4.6rem)/1.06 var(--f-display); letter-spacing: -0.018em; text-wrap: pretty; }
.links { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--fg); }
.links a {
  display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; align-items: baseline; gap: 18px;
  padding: 20px 4px; border-bottom: 1px solid var(--line); text-decoration: none;
  background: linear-gradient(var(--lime), var(--lime)) left / 0 100% no-repeat;
  transition: background-size .45s var(--ease), padding .3s var(--ease);
}
.links a:hover, .links a:focus-visible { background-size: 100% 100%; padding-left: 14px; }
.lk { font: 500 12px/1 var(--f-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lv { font: 400 clamp(1.4rem, 2.6vw, 2rem)/1.1 var(--f-display); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.ar { font: 400 18px/1 var(--f-mono); }
.freelance { margin: 28px 0 0; display: flex; gap: 12px; align-items: baseline; color: var(--muted); font-size: 15px; }

/* ── footer ── */
.foot { border-top: 1px solid var(--line); padding-block: 28px; background: rgba(255,255,255,.85); }
.foot-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; font: 400 12px/1.5 var(--f-mono); color: var(--muted); }

/* ── reveal on scroll (only when JS runs) ── */
.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: calc(var(--d, 0) * 90ms); }
.js .reveal.in { opacity: 1; transform: none; }

/* ── responsive ── */
@media (max-width: 1080px) {
  .p-body { grid-template-columns: minmax(0, 1fr); }
  .p-body > .spec { grid-column: 1; margin-top: 22px; }
}
@media (max-width: 920px) {
  .nav { display: none; }
  .sec-grid { grid-template-columns: 1fr; }
  .sec-head { position: static; }
  .rules { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .now-grid { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr; }
  .meta div { padding: 12px 0; }
  .meta div + div { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .event { grid-template-columns: 1fr; gap: 4px; }
  .stack .row { grid-template-columns: 1fr; gap: 4px; }
  .spec div { grid-template-columns: 1fr; gap: 2px; }
  .links a { grid-template-columns: minmax(0, 1fr) auto; }
  .lk { grid-column: 1 / -1; }
  .formula { box-shadow: 4px 4px 0 var(--fg); }
  .cta .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
