/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  --bg:             #faf9f8;
  --surface:        #fff;
  --surface-muted:  #fafafa;
  --surface-hover:  #fdfdfd;
  --text:           #1a1a1a;
  --text-muted:     #888;
  --text-faint:     #bbb;
  --border:         #eee;
  --border-subtle:  #f0f0f0;
  --border-focus:   #1a1a1a;
  --accent:         #c8a87a;
  --accent-hover:   #b8924a;

  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1.25rem;
  --space-lg:  1.75rem;
  --space-xl:  3.5rem;

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);

  --dur-fast: 0.2s;
  --dur-base: 0.3s;
  --card-grad-opacity: 0.48; /* light mode */
}

body.dark-mode {
  --bg:             #111;
  --surface:        #1a1a1a;
  --surface-muted:  #161616;
  --surface-hover:  #202020;
  --text:           #e0e0e0;
  --text-muted:     #999;
  --text-faint:     #555;
  --border:         #333;
  --border-subtle:  #2a2a2a;
  --border-focus:   #e0e0e0;
  color: #e0e0e0 !important;
  --card-grad-opacity: 0.24;
}


/* ============================================================
   Base
   ============================================================ */
html {
  scroll-behavior: smooth;
  background: var(--bg) !important;
}

html.dark-mode {
  background: #111 !important;
}

/* WP theme wrapper elements — make transparent so body dark bg shows through */
body.dark-mode #page,
body.dark-mode #content,
body.dark-mode #primary,
body.dark-mode #main,
body.dark-mode .site,
body.dark-mode .site-content,
body.dark-mode .site-main,
body.dark-mode .content-area,
body.dark-mode .entry-content,
body.dark-mode .hentry,
body.dark-mode article.page {
  background: transparent !important;
}

body {
  background: transparent !important;
}

body::after {
  content: '';
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 40% 40% at 18% 25%, hsla(38, 55%, 38%, 0.38), transparent 60%),
    radial-gradient(ellipse 35% 35% at 82% 72%, hsla(210, 42%, 38%, 0.30), transparent 60%),
    radial-gradient(ellipse 32% 32% at 50% 82%, hsla(28, 50%, 36%, 0.26), transparent 60%);
  animation: bgFlow 28s cubic-bezier(0.45, 0, 0.55, 1) infinite alternate;
}

html.dark-mode body::after {
  background:
    radial-gradient(ellipse 40% 40% at 18% 25%, hsla(38, 50%, 36%, 0.22), transparent 60%),
    radial-gradient(ellipse 35% 35% at 82% 72%, hsla(200, 40%, 34%, 0.17), transparent 60%),
    radial-gradient(ellipse 32% 32% at 50% 82%, hsla(28, 45%, 34%, 0.14), transparent 60%);
}

@keyframes bgFlow {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(18%, -12%) scale(1.04); }
  100% { transform: translate(28%, -22%) scale(1); }
}

body::before {
  content: '';
  position: fixed;
  inset: -20px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
  animation: grainDrift 18s ease-in-out infinite alternate;
}

@keyframes grainDrift {
  0%   { transform: translate(0, 0); }
  50%  { transform: translate(-12px, 8px); }
  100% { transform: translate(6px, -10px); }
}

@keyframes breatheA {
  0%   { transform: scale(1) translate(0, 0);        opacity: 0.5; }
  100% { transform: scale(1.15) translate(5%, -5%);  opacity: 1; }
}

@keyframes breatheB {
  0%   { transform: scale(1) translate(0, 0);        opacity: 0.6; }
  100% { transform: scale(1.12) translate(-5%, 5%);  opacity: 1; }
}


/* ============================================================
   Landing grid
   ============================================================ */
.landing-grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.landing-grid > p {
  display: none;
}

.landing-card {
  background: var(--surface);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.landing-card.muted {
  background: var(--surface-muted);
}

.landing-card:has(a) {
  padding: 0;
  transition:
    transform var(--dur-base) var(--ease-spring),
    box-shadow var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-smooth);
}

.landing-card:has(a):hover {
  transform: translateY(-5px);
  box-shadow:
    inset 0 0 0 1.5px #c8c8c8,
    0 2px 4px rgba(0,0,0,0.04),
    0 8px 16px rgba(0,0,0,0.06),
    0 20px 40px rgba(0,0,0,0.07);
  background: var(--surface-hover);
}

.landing-card:has(a):active {
  transform: translateY(-2px);
  box-shadow:
    inset 0 0 0 1.5px #c8c8c8,
    0 2px 4px rgba(0,0,0,0.05),
    0 4px 8px rgba(0,0,0,0.06);
}

.landing-card a {
  display: block;
  padding: var(--space-lg);
  height: 100%;
  box-sizing: border-box;
  text-decoration: none;
  color: var(--text);
  position: relative;
  z-index: 2;
}

.landing-card a:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

.landing-num {
  font-family: 'DM Mono', monospace !important;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-sm);
  transition: color var(--dur-fast) ease;
}

.landing-title {
  font-size: 16px;
  font-weight: 400;
  margin-bottom: var(--space-xs);
  color: var(--text);
  transition: color var(--dur-fast) ease;
}

.landing-title.muted { color: var(--text-faint); }

.landing-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.landing-desc.muted { color: var(--border); }

.landing-arrow {
  font-family: 'DM Mono', monospace !important;
  font-size: 12px;
  color: var(--accent);
  margin-top: var(--md, 1.25rem);
  transition: color var(--dur-fast) ease;
}

.landing-card:has(a):hover .landing-num  { color: var(--accent-hover); }
.landing-card:has(a):hover .landing-title { color: var(--text); }
.landing-card:has(a):hover .landing-arrow { color: var(--accent-hover); }

/* Dark mode hover overrides (shadows can't be tokenised easily) */
body.dark-mode .landing-card:has(a):hover {
  box-shadow:
    inset 0 0 0 1.5px #444,
    0 2px 4px rgba(0,0,0,0.15),
    0 8px 16px rgba(0,0,0,0.2),
    0 20px 40px rgba(0,0,0,0.25);
}

body.dark-mode .landing-card:has(a):active {
  box-shadow:
    inset 0 0 0 1.5px #444,
    0 2px 4px rgba(0,0,0,0.15),
    0 4px 8px rgba(0,0,0,0.18);
}

body.dark-mode .landing-card:has(a):hover .landing-num   { color: #777; }
body.dark-mode .landing-card:has(a):hover .landing-title  { color: #fff; }
body.dark-mode .landing-card:has(a):hover .landing-arrow  { color: #999; }


/* ============================================================
   Landing card — per-card gradient (::before)
   ============================================================ */

/* Shared ::before base */
.landing-card:has(a)::before {
  content: '';
  position: absolute;
  inset: -30%;
  pointer-events: none;
  z-index: 0;
  filter: none;
  transition: filter 0.4s ease;
}

/* Note: the four per-card rules below add only `background` and `animation`.
   `filter`, `transition`, and all other shared properties live on the base
   rule above — do NOT repeat them in the per-card rules. */

/* CV — warm amber, top-left
   Gradient centre mapped to card's top-left corner in ::before coordinate space
   (::before has inset:-30%, so card corners sit at ≈19%/81%) */
.landing-card:has(a):nth-child(1)::before {
  background: radial-gradient(ellipse 85% 85% at 19% 19%, hsla(38, 55%, 45%, var(--card-grad-opacity)), transparent 65%);
  animation: breatheA 6s ease-in-out infinite alternate;
}

/* Work — slate-blue, top-right */
.landing-card:has(a):nth-child(2)::before {
  background: radial-gradient(ellipse 85% 85% at 81% 19%, hsla(210, 42%, 45%, var(--card-grad-opacity)), transparent 65%);
  animation: breatheB 7s ease-in-out infinite alternate;
}

/* About — terracotta, bottom-right */
.landing-card:has(a):nth-child(3)::before {
  background: radial-gradient(ellipse 85% 85% at 81% 81%, hsla(20, 50%, 42%, var(--card-grad-opacity)), transparent 65%);
  animation: breatheA 5.5s ease-in-out infinite alternate;
}

/* Contact — sage, bottom-left */
.landing-card:has(a):nth-child(4)::before {
  background: radial-gradient(ellipse 85% 85% at 19% 81%, hsla(160, 30%, 42%, var(--card-grad-opacity)), transparent 65%);
  animation: breatheB 8s ease-in-out infinite alternate;
}

/* Grain overlay — all cards (active and muted) */
.landing-card::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 140px;
}

/* Dark mode: same opacity — explicit override per spec */
body.dark-mode .landing-card::after {
  opacity: 0.04;
}

/* Hover: reveal gradient via filter — does not affect card's own box-shadow or text */
.landing-card:has(a):hover::before {
  filter: brightness(2.2) saturate(1.4);
}

@media (prefers-reduced-motion: reduce) {
  .landing-card::before {
    animation: none;
  }
}


/* ============================================================
   Arrow animation (shared)
   ============================================================ */
.family-card a .arrow,
.landing-card a .arrow {
  display: inline-block;
  transition: transform var(--dur-base) var(--ease-spring);
}

.family-card:has(a):hover .arrow,
.landing-card:has(a):hover .arrow {
  transform: translateX(7px);
}


/* ============================================================
   Navigation (back / top)
   ============================================================ */
.back-link,
.top-link {
  display: inline-flex;
  align-items: center;
  font-family: 'DM Mono', monospace;
  font-size: 16px;
  color: var(--text-faint);
  text-decoration: none;
  transition: color var(--dur-fast) ease;
  line-height: 1;
}

.back-link { margin-top: var(--space-xl); margin-right: var(--space-md); }
.top-link  { margin-top: var(--space-xl); }

.back-link:hover,
.top-link:hover { color: var(--text-muted); }

.back-link:focus-visible,
.top-link:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 4px;
  color: var(--text-muted);
}

.back-link .arrow {
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.back-link:hover .arrow { transform: translateX(-4px); }

.top-link .arrow {
  display: inline-block;
  transition: transform var(--dur-fast) var(--ease-spring);
}
.top-link:hover .arrow { transform: translateY(-4px); }


/* ============================================================
   Dark toggle
   ============================================================ */
.dark-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  font-family: 'DM Mono', monospace;
  font-size: 18px;
  color: var(--text-faint);
  background: none;
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color var(--dur-fast) ease,
    color var(--dur-fast) ease,
    transform var(--dur-base) ease;
}

.dark-toggle:hover {
  color: var(--text-muted);
  border-color: var(--text-faint);
}

.dark-toggle.rotated,
body.dark-mode .dark-toggle {
  transform: rotate(180deg);
}

body.dark-mode .dark-toggle {
  color: #666;
  border-color: #333;
}


/* ============================================================
   Scroll progress bar
   ============================================================ */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 1px;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.08s linear;
  opacity: 0.6;
}

body.dark-mode .scroll-progress {
  opacity: 0.4;
}


/* ============================================================
   Fade-in animation
   ============================================================ */
.fade-in {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity var(--dur-base) var(--ease-smooth),
    transform var(--dur-base) var(--ease-smooth);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}


/* ============================================================
   Dark mode: inline style overrides (compatibility layer)
   — remove once HTML pages are migrated to CSS classes
   ============================================================ */
body.dark-mode [style*="font-family:'DM Mono'"][style*="clamp"] {
  color: #ffffff !important;
}

body.dark-mode [style*="color:#1a1a1a"]   { color: var(--text)       !important; }
body.dark-mode [style*="color:#444"]      { color: #ccc              !important; }
body.dark-mode [style*="color:#555"]      { color: #bbb              !important; }
body.dark-mode [style*="color:#666"]      { color: #aaa              !important; }

body.dark-mode [style*="border-bottom:1px solid #eee"]               { border-bottom-color: var(--border-subtle) !important; }
body.dark-mode [style*="border-top:1px solid #eee"]                  { border-top-color:    var(--border-subtle) !important; }
body.dark-mode [style*="border:1px solid #e8e8e8"]                   { border-color:        var(--border)        !important; }
body.dark-mode [style*="border-bottom:1px solid #eee"][style*="color:#1a1a1a"] {
  border-bottom-color: var(--border-subtle) !important;
}


/* ============================================================
   CV — wrapper & header
   ============================================================ */
.cv-wrap {
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  color: var(--text);
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1rem;
}

.cv-name {
  font-family: 'DM Mono', monospace;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 300;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.cv-subtitle {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.cv-contact {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: #aaa;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.cv-contact a {
  color: #aaa;
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}

.cv-contact a:hover { color: var(--text-muted); }

.cv-section-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 2rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 2.5rem;
}

.cv-section-label.first {
  border-top: none;
  padding-top: 0;
}


/* ============================================================
   CV — timeline
   ============================================================ */
.cv-timeline {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.cv-timeline-line {
  display: none;
}


.cv-entry {
  position: relative;
  padding-left: 1.75rem;
  padding-bottom: 2.5rem;
}

.cv-entry:last-child { padding-bottom: 0.5rem; }

.cv-entry-node {
  position: absolute;
  left: -1.44rem;
  top: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background var(--dur-base) ease, box-shadow var(--dur-base) ease;
}

.cv-entry.current .cv-entry-node {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 168, 122, 0.15);
  animation: dotPulse 2.5s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(200, 168, 122, 0.18); }
  50%      { box-shadow: 0 0 0 7px rgba(200, 168, 122, 0.05); }
}

.cv-entry-date {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 2px;
}

.cv-entry-company {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.cv-entry-role {
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.cv-entry-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.75;
}


/* ============================================================
   CV — education, additional, languages
   ============================================================ */
.cv-edu-entry {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 0 2rem;
  margin-bottom: 1.25rem;
}

.cv-edu-year {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-faint);
  padding-top: 2px;
}

.cv-edu-school {
  font-size: 14px;
  font-weight: 400;
  margin-bottom: 3px;
  color: var(--text);
}

.cv-edu-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.cv-additional {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 2.5rem;
}

.cv-lang-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
}

.cv-lang-tag {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

.cv-lang-tag:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.cv-footer {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: #ccc;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 3rem;
  display: flex;
  gap: 2rem;
}

.cv-footer a {
  color: #ccc;
  text-decoration: none;
  transition: color var(--dur-fast) ease;
}

.cv-footer a:hover { color: var(--text-muted); }


/* ============================================================
   CV — scroll pulse nav
   ============================================================ */
.scroll-pulse-nav {
  position: fixed;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s var(--ease-smooth);
}

.scroll-pulse-nav.visible {
  opacity: 1;
}

.scroll-seg {
  width: 2px;
  height: 6px;
  border-radius: 2px;
  background: var(--text-faint);
  opacity: 0.2;
  transition:
    height 0.15s var(--ease-smooth),
    opacity 0.15s ease,
    background 0.15s ease;
  flex-shrink: 0;
}

@media (max-width: 860px) {
  .scroll-pulse-nav { display: none; }
}


/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 580px) {
  .landing-grid {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns:140px"],
  [style*="grid-template-columns:80px"] {
    grid-template-columns: 1fr !important;
  }

  .cv-edu-entry {
    grid-template-columns: 1fr;
  }

  .cv-edu-year { margin-bottom: 0.25rem; }
}
