/* piferrer.co.uk — one stylesheet for every page.
   Palette: warm paper + ink, with four "puzzle piece" accents that echo
   Mapzzle (teal) and Defensa La Llengua (indigo + sun). */

@font-face {
  font-family: 'Bricolage';
  src: url('/fonts/bricolage.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --bg: #faf7f2;
  --bg-alt: #f3eee5;
  --card: #ffffff;
  --ink: #14213d;
  --ink-soft: #4b5568;
  --muted: #7a8396;
  --line: #e6dfd2;

  --coral: #ef6a5a;
  --sun: #f5c244;
  --teal: #1b9d91;
  --indigo: #5b6fd6;

  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 8px 24px rgba(20, 33, 61, .07);
  --shadow-lift: 0 2px 4px rgba(20, 33, 61, .08), 0 18px 40px rgba(20, 33, 61, .12);

  --display: 'Bricolage', ui-sans-serif, system-ui, sans-serif;
  --body: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 18px;
  --wrap: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420;
    --bg-alt: #131a29;
    --card: #182033;
    --ink: #eef1f7;
    --ink-soft: #b3bccd;
    --muted: #8590a6;
    --line: #273149;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420;
  --bg-alt: #131a29;
  --card: #182033;
  --ink: #eef1f7;
  --ink-soft: #b3bccd;
  --muted: #8590a6;
  --line: #273149;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .35), 0 18px 40px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 var(--body);
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--display); line-height: 1.1; margin: 0; letter-spacing: -.02em; }
p { margin: 0 0 1em; }
a { color: inherit; }
img { max-width: 100%; display: block; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

:focus-visible { outline: 3px solid var(--indigo); outline-offset: 3px; border-radius: 6px; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 18px; }
.monogram {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  font: 800 14px/1 var(--display); color: #fff; letter-spacing: -.02em;
  background: conic-gradient(from 45deg, var(--coral) 0 25%, var(--sun) 0 50%, var(--teal) 0 75%, var(--indigo) 0);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav a { text-decoration: none; font-size: 15px; font-weight: 500; color: var(--ink-soft); padding: 8px 12px; border-radius: 10px; }
.nav a:hover { color: var(--ink); background: var(--bg-alt); }
.nav a[aria-current="page"] { color: var(--ink); }

.nav a.lang {
  font: 700 13px/1 var(--body); letter-spacing: .04em; color: var(--ink);
  border: 1px solid var(--line); background: var(--card); padding: 11px 10px; margin-left: 4px;
}
.nav a.lang:hover { border-color: var(--ink); background: var(--card); }

.lang-note {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 12px;
  box-shadow: var(--shadow-lift); font-size: 15px;
}
.lang-note a { color: var(--sun); font-weight: 700; white-space: nowrap; }
.lang-note button { background: none; border: 0; color: inherit; font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 6px; opacity: .7; }
.lang-note button:hover { opacity: 1; }
@media (max-width: 480px) { .lang-note > span { display: none; } }

.theme-toggle {
  margin-left: 4px; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun-i { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun-i { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: block; }
}

@media (max-width: 720px) {
  .nav a.hide-sm { display: none; }
  .brand span.name { display: none; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  font: 600 16px/1 var(--body); padding: 14px 20px; border-radius: 12px;
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--bg);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn svg { width: 18px; height: 18px; }

/* ---------- Hero ---------- */

.hero { padding: 64px 0 48px; }
.hero .wrap { display: grid; grid-template-columns: 1.15fr .85fr; gap: 48px; align-items: center; }
@media (max-width: 900px) { .hero .wrap { grid-template-columns: 1fr; gap: 32px; } .hero { padding-top: 32px; } }

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  color: var(--teal); background: color-mix(in srgb, var(--teal) 12%, transparent);
  padding: 6px 12px; border-radius: 999px; margin-bottom: 20px;
}
.eyebrow .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 0 0 var(--teal); animation: ping 2.4s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--teal) 60%, transparent); } 80%, 100% { box-shadow: 0 0 0 10px transparent; } }

.hero h1 { font-size: clamp(40px, 6.2vw, 72px); font-weight: 800; margin-bottom: 20px; }
.hero h1 .hl { position: relative; white-space: nowrap; isolation: isolate; }
.hero h1 .hl::after {
  content: ''; position: absolute; left: -2%; right: -2%; bottom: .06em; height: .32em; z-index: -1;
  background: var(--sun); border-radius: 4px; transform: rotate(-1.2deg); opacity: .85;
}
.hero .lede { font-size: clamp(18px, 2vw, 20px); color: var(--ink-soft); max-width: 36em; margin-bottom: 28px; }
.hero .ctas { display: flex; gap: 12px; flex-wrap: wrap; }

/* Jigsaw */
.puzzle { position: relative; max-width: 420px; width: 100%; margin: 0 auto; }
.puzzle svg { width: 100%; height: auto; overflow: visible; touch-action: none; }
.piece { cursor: grab; transition: transform .55s cubic-bezier(.34, 1.56, .64, 1), filter .2s; }
.piece.dragging { cursor: grabbing; transition: none; filter: drop-shadow(0 14px 18px rgba(20, 33, 61, .28)); }
.piece path { stroke: var(--bg); stroke-width: 3; stroke-linejoin: round; }
.piece:hover path { filter: brightness(1.06); }
.piece text { pointer-events: none; user-select: none; -webkit-user-select: none; }
.piece .t1 { font: 800 30px var(--display); letter-spacing: -.02em; }
.piece .t1-sm { font-size: 22px; }
.piece .t2 { font: 600 13px var(--body); opacity: .9; }
.puzzle .hint { text-align: center; font-size: 14px; color: var(--muted); margin-top: 14px; }
.puzzle .hint b { color: var(--ink-soft); font-weight: 600; }

/* ---------- Stats strip ---------- */

.stats { padding: 8px 0 24px; }
.stats ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) { .stats ul { grid-template-columns: repeat(2, 1fr); } }
.stats li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stats .num { font: 800 clamp(30px, 4vw, 40px)/1 var(--display); letter-spacing: -.03em; margin-bottom: 6px; }
.stats li:nth-child(1) .num { color: var(--coral); }
.stats li:nth-child(2) .num { color: var(--teal); }
.stats li:nth-child(3) .num { color: var(--indigo); }
.stats li:nth-child(4) .num { color: #d79b0b; }
:root[data-theme="dark"] .stats li:nth-child(4) .num { color: var(--sun); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stats li:nth-child(4) .num { color: var(--sun); } }
.stats .lbl { font-size: 15px; color: var(--ink-soft); line-height: 1.4; }

/* ---------- Sections ---------- */

section.block { padding: 88px 0; }
section.block.alt { background: var(--bg-alt); }
@media (max-width: 600px) { section.block { padding: 64px 0; } }

.sec-head { max-width: 680px; margin-bottom: 44px; }
.kicker { font: 700 13px/1 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--coral); margin-bottom: 14px; display: block; }
.sec-head h2 { font-size: clamp(32px, 4.5vw, 48px); font-weight: 800; margin-bottom: 14px; }
.sec-head p { font-size: 18px; color: var(--ink-soft); margin: 0; }

/* What I do */
.cards3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .cards3 { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
  box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
.card .ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 18px; color: #fff; }
.card .ico svg { width: 24px; height: 24px; }
.card h3 { font-size: 22px; margin-bottom: 10px; }
.card p { color: var(--ink-soft); font-size: 16px; margin: 0; }

.skills { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: 14px; font-weight: 500; padding: 7px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink-soft); }
.chip.k { font-weight: 700; color: var(--ink); border-color: transparent; background: transparent; padding-left: 0; }

/* ---------- Route (experience as a transit line) ---------- */

.route { position: relative; list-style: none; margin: 0; padding: 0; }
.stop { position: relative; display: grid; grid-template-columns: 150px 1fr; gap: 0 40px; padding-bottom: 36px; }
.stop:last-child { padding-bottom: 0; }
@media (max-width: 700px) { .stop { grid-template-columns: 1fr; padding-left: 40px; } }

/* the line */
.stop::before {
  content: ''; position: absolute; top: 14px; bottom: -14px; left: 169px; width: 8px; border-radius: 4px; background: var(--c);
}
.stop:last-child::before { bottom: auto; height: 30px; opacity: .35; }
@media (max-width: 700px) { .stop::before { left: 10px; } }
/* the station */
.stop::after {
  content: ''; position: absolute; top: 6px; left: 161px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg); border: 6px solid var(--c);
}
section.alt .stop::after { background: var(--bg-alt); }
@media (max-width: 700px) { .stop::after { left: 2px; } }

.when { font: 700 15px/1.3 var(--display); color: var(--ink-soft); padding-top: 6px; text-align: right; }
.when small { display: block; font: 500 13px var(--body); color: var(--muted); margin-top: 4px; }
@media (max-width: 700px) { .when { text-align: left; padding-top: 4px; margin-bottom: 4px; } .when small { display: inline; margin-left: 6px; } }

.stop-body { min-width: 0; padding-left: 0; }
@media (min-width: 701px) { .stop-body { padding-left: 16px; } }
.stop h3 { font-size: 24px; margin-bottom: 4px; }
.stop .role { font-weight: 600; color: var(--c-ink, var(--c)); margin-bottom: 12px; }
.stop .summary { color: var(--ink-soft); margin-bottom: 14px; }

.wins { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 10px; }
.wins li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font-size: 15.5px; color: var(--ink-soft); }
.wins li strong { color: var(--ink); font-weight: 650; display: block; margin-bottom: 2px; font-size: 16px; }
.wins .tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; color: var(--c-ink, var(--c)); background: color-mix(in srgb, var(--c) 14%, transparent); }

details.more { margin-top: 10px; }
details.more summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px;
  font-weight: 600; font-size: 15px; color: var(--ink); padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::after { content: '+'; font-weight: 700; color: var(--c); }
details.more[open] summary::after { content: '–'; }
details.more[open] summary { margin-bottom: 12px; }

.stop.edf { --c: var(--teal); }
.stop.own { --c: var(--coral); }
.stop.acn { --c: var(--indigo); }
.stop.esp { --c: var(--sun); --c-ink: #a87405; }
:root[data-theme="dark"] .stop.esp { --c-ink: var(--sun); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stop.esp { --c-ink: var(--sun); } }

.edu { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.edu > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.edu b { display: block; font-family: var(--display); font-size: 17px; margin-bottom: 2px; }
.edu span { font-size: 14.5px; color: var(--ink-soft); }
.edu-title { font: 700 22px var(--display); margin: 64px 0 16px; }

/* ---------- Projects ---------- */

.projects { display: grid; gap: 24px; }
.proj {
  display: grid; grid-template-columns: 1.1fr 1fr; background: var(--card); border: 1px solid var(--line);
  border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); transition: transform .25s, box-shadow .25s;
}
.proj:hover { transform: translateY(-4px); box-shadow: var(--shadow-lift); }
@media (max-width: 860px) { .proj { grid-template-columns: 1fr; } }
.proj .media { position: relative; min-height: 280px; display: grid; place-items: center; overflow: hidden; }
.proj .txt { padding: 36px; display: flex; flex-direction: column; }
@media (max-width: 600px) { .proj .txt { padding: 24px; } }
.proj .app { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.proj .app img { width: 52px; height: 52px; border-radius: 13px; box-shadow: var(--shadow); }
.proj h3 { font-size: 28px; }
.status { font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; display: inline-block; margin-top: 4px; }
.status.live { color: #0f7a4f; background: #d6f5e6; }
.status.soon { color: #8a5a00; background: #fdefc8; }
.proj p { color: var(--ink-soft); font-size: 16.5px; }
.proj .stack { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 22px; }
.proj .stack span { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 8px; background: var(--bg-alt); color: var(--ink-soft); }
.proj .links { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.proj .links .btn { padding: 11px 16px; font-size: 15px; }

.media.mapzzle { background: linear-gradient(160deg, #1b9d91, #136a82); }
.media.mapzzle img { width: 100%; height: 100%; object-fit: contain; }
.media.defensa { background: linear-gradient(160deg, #6279c6, #4a5fb0); padding: 28px 16px 0; align-items: end; }
.phones { display: flex; gap: 16px; justify-content: center; align-items: flex-end; }
.phones img { width: min(42%, 180px); border-radius: 22px 22px 0 0; border: 6px solid #1b2440; border-bottom: 0; box-shadow: 0 20px 40px rgba(0, 0, 0, .25); }
.phones img:nth-child(2) { transform: translateY(24px); }
.media.pipeline { background: #0f1a2b; padding: 24px; }
.term { width: 100%; max-width: 440px; font: 13.5px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace; color: #c9d4e6; }
.term .bar { display: flex; gap: 6px; margin-bottom: 14px; }
.term .bar i { width: 11px; height: 11px; border-radius: 50%; background: #3a4660; }
.term .bar i:nth-child(1) { background: var(--coral); } .term .bar i:nth-child(2) { background: var(--sun); } .term .bar i:nth-child(3) { background: #4ade80; }
.term .p { color: #4ade80; } .term .d { color: #7d8aa5; } .term .ok { color: var(--sun); }

/* ---------- Contact ---------- */

.contact { text-align: center; }
.contact .sec-head { margin: 0 auto 32px; }
.contact .ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.langs { margin-top: 28px; color: var(--muted); font-size: 15px; }

footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 14px; }
footer .wrap { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
footer a { color: var(--ink-soft); }

/* ---------- Reveal on scroll ---------- */

.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .piece { transition: none; }
  .eyebrow .dot { animation: none; }
}

/* ---------- Written pages (thoughts, 404) ---------- */

.page { padding: 64px 0 96px; }
.page .wrap { max-width: 760px; }
.page h1 { font-size: clamp(36px, 5vw, 56px); font-weight: 800; margin-bottom: 16px; }
.page .lede { font-size: 19px; color: var(--ink-soft); margin-bottom: 40px; }
.post-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.post-list a { display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; transition: transform .2s, box-shadow .2s; }
.post-list a:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.post-list h2 { font-size: 22px; margin-bottom: 6px; }
.post-list p { color: var(--ink-soft); margin: 0; font-size: 16px; }
.post-list time { font-size: 13px; color: var(--muted); font-weight: 600; }
.empty { border: 2px dashed var(--line); border-radius: 18px; padding: 32px; text-align: center; color: var(--ink-soft); }

article.post .meta { color: var(--muted); font-size: 15px; margin-bottom: 36px; }
article.post p, article.post li { font-size: 18.5px; line-height: 1.7; }
article.post h2 { font-size: 28px; margin: 44px 0 14px; }
article.post blockquote { margin: 28px 0; padding: 4px 0 4px 20px; border-left: 4px solid var(--sun); color: var(--ink-soft); font-size: 20px; }
