/* =========================================================
   Guillem Fernandez — pro.guillem.cat
   Design system shares the palette/type family used on
   engineeringprotocolstack.com for brand consistency, extended
   with a light mode and CV/portfolio-specific components.
   ========================================================= */

:root,
[data-theme="dark"] {
  --bg: #0b0d1c;
  --bg-alt: #10132a;
  --surface: #141833;
  --surface-2: #1a1f3d;
  --border: #262c52;
  --text: #f2f4fb;
  --text-muted: #a7add0;
  --text-faint: #6c7399;
  --text-inverse: #06131a;
  --cyan: #4fd1ff;
  --cyan-soft: rgba(79, 209, 255, 0.12);
  --amber: #e0a85c;
  --amber-soft: rgba(224, 168, 92, 0.14);
  --teal: #35d8c4;

  --radius: 14px;
  --radius-sm: 8px;
  --font-display: "Manrope", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --max: 1160px;
  --max-narrow: 760px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 32px -8px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, 0.65);
}

[data-theme="light"] {
  --bg: #f8f7f3;
  --bg-alt: #f1efe8;
  --surface: #ffffff;
  --surface-2: #f4f2ec;
  --border: #e4e0d4;
  --text: #201d14;
  --text-muted: #5c5745;
  --text-faint: #928c76;
  --text-inverse: #ffffff;
  --cyan: #0b7c94;
  --cyan-soft: rgba(11, 124, 148, 0.08);
  --amber: #a56a1f;
  --amber-soft: rgba(165, 106, 31, 0.1);
  --teal: #0d8f7f;

  --shadow-sm: 0 1px 2px rgba(30, 25, 10, 0.06);
  --shadow-md: 0 12px 32px -8px rgba(30, 25, 10, 0.12);
  --shadow-lg: 0 30px 70px -20px rgba(30, 25, 10, 0.18);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f8f7f3;
    --bg-alt: #f1efe8;
    --surface: #ffffff;
    --surface-2: #f4f2ec;
    --border: #e4e0d4;
    --text: #201d14;
    --text-muted: #5c5745;
    --text-faint: #928c76;
    --text-inverse: #ffffff;
    --cyan: #0b7c94;
    --cyan-soft: rgba(11, 124, 148, 0.08);
    --amber: #a56a1f;
    --amber-soft: rgba(165, 106, 31, 0.1);
    --teal: #0d8f7f;
  }
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: none;
  scroll-padding-top: 88px;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 900px 500px at 12% 0%, var(--cyan-soft), transparent 60%),
    radial-gradient(ellipse 900px 500px at 92% 10%, var(--amber-soft), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}

img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; color: var(--text); text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 1.3rem + 3vw, 3.1rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 1.95rem); margin: 0 0 1rem; }
h3 { font-size: 1.25rem; margin: 0 0 .6rem; }
p { color: var(--text-muted); margin: 0 0 1.1rem; max-width: 70ch; }
strong { color: var(--text); }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { color: var(--text-muted); }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }
.wrap--narrow { max-width: var(--max-narrow); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__mark { width: 36px; height: 36px; flex-shrink: 0; }
.brand__text { font-family: var(--font-display); font-weight: 800; font-size: .95rem; line-height: 1.1; }
.brand__text small { display: block; font-weight: 500; font-size: .68rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }

.nav-toggle { display: none; }
.nav-burger { display: none; }
.site-nav { display: flex; align-items: center; gap: 20px; font-size: .92rem; }
.site-nav a { color: var(--text-muted); font-weight: 500; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav-cta { background: linear-gradient(120deg, var(--cyan), var(--teal)); color: var(--text-inverse) !important; padding: 8px 16px; border-radius: 999px; font-weight: 700; }
[data-theme="light"] .nav-cta { color: #fff !important; }
.nav-cta:hover { opacity: .9; text-decoration: none; }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  color: var(--text-muted); background: transparent; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--cyan); color: var(--cyan); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 13px 24px; border-radius: 999px; font-weight: 700; font-family: var(--font-display); font-size: .95rem; border: 1px solid transparent; cursor: pointer; }
.btn-primary { background: linear-gradient(120deg, var(--cyan), var(--teal)); color: var(--text-inverse); }
[data-theme="light"] .btn-primary { color: #fff; }
.btn-primary:hover { opacity: .9; text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--cyan); color: var(--cyan); text-decoration: none; }
.btn-sm { padding: 9px 16px; font-size: .85rem; }

/* ---------- Hero ---------- */
.hero { padding: 64px 0 40px; overflow: hidden; }
.hero__inner { display: grid; grid-template-columns: 1.15fr .85fr; gap: 56px; align-items: center; }
.hero__eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--amber); background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); padding: 5px 12px; border-radius: 999px; margin-bottom: 18px; }
.hero__subtitle { font-size: 1.1rem; color: var(--text-muted); max-width: 50ch; margin-bottom: 1.7rem; }
.hero__actions { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 1.5rem; }
.hero__meta { font-size: .85rem; color: var(--text-faint); }
.hero__portrait { position: relative; justify-self: center; }
.hero__portrait img { width: 100%; max-width: 300px; border-radius: var(--radius); box-shadow: var(--shadow-lg), 0 0 0 1px var(--border); }

/* ---------- Sections ---------- */
section { padding: 52px 0; }
.section-head { text-align: center; max-width: 640px; margin: 0 auto 2.2rem; }
.section-head .eyebrow { color: var(--cyan); font-weight: 700; font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- Stat strip ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 18px; text-align: center; }
.stat-card .stat-num { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; color: var(--cyan); display: block; }
.stat-card .stat-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/* ---------- Cards / generic ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; }
.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; transition: transform .15s ease, border-color .15s ease; }
.info-card:hover { transform: translateY(-3px); border-color: var(--cyan); }
.info-card .tag-dot { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 800; font-size: .78rem; letter-spacing: .06em; color: var(--cyan); text-transform: uppercase; margin-bottom: .6rem; }

/* ---------- Book cross-promo ---------- */
.book-promo { display: grid; grid-template-columns: 220px 1fr; gap: 32px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; }
.book-promo img { border-radius: 8px; box-shadow: var(--shadow-md), 0 0 0 1px var(--border); }
.book-promo__actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 1rem; }

/* ---------- Posts ---------- */
.posts-list { display: grid; gap: 16px; }
.post-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; color: var(--text); }
.post-card:hover { border-color: var(--cyan); text-decoration: none; }
.post-card h3 { margin: 0 0 6px; font-size: 1.15rem; }
.post-card p { margin: 0; font-size: .95rem; }
.post__meta { font-size: .82rem; color: var(--text-faint); display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--cyan); background: var(--cyan-soft); border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent); padding: 2px 9px; border-radius: 999px; }

/* ---------- CV / Timeline ---------- */
.cv-header { display: grid; grid-template-columns: 200px 1fr; gap: 34px; align-items: center; margin-bottom: 2.6rem; }
.cv-header img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-md), 0 0 0 1px var(--border); }
.cv-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1rem; }

.timeline { position: relative; padding-left: 28px; border-left: 2px solid var(--border); margin: 1.5rem 0 2.5rem; }
.timeline-item { position: relative; padding-bottom: 2.1rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: -34px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px var(--bg); }
.timeline-item .role { font-family: var(--font-display); font-weight: 800; font-size: 1.05rem; color: var(--text); }
.timeline-item .org { color: var(--amber); font-weight: 600; font-size: .92rem; }
.timeline-item .period { color: var(--text-faint); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .5rem; display: block; }
.timeline-item ul { padding-left: 1.2rem; margin-top: .5rem; }
.timeline-item li { margin-bottom: .35rem; font-size: .95rem; }
.timeline-item.compact { padding-bottom: 1rem; }
.timeline-item.compact::before { background: var(--text-faint); width: 9px; height: 9px; left: -32px; }

.skills-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin: 1rem 0 2rem; }
.skill-group h4 { font-family: var(--font-display); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); margin-bottom: .6rem; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 13px; font-size: .84rem; color: var(--text-muted); }

.edu-table { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; }
.edu-table td { border-top: 1px solid var(--border); padding: 12px 0; font-size: .95rem; }
.edu-table td:first-child { color: var(--text); font-weight: 600; width: 45%; }
.edu-table td:last-child { color: var(--text-muted); }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.contact-list { list-style: none; }
.contact-list li { display: flex; gap: 10px; margin-bottom: 16px; color: var(--text-muted); align-items: baseline; }
.contact-list strong { color: var(--text); min-width: 100px; display: inline-block; }

/* ---------- Page (generic content) ---------- */
.page__header { margin-bottom: 2rem; }
.page__subtitle { color: var(--text-muted); font-size: 1.1rem; }
.page__content h2:first-child { margin-top: 0; }
.page__content ul, .page__content ol { padding-left: 1.3rem; }
.page__content li { margin-bottom: .4rem; }
.page__content blockquote { border-left: 3px solid var(--cyan); margin: 1.6rem 0; padding: .2rem 1.2rem; color: var(--text-muted); font-style: italic; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 48px 0 30px; margin-top: 56px; }
.site-footer__inner { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 28px; }
.footer-mark { width: 40px; margin-bottom: 12px; }
.site-footer h4 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); margin: 0 0 12px; }
.site-footer__col p { font-size: .85rem; }
.site-footer__col a { display: block; color: var(--text-muted); font-size: .9rem; margin-bottom: 8px; }
.site-footer__col a:hover { color: var(--cyan); text-decoration: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero__inner { grid-template-columns: 1fr; }
  .hero__portrait { order: -1; }
  .cards-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .book-promo { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .cv-header { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .skills-grid { grid-template-columns: 1fr; }
  .contact-grid { grid-template-columns: 1fr; }
  .site-footer__inner { grid-template-columns: 1fr 1fr; }
  .site-nav { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-alt); border-bottom: 1px solid var(--border); flex-direction: column; align-items: flex-start; gap: 0; max-height: 0; overflow: hidden; transition: max-height .25s ease; }
  .site-nav a { width: 100%; padding: 14px 24px; border-top: 1px solid var(--border); }
  .nav-cta { border-radius: 0; text-align: center; }
  .nav-burger { display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 30px; height: 30px; cursor: pointer; }
  .nav-burger span { height: 2px; background: var(--text); border-radius: 2px; }
  .nav-toggle:checked ~ .site-nav { max-height: 600px; }
}
@media (max-width: 600px) {
  .hero { padding: 40px 0 24px; }
  .site-footer__inner { grid-template-columns: 1fr; }
}
