/* ============================================
   DAVID JAUMES — davidjaumes.com
   Shared Design System
   ============================================ */

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

:root {
  --c-bg: #F6F4F0;
  --c-bg-alt: #EDEAE4;
  --c-bg-dark: #1A1A18;
  --c-bg-dark-alt: #232321;
  --c-text: #1A1A18;
  --c-text-secondary: #6B6860;
  --c-text-on-dark: #F6F4F0;
  --c-text-on-dark-secondary: #A8A49C;
  --c-accent: #B45A2B;
  --c-accent-light: #D4804E;
  --c-accent-subtle: rgba(180,90,43,0.08);
  --c-border: #D6D2CA;
  --c-border-dark: #3A3A36;
  --font-display: 'DM Serif Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --max-w: 1120px;
  --max-w-narrow: 800px;
  --section-py: clamp(80px, 10vw, 140px);
  --section-py-sm: clamp(48px, 6vw, 80px);
}

html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-body); color: var(--c-text); background: var(--c-bg);
  line-height: 1.65; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
::selection { background: var(--c-accent); color: #fff; }
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; }

/* --- Layout --- */
.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 clamp(24px, 5vw, 64px); }
.wrap--narrow { max-width: var(--max-w-narrow); }

/* --- Typography --- */
.section-label {
  font-size: 12px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--c-accent); margin-bottom: 20px;
}
.section-label--light { color: var(--c-accent-light); }

/* --- Image captions --- */
.img-caption {
  font-size: 12px; font-weight: 400;
  color: var(--c-text-secondary); line-height: 1.5;
  margin-top: 10px;
}
figure.project-figure { margin: 40px 0; }
figure.project-figure .project-visual-block { margin: 0; }

h1, .h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(40px, 6vw, 72px); line-height: 1.08; letter-spacing: -0.02em;
}
h2, .h2 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(32px, 4vw, 48px); line-height: 1.12; letter-spacing: -0.01em;
}
h3, .h3 {
  font-family: var(--font-display); font-weight: 400;
  font-size: clamp(22px, 2.5vw, 28px); line-height: 1.2;
}
h1 em, h2 em, h3 em { font-style: italic; color: var(--c-accent); }

.text-lead {
  font-size: clamp(17px, 1.5vw, 20px); line-height: 1.65;
  color: var(--c-text-secondary); font-weight: 300;
}
.text-body {
  font-size: 16px; line-height: 1.75; color: var(--c-text-secondary); font-weight: 300;
}
.text-body p + p { margin-top: 16px; }
.text-body strong { color: var(--c-text); font-weight: 500; }

/* --- Navigation --- */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(246,244,240,0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--c-border);
  transition: background 0.3s;
}
nav.scrolled { background: rgba(246,244,240,0.95); }
nav .wrap { display: flex; align-items: center; height: 64px; gap: 20px; }
.nav-logo {
  font-family: var(--font-body); font-weight: 700; font-size: 15px;
  letter-spacing: 0.02em; color: var(--c-text); text-decoration: none;
}
.nav-logo span { color: var(--c-text-secondary); font-weight: 300; }
.nav-links { display: flex; gap: 32px; align-items: center; margin-left: auto; }
.nav-links a {
  font-size: 14px; font-weight: 400; color: var(--c-text-secondary);
  text-decoration: none; letter-spacing: 0.01em; transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--c-text); }
.nav-links a.nav-locked {
  display: inline-flex; align-items: center; gap: 5px;
}
.nav-links a.nav-locked svg {
  width: 12px; height: 12px; stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0; position: relative; top: -0.5px;
}
.nav-links a.nav-cta {
  color: var(--c-bg); background: var(--c-text); padding: 8px 20px;
  border-radius: 6px; font-weight: 500; font-size: 13px; transition: background 0.2s, transform 0.15s;
}
.nav-links a.nav-cta:hover { background: var(--c-accent); transform: translateY(-1px); }
.nav-burger { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.nav-burger span { display: block; width: 22px; height: 1.5px; background: var(--c-text); margin: 5px 0; transition: all 0.3s; }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-body); font-size: 15px; font-weight: 500;
  padding: 14px 28px; border-radius: 8px; text-decoration: none;
  transition: all 0.25s ease; cursor: pointer; border: none;
}
.btn svg { width: 16px; height: 16px; transition: transform 0.2s; }
.btn:hover svg { transform: translateX(3px); }
.btn-primary { background: var(--c-text); color: var(--c-bg); }
.btn-primary:hover { background: var(--c-accent); transform: translateY(-2px); }
.btn-secondary { background: transparent; color: var(--c-text); border: 1px solid var(--c-border); }
.btn-secondary:hover { border-color: var(--c-text); }
.btn-primary--invert { background: var(--c-bg); color: var(--c-text); }
.btn-primary--invert:hover { background: var(--c-accent-light); color: #fff; transform: translateY(-2px); }
.btn-secondary--dark { color: var(--c-text-on-dark-secondary); border-color: var(--c-border-dark); }
.btn-secondary--dark:hover { border-color: var(--c-text-on-dark-secondary); color: var(--c-text-on-dark); }
.btn-sm { padding: 10px 20px; font-size: 14px; }
.btn-arrow { padding: 0; background: none; border: none; color: var(--c-accent); font-weight: 500; font-size: 15px; }
.btn-arrow:hover { color: var(--c-text); }

/* --- Page Header --- */
.page-header {
  padding-top: calc(64px + clamp(48px, 6vw, 80px));
  padding-bottom: var(--section-py-sm);
  border-bottom: 1px solid var(--c-border);
}
.page-header h1 { margin-bottom: 16px; }

/* --- Sections --- */
.section { padding: var(--section-py) 0; }
.section--sm { padding: var(--section-py-sm) 0; }
.section--dark { background: var(--c-bg-dark); color: var(--c-text-on-dark); }
.section--alt { background: var(--c-bg-alt); }
.section--bordered { border-top: 1px solid var(--c-border); }

/* --- Cards --- */
.card {
  border: 1px solid var(--c-border); border-radius: 12px;
  padding: clamp(28px, 3vw, 40px); transition: border-color 0.3s, transform 0.3s;
  background: var(--c-bg);
}
.card:hover { border-color: var(--c-accent); }
.card--dark {
  background: var(--c-bg-dark-alt); border-color: var(--c-border-dark);
  color: var(--c-text-on-dark);
}
.card--dark:hover { border-color: var(--c-accent); }
.card--flat { border: none; background: var(--c-bg-alt); }
.card--accent-top { border-top: 3px solid var(--c-accent); }

/* --- KPI Cards --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpi {
  background: var(--c-bg-alt); border-radius: 10px; padding: 24px;
  text-align: center;
}
.kpi-value {
  font-family: var(--font-display); font-size: clamp(32px, 4vw, 48px);
  color: var(--c-accent); line-height: 1;
}
.kpi-label { font-size: 14px; color: var(--c-text-secondary); margin-top: 6px; font-weight: 300; }
.kpi--dark { background: var(--c-bg-dark-alt); }
.kpi--dark .kpi-label { color: var(--c-text-on-dark-secondary); }

/* --- Tags --- */
.tag {
  display: inline-block; font-size: 11px; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.06em; padding: 5px 12px; border-radius: 4px;
}
.tag--dark { background: var(--c-bg-dark); color: var(--c-text-on-dark); }
.tag--light { background: var(--c-bg-alt); color: var(--c-text); }
.tag--accent { background: var(--c-accent-subtle); color: var(--c-accent); }

/* --- Grid Utilities --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 3vw, 32px); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(24px, 3vw, 32px); }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: clamp(40px, 6vw, 80px); }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: clamp(40px, 6vw, 80px); }
.grid-aside { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(40px, 6vw, 100px); align-items: start; }

/* --- Project Grid --- */
.projects-featured { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.project-card {
  border-radius: 12px; overflow: hidden; text-decoration: none;
  display: flex; flex-direction: column; transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
  border: 1px solid var(--c-border);
}
.project-card:hover { transform: translateY(-6px); }
.project-card:first-child { grid-column: 1 / -1; }
.project-card:first-child .project-thumb { height: 340px; }
.project-thumb {
  height: 260px; overflow: hidden; position: relative;
}
.project-thumb-img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.16,1,0.3,1);
}
.project-card:hover .project-thumb-img { transform: scale(1.04); }
.project-thumb-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--c-text-secondary); font-weight: 300;
}
.project-info { padding: 24px; }
.project-info .tag { margin-bottom: 12px; }
.project-info h3 {
  font-family: var(--font-display); font-size: 22px; margin-bottom: 8px;
  line-height: 1.25;
}
.project-info p { font-size: 14px; color: var(--c-text-secondary); line-height: 1.6; font-weight: 300; }

/* --- Project Mosaic --- */
.mosaic {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.mosaic-item {
  border-radius: 8px; overflow: hidden; aspect-ratio: 4/3;
  transition: transform 0.3s, opacity 0.3s; cursor: default;
}
.mosaic-item:hover { transform: scale(1.03); opacity: 0.9; }
.mosaic-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--c-text-secondary); font-weight: 300;
}

/* --- Project Detail --- */
.project-hero {
  padding-top: calc(64px + clamp(40px, 5vw, 64px));
  padding-bottom: var(--section-py-sm);
}
.project-hero-visual {
  width: 100%; height: clamp(300px, 40vw, 480px);
  border-radius: 12px; overflow: hidden; margin-top: 40px;
}
.breadcrumb {
  font-size: 13px; color: var(--c-text-secondary); margin-bottom: 24px;
}
.breadcrumb a { text-decoration: none; transition: color 0.2s; }
.breadcrumb a:hover { color: var(--c-text); }
.breadcrumb .sep { margin: 0 8px; opacity: 0.4; }

/* --- Timeline --- */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 1px; background: var(--c-border);
}
.timeline-step { position: relative; padding-bottom: 40px; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-step::before {
  content: ''; position: absolute; left: -29px; top: 8px;
  width: 11px; height: 11px; border-radius: 50%;
  border: 2px solid var(--c-accent); background: var(--c-bg);
}
.timeline-step h3 { font-family: var(--font-body); font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.timeline-step p { font-size: 15px; color: var(--c-text-secondary); line-height: 1.7; font-weight: 300; }

/* --- Form --- */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 6px; color: var(--c-text);
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 12px 16px; font-family: var(--font-body);
  font-size: 15px; border: 1px solid var(--c-border); border-radius: 8px;
  background: #fff; color: var(--c-text); transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--c-accent); }
.form-textarea { min-height: 140px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* --- Footer --- */
footer {
  background: var(--c-bg-dark); color: var(--c-text-on-dark-secondary);
  border-top: 1px solid var(--c-border-dark); padding: 32px 0;
}
footer .wrap { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
footer a { color: var(--c-text-on-dark-secondary); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--c-text-on-dark); }
footer .footer-links { display: flex; gap: 24px; }

/* --- Animations --- */
.reveal {
  opacity: 0; transform: translateY(28px);
  transition: opacity 0.7s cubic-bezier(0.16,1,0.3,1), transform 0.7s cubic-bezier(0.16,1,0.3,1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-d1 { transition-delay: 0.1s; }
.reveal-d2 { transition-delay: 0.2s; }
.reveal-d3 { transition-delay: 0.3s; }
.reveal-d4 { transition-delay: 0.35s; }

@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

/* --- Spacers --- */
.mt-xs { margin-top: 8px; }
.mt-sm { margin-top: 16px; }
.mt-md { margin-top: 32px; }
.mt-lg { margin-top: 48px; }
.mt-xl { margin-top: 64px; }
.mb-sm { margin-bottom: 16px; }
.mb-md { margin-bottom: 32px; }
.mb-lg { margin-bottom: 48px; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-links.open {
    display: flex; flex-direction: column; position: absolute;
    top: 64px; left: 0; right: 0; background: var(--c-bg);
    border-bottom: 1px solid var(--c-border); padding: 24px; gap: 20px;
  }
  .nav-burger { display: block; }
  .grid-aside, .grid-2, .grid-3, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .projects-featured { grid-template-columns: 1fr; }
  .project-card:first-child { grid-column: auto; }
  .project-card:first-child .project-thumb { height: 260px; }
  .mosaic { grid-template-columns: repeat(3, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  footer .wrap { flex-direction: column; gap: 16px; text-align: center; }
}
@media (max-width: 600px) {
  .mosaic { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* --- Skip Link --- */
.skip-link {
  position: absolute; top: 8px; left: -9999px;
  background: var(--c-accent); color: #fff;
  padding: 8px 20px; z-index: 9999;
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  text-decoration: none; border-radius: 4px;
}
.skip-link:focus { left: 8px; }

/* --- Focus Visible --- */
:focus:not(:focus-visible) { outline: none; }
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.btn:focus-visible { border-radius: 8px; }
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible { outline-offset: 0; border-color: var(--c-accent); border-radius: 8px; }

/* --- Touch Optimization --- */
.btn, .nav-links a, .nav-logo, .project-card,
.client-logo, .mosaic-item, .faq-q, .lightbox-close {
  touch-action: manipulation;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1; transform: none; transition: none;
  }
  .hero-content .hero-surtitle,
  .hero-content h1,
  .hero-content .hero-subtitle,
  .hero-content .hero-ctas,
  .hero-portrait { opacity: 1; transform: none; animation: none; }
  .btn, .card, .project-card, .client-logo,
  .mosaic-item, .project-thumb-img,
  nav, .faq-a { transition: none; }
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --c-bg: #1B1B19;
  --c-bg-alt: #242421;
  --c-bg-dark: #111110;
  --c-bg-dark-alt: #1D1D1B;
  --c-text: #F2EFE9;
  --c-text-secondary: #9B9790;
  --c-text-on-dark: #F2EFE9;
  --c-text-on-dark-secondary: #9B9790;
  --c-border: #383835;
  --c-border-dark: #2C2C29;
  color-scheme: dark;
}
[data-theme="light"] { color-scheme: light; }

[data-theme="dark"] nav {
  background: rgba(27,27,25,0.85);
  border-bottom-color: var(--c-border);
}
[data-theme="dark"] nav.scrolled { background: rgba(27,27,25,0.95); }
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea {
  background: var(--c-bg-alt);
  color: var(--c-text);
  border-color: var(--c-border);
}

/* --- Theme Toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--c-border);
  cursor: pointer;
  padding: 9.5px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-secondary);
  transition: color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--c-text); border-color: var(--c-text); }
.theme-toggle svg { width: 16px; height: 16px; display: none; }
:root:not([data-theme-pref]) .theme-toggle .icon-system,
:root[data-theme-pref="system"] .theme-toggle .icon-system { display: block; }
:root[data-theme-pref="light"] .theme-toggle .icon-light { display: block; }
:root[data-theme-pref="dark"] .theme-toggle .icon-dark { display: block; }
