/* ============================================================
   LUIS — PERSONAL WEBSITE
   Design System v2.0
   
   Stack: IBM Plex Sans (body) + IBM Plex Mono (labels/codes)
   Palette: Monochromatic. No accent color. Whitespace is structure.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@0,400;0,500;1,400&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;1,400&display=swap');

/* ─── Design Tokens ───────────────────────────────────────── */
:root {
  /* Color — dark default */
  --bg:           #060606;
  --bg-raised:    #0d0d0d;
  --text:         #e5e5e5;
  --text-muted:   #adadad;
  --text-dim:     #282828;
  --border:       rgba(255, 255, 255, 0.07);
  --border-mid:   rgba(255, 255, 255, 0.12);
  --link:         #dedede;
  --link-hover:   #ffffff;

  /* Typography */
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', 'Menlo', 'Courier New', monospace;

  /* Type scale (rem, base 16px) */
  --t-10: 0.625rem;
  --t-11: 0.6875rem;
  --t-12: 0.75rem;
  --t-13: 0.8125rem;
  --t-14: 0.875rem;
  --t-15: 0.9375rem;
  --t-17: 1.0625rem;
  --t-20: 1.25rem;
  --t-24: 1.5rem;
  --t-28: 1.75rem;
  --t-34: 2.125rem;
  --t-44: 2.75rem;

  /* Spacing (8px grid) */
  --s-2:  0.125rem;
  --s-4:  0.25rem;
  --s-6:  0.375rem;
  --s-8:  0.5rem;
  --s-12: 0.75rem;
  --s-16: 1rem;
  --s-20: 1.25rem;
  --s-24: 1.5rem;
  --s-32: 2rem;
  --s-40: 2.5rem;
  --s-48: 3rem;
  --s-64: 4rem;
  --s-80: 5rem;

  /* Layout */
  --page-max: 1200px;
  --page-px:  1.5rem;

  /* Component sizing — tune the page from here, not the rules below */
  --header-height:    64px;
  --header-padding:   var(--s-12);
  --name-size:        var(--t-44);
  --name-size-mobile: var(--t-28);
  --profile-size:     76px;
  --toggle-size:      40px;
  --links-columns:    3;
  --section-gap:      var(--s-24);
  --card-gap:         var(--s-12);

  /* Glass surfaces — used by the CV cards / segmented control */
  --glass-card-bg:      rgba(255, 255, 255, 0.035);
  --glass-card-border:  rgba(255, 255, 255, 0.09);
  --glass-track-bg:     rgba(255, 255, 255, 0.045);
  --glass-thumb-bg:     rgba(255, 255, 255, 0.11);
  --glass-thumb-border: rgba(255, 255, 255, 0.16);
  --glass-thumb-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);

  /* Animation */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur:  140ms;
}

/* Light mode */
body.light-mode {
  --bg:           #f4f4f2;
  --bg-raised:    #ffffff;
  --text:         #111111;
  --text-muted:   #4a4a4a;
  --text-dim:     #d4d4d4;
  --border:       rgba(0, 0, 0, 0.08);
  --border-mid:   rgba(0, 0, 0, 0.14);
  --link:         #0f0f0f;
  --link-hover:   #000000;

  --glass-card-bg:      rgba(255, 255, 255, 0.55);
  --glass-card-border:  rgba(0, 0, 0, 0.08);
  --glass-track-bg:     rgba(0, 0, 0, 0.045);
  --glass-thumb-bg:     #ffffff;
  --glass-thumb-border: rgba(0, 0, 0, 0.08);
  --glass-thumb-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--t-15);
  font-weight: 400;
  line-height: 1.65;
  min-height: 100vh;
  transition:
    background var(--dur) var(--ease),
    color      var(--dur) var(--ease);
}

a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
a:hover { color: var(--link-hover); }

img { display: block; max-width: 100%; }

/* ─── Site Shell ────────────────────────────────────────────── */
.site {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  transition:
    background    var(--dur) var(--ease),
    border-color  var(--dur) var(--ease);
}

.header-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-12) var(--page-px);
  display: flex;
  align-items: center;
  gap: var(--s-20);
}

.header-name {
  font-family: var(--mono);
  font-size: var(--t-13);
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.header-name:hover { color: var(--link-hover); }

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--s-16);
  flex: 1;
}

.nav-link {
  font-family: var(--mono);
  font-size: var(--t-12);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: lowercase;
  transition: color var(--dur) var(--ease);
}
.nav-link:hover,
.nav-link.active { color: var(--text); }

.header-controls {
  display: flex;
  align-items: center;
  gap: var(--s-12);
  flex-shrink: 0;
}

.ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: var(--t-14);
  color: var(--text-muted);
  line-height: 1;
  padding: 0;
  transition: color var(--dur) var(--ease);
}
.ctrl-btn:hover { color: var(--text); }

/* ─── Page Content ────────────────────────────────────────────── */
.page-content {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-40) var(--page-px) var(--s-64);
  flex: 1;
}

/* ─── Home Layout (dual column) ─────────────────────────────────
   Left: personal — photo, name, bio. Right: directory — CV,
   Projects, Playground, Links, read as a control panel. ─────── */
.home-grid {
  display: grid;
  grid-template-columns: 2fr 2fr;
  gap: var(--s-64);
  align-items: start;
}

.home-primary {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.home-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  padding-left: var(--s-40);
  min-width: 0;
}

.panel-block + .panel-block {
  border-top: 1px solid var(--border);
  margin-top: var(--s-24);
  padding-top: var(--s-24);
}

/* ─── Divider ─────────────────────────────────────────────────── */
.rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s-32) 0;
}

/* ─── Section Label ───────────────────────────────────────────── */
.section-label {
  font-family: var(--mono);
  font-size: var(--t-14);
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: block;
  margin-bottom: var(--s-16);
}

/* ─── Identity (Homepage) ─────────────────────────────────────── */
.identity {
  display: flex;
  align-items: flex-start;
  gap: var(--s-20);
}

.profile-img {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-mid);
  flex-shrink: 0;
  margin-top: var(--s-4);
}

.name {
  font-family: var(--sans);
  font-size: var(--t-44);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: var(--s-8);
  min-height: 1.15em;
}

.subtitle {
  font-size: var(--t-15);
  color: var(--text-muted);
  line-height: 1.5;
  font-weight: 400;
}

/* ─── Typewriter Cursor ───────────────────────────────────────── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.cursor {
  display: inline-block;
  width: 1.5px;
  height: 0.85em;
  background: var(--text-muted);
  margin-left: 2px;
  vertical-align: baseline;
  position: relative;
  top: 0.1em;
  animation: blink 1.1s steps(1) infinite;
}

/* ─── Bio ─────────────────────────────────────────────────────── */
.bio-content {
  font-size: var(--t-17);
  color: var(--text);
  line-height: 1.75;
}

.bio-content p { margin-bottom: var(--s-12); }
.bio-content p:last-child { margin-bottom: 0; }

.bio-content a {
  border-bottom: 1px solid var(--border-mid);
  padding-bottom: 1px;
}
.bio-content a:hover { border-bottom-color: var(--text); }

/* ─── CV Block ─────────────────────────────────────────────────
   Each CV is a card: title, a segmented language control, and a
   single "Open PDF" action driven by the control's selection.
   Glass surfaces are reserved for this block — the one place in
   the page that takes a visual risk; everything else stays flat
   and hairline-quiet. ──────────────────────────────────────── */

.cv-card {
    cursor: pointer;

    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        transform 0.2s ease;
}

.cv-card:hover {
    transform: translateY(-1px);
}

   .cv-cards {
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
}

.cv-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-12);
  padding: var(--s-16);
  background: var(--glass-card-bg);
  border: 1px solid var(--glass-card-border);
  border-radius: 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.cv-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.cv-card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Segmented control — Apple-style track with a sliding glass thumb */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 122px;
  flex-shrink: 0;
  background: var(--glass-track-bg);
  border: 1px solid var(--glass-card-border);
  border-radius: 999px;
  padding: 2px;
}

.seg-thumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: calc((100% - 4px) / 3);
  background: var(--glass-thumb-bg);
  border: 1px solid var(--glass-thumb-border);
  border-radius: 999px;
  box-shadow: var(--glass-thumb-shadow);
  transition: transform 220ms var(--ease);
}
.seg[data-active="es"] .seg-thumb { transform: translateX(100%); }
.seg[data-active="fr"] .seg-thumb { transform: translateX(200%); }

.seg-btn {
  position: relative;
  z-index: 1;
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: var(--t-11);
  letter-spacing: 0.03em;
  padding: var(--s-6) 0;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}
.seg-btn[aria-pressed="true"] { color: var(--text); }
.seg-btn:hover { color: var(--text); }
.seg-btn:focus-visible {
  outline: 1px solid var(--text-muted);
  outline-offset: 2px;
  border-radius: 999px;
}

.cv-open {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-12) var(--s-16);
  border: 1px solid var(--border-mid);
  border-radius: 10px;
  font-family: var(--mono);
  font-size: var(--t-12);
  letter-spacing: 0.03em;
  color: var(--text);
  transition:
    border-color var(--dur) var(--ease),
    background   var(--dur) var(--ease);
}
.cv-open:hover {
  border-color: var(--text-muted);
  background: var(--glass-track-bg);
}

.cv-open-arrow {
  color: var(--text-muted);
  transition: transform var(--dur) var(--ease);
}
.cv-open:hover .cv-open-arrow { transform: translate(2px, -2px); }

/* ─── Section Links (Projects / Playground on homepage) ─────── */
.section-links {
  display: flex;
  flex-direction: column;
}

.section-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-16);
  padding: var(--s-12) 0;
  border-top: 1px solid var(--border);
  color: var(--text);
  transition: color var(--dur) var(--ease);
}
.section-link:last-child { border-bottom: 1px solid var(--border); }
.section-link:hover { color: var(--link-hover); }

.section-link-title {
  font-size: var(--t-14);
}

.section-link-desc {
  font-family: var(--mono);
  font-size: var(--t-12);
  color: var(--text-muted);
  letter-spacing: 0.02em;
  transition: color var(--dur) var(--ease);
}
.section-link:hover .section-link-desc { color: var(--text-muted); }

.section-link:hover,
.link-item:hover,
.cv-card:hover {
    transform: translateY(-2px);

    border-color: var(--text-muted);
}

.section-link,
.link-item,
.cv-card {
    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        background 0.18s ease;
}

/* ─── External Links ──────────────────────────────────────────── */
.link-list {
  display: grid;

  grid-template-columns:
      repeat(var(--links-columns), 1fr);

  gap: var(--s-8) var(--s-20);
}

.link-item {
  display: flex;

  align-items: center;

  gap: var(--s-8);

  padding: var(--s-4) 0;

  min-width: 0;
}

.link-item:hover { color: var(--link-hover); }

.link-code {
  font-family: var(--mono);
  font-size: var(--t-12);
  color: var(--text-muted);
  width: 3.25rem;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  transition: color var(--dur) var(--ease);
}
.link-item:hover .link-code { color: var(--text-muted); }

.link-name {
  font-size: var(--t-14);
}

/* ─── Footer ──────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease);
}

.footer-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s-20) var(--page-px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-text {
  font-family: var(--mono);
  font-size: var(--t-11);
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* ─── Index Pages (Projects / Playground) ─────────────────────── */
.index-header {
  margin-bottom: var(--s-40);
}

.page-title {
  font-size: var(--t-24);
  font-weight: 300;
  letter-spacing: -0.015em;
  line-height: 1.25;
  margin-bottom: var(--s-8);
}

.page-desc {
  font-size: var(--t-14);
  color: var(--text-muted);
}

.item-list {
  display: flex;
  flex-direction: column;
}

.item-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: var(--s-24);
  padding: var(--s-20) 0;
  border-top: 1px solid var(--border);
  color: var(--text);
  transition: color var(--dur) var(--ease);
}
.item-entry:last-child { border-bottom: 1px solid var(--border); }
.item-entry:hover { color: var(--link-hover); }

.item-title {
  font-size: var(--t-15);
  font-weight: 400;
  margin-bottom: var(--s-6);
}

.item-desc {
  font-size: var(--t-13);
  color: var(--text-muted);
  line-height: 1.55;
  transition: color var(--dur) var(--ease);
}
.item-entry:hover .item-desc { color: var(--text-muted); }

.item-meta {
  font-family: var(--mono);
  font-size: var(--t-11);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  padding-top: 0.2em;
}

/* ─── Individual Project / Playground Pages ───────────────────── */
.page-back {
  font-family: var(--mono);
  font-size: var(--t-12);
  color: var(--text-muted);
  letter-spacing: 0.03em;
  display: inline-block;
  margin-bottom: var(--s-40);
  transition: color var(--dur) var(--ease);
}
.page-back:hover { color: var(--text); }

.article-header { margin-bottom: var(--s-32); }

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-24) var(--s-40);
  margin-top: var(--s-24);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.meta-key {
  font-family: var(--mono);
  font-size: var(--t-10);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meta-val {
  font-size: var(--t-14);
  color: var(--text);
}

/* ─── Article Body ────────────────────────────────────────────── */
.article-body {
  font-size: var(--t-15);
  line-height: 1.75;
  color: var(--text);
}

.article-body p            { margin-bottom: var(--s-16); }
.article-body p:last-child { margin-bottom: 0; }

.article-body h2 {
  font-size: var(--t-17);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: var(--s-40) 0 var(--s-12);
}

.article-body h3 {
  font-size: var(--t-15);
  font-weight: 500;
  margin: var(--s-24) 0 var(--s-8);
}

.article-body ul,
.article-body ol {
  padding-left: var(--s-20);
  margin-bottom: var(--s-16);
}

.article-body li { margin-bottom: var(--s-8); }

.article-body a {
  border-bottom: 1px solid var(--border-mid);
  padding-bottom: 1px;
}
.article-body a:hover { border-bottom-color: var(--text); }

.article-body figure { margin: var(--s-32) 0; }

.article-body figure img {
  width: 100%;
  border: 1px solid var(--border);
}

.article-body figcaption {
  font-family: var(--mono);
  font-size: var(--t-11);
  color: var(--text-muted);
  margin-top: var(--s-8);
  letter-spacing: 0.03em;
}

.article-body blockquote {
  border-left: 1px solid var(--border-mid);
  padding-left: var(--s-16);
  margin: var(--s-24) 0;
  color: var(--text-muted);
  font-style: italic;
}

.article-body code {
  font-family: var(--mono);
  font-size: var(--t-13);
  background: var(--bg-raised);
  padding: 1px 5px;
  border-radius: 2px;
}

.article-body pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: var(--s-16);
  overflow-x: auto;
  margin: var(--s-24) 0;
}

.article-body pre code {
  background: none;
  padding: 0;
  font-size: var(--t-12);
  line-height: 1.6;
}

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 820px) {
  .home-grid {
    grid-template-columns: 1fr;
    gap: var(--s-40);
  }

  .home-panel {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: var(--s-32);
  }
}

@media (max-width: 600px) {
  :root {
    --page-px:  1.25rem;
    --s-40:     1.75rem;
    --s-64:     2.5rem;
  }

  .name     { font-size: var(--t-28); }

  .identity {
    flex-direction: column;
    align-items: flex-start;
  }

  .seg { width: 112px; }

  .item-entry {
    grid-template-columns: 1fr;
    gap: var(--s-4);
  }

  .item-meta { display: none; }
}

/* ─── Reduced Motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .cursor { animation: none; opacity: 1; }
}

@media (max-width: 600px) {

  .link-list {
      grid-template-columns: 1fr;
  }

}