/* ============================================================
   Personal Website — Base Design System
   Joel Evert Patreksson Thomas
   Conservative finance professional with edge.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --black: #080708;
  --black-rich: #111012;
  --black-elevated: #171518;
  --maroon: #6b2737;
  --maroon-dim: #54202d;
  --maroon-deep: #301017;
  --maroon-glow: rgba(107, 39, 55, 0.32);
  --light: #eadccc;
  --light-dim: #d4bfaf;
  --light-soft: rgba(234, 220, 204, 0.7);
  --text: #f4ede6;
  --text-mid: #b9aea3;
  --text-soft: #8f857c;
  --line: rgba(234, 220, 204, 0.12);
  --line-strong: rgba(234, 220, 204, 0.2);
  --surface: rgba(255, 255, 255, 0.035);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --surface-glass: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));

  --font-heading: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;

  --step--1: clamp(0.82rem, 0.79rem + 0.12vw, 0.9rem);
  --step-0: clamp(0.98rem, 0.94rem + 0.2vw, 1.08rem);
  --step-1: clamp(1.12rem, 1.04rem + 0.36vw, 1.3rem);
  --step-2: clamp(1.35rem, 1.18rem + 0.7vw, 1.75rem);
  --step-3: clamp(1.72rem, 1.42rem + 1.2vw, 2.45rem);
  --step-4: clamp(2.25rem, 1.76rem + 1.98vw, 3.45rem);
  --step-5: clamp(2.9rem, 2.15rem + 3.05vw, 4.8rem);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-10: 128px;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --shadow-card-hover: 0 18px 45px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(107, 39, 55, 0.18);
  --shadow-nav: 0 18px 40px rgba(0, 0, 0, 0.36);
  --shadow-glow: 0 0 0 1px rgba(107, 39, 55, 0.28), 0 24px 48px rgba(48, 16, 23, 0.45), 0 0 32px rgba(107, 39, 55, 0.12);

  --transition-fast: 180ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-base: 260ms cubic-bezier(0.22, 1, 0.36, 1);
  --transition-slow: 500ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: -0.01em;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(107, 39, 55, 0.12), transparent 35%),
    linear-gradient(180deg, var(--black) 0%, var(--black-rich) 100%);
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.035) 0, transparent 30%);
  background-size: 3px 3px, 72px 72px, 100% 100%;
  opacity: 0.24;
  mix-blend-mode: soft-light;
  z-index: -1;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--light);
  text-wrap: balance;
}

h1 {
  font-size: var(--step-5);
  font-weight: 700;
}

h2 {
  font-size: var(--step-4);
}

h3 {
  font-size: var(--step-2);
}

h4 {
  font-size: var(--step-1);
}

h5,
h6 {
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

h5 { font-size: var(--step-0); }
h6 { font-size: var(--step--1); }

p {
  margin-bottom: var(--space-4);
  max-width: 66ch;
  color: var(--text-mid);
}

.lead,
.text-lg {
  font-size: var(--step-1);
  line-height: 1.7;
  color: var(--text);
}

a {
  color: var(--light);
  text-decoration: underline;
  text-decoration-color: rgba(107, 39, 55, 0.8);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

a:hover {
  color: #fff7ef;
  text-decoration-color: var(--light);
}

ul, ol {
  list-style-position: inside;
  margin-bottom: var(--space-4);
}

li {
  margin-bottom: var(--space-2);
}

strong {
  font-weight: 600;
  color: var(--light);
}

code,
pre {
  font-family: var(--font-mono);
}

code {
  font-size: 0.875em;
  background: rgba(255, 255, 255, 0.06);
  color: var(--light);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

pre {
  font-size: 0.875rem;
  background: var(--black-elevated);
  color: var(--light);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-5);
  border: 1px solid var(--line);
}

blockquote {
  border-left: 3px solid var(--maroon);
  padding-left: var(--space-5);
  margin: var(--space-5) 0;
  color: var(--text-mid);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--space-7) 0;
}

.gold-accent { color: var(--light); }
.gold-underline { display: inline-block; position: relative; }
.gold-underline::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--maroon) 15%, var(--light-dim) 100%);
}

.navy-bg {
  background: linear-gradient(180deg, rgba(8, 7, 8, 0.94), rgba(48, 16, 23, 0.88));
  color: var(--text);
}

.warm-bg {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

.text-center { text-align: center; }
.text-mid { color: var(--text-mid); }
.text-light { color: var(--text-soft); }
.text-sm { font-size: var(--step--1); }

.container,
.container-narrow {
  width: min(100% - 2rem, 1200px);
  margin: 0 auto;
}

.container-narrow {
  max-width: 860px;
}

.section {
  padding: clamp(4.5rem, 8vw, 7rem) 0;
}

.section-tight {
  padding: clamp(3.5rem, 6vw, 5.5rem) 0;
}

.page-reveal,
.hero-inner,
.chat-shell,
.timeline-item,
.metric-card,
.skill-group,
.project-card,
.section-header,
.card {
  animation: fadeInUp 0.8s var(--transition-base) both;
}

.section-header {
  text-align: center;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-header h2::after {
  content: '';
  display: block;
  width: 72px;
  height: 2px;
  margin: var(--space-3) auto 0;
  background: linear-gradient(90deg, transparent, var(--maroon), var(--light-dim));
}

.section-header p {
  margin: var(--space-3) auto 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  padding: 0.9rem 1.35rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-base), border-color var(--transition-base), background var(--transition-base), box-shadow var(--transition-base), color var(--transition-base);
  text-decoration: none;
  line-height: 1.2;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--maroon) 0%, var(--maroon-dim) 100%);
  color: var(--light);
  border-color: rgba(234, 220, 204, 0.2);
  box-shadow: 0 10px 24px rgba(48, 16, 23, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 18px 32px rgba(48, 16, 23, 0.42);
  color: var(--light);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.02);
  color: var(--light);
  border-color: rgba(234, 220, 204, 0.14);
  backdrop-filter: blur(10px);
}

.btn-outline:hover {
  background: rgba(107, 39, 55, 0.18);
  border-color: rgba(234, 220, 204, 0.28);
  color: var(--light);
}

.btn-light {
  background: rgba(255, 255, 255, 0.08);
  color: var(--light);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn-light:hover {
  background: var(--light);
  color: var(--black);
}

.card {
  position: relative;
  background: var(--surface-glass), rgba(17, 16, 18, 0.9);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: clamp(1.35rem, 2vw, 1.9rem);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 42%);
  opacity: 0.45;
  pointer-events: none;
}

.card:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px) scale(1.01);
  border-color: rgba(107, 39, 55, 0.32);
}

.metric {
  font-family: var(--font-heading);
  font-size: clamp(2.8rem, 5vw, 4.8rem);
  font-weight: 700;
  color: var(--light);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.metric-label {
  font-size: var(--step--1);
  color: var(--text-mid);
  margin-top: var(--space-2);
  max-width: 24ch;
}

:focus-visible {
  outline: 2px solid var(--light);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

::selection {
  background: var(--maroon);
  color: var(--light);
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(107, 39, 55, 0.85), rgba(212, 191, 175, 0.55));
  border-radius: 999px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 768px) {
  body {
    line-height: 1.68;
  }

  .container,
  .container-narrow {
    width: min(100% - 1.5rem, 1200px);
  }

  .section {
    padding: var(--space-8) 0;
  }
}

@media (max-width: 400px) {
  .section {
    padding: var(--space-7) 0;
  }

  p {
    max-width: 100%;
  }
}

/* ── Grain Texture Overlay ── */
.grain-overlay::before, .grain-overlay {
  position: relative;
}

.grain-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px;
}

/* Refined backdrop for glass elements */
.glass-surface {
  background: rgba(17, 16, 18, 0.72);
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  border: 1px solid rgba(234, 220, 204, 0.08);
}

/* ── Maroon Glow ── */
.glow-maroon:hover {
  box-shadow: 0 0 24px rgba(107, 39, 55, 0.22), 0 0 6px rgba(107, 39, 55, 0.08);
}

.glow-maroon-soft:hover {
  box-shadow: 0 0 16px rgba(107, 39, 55, 0.14);
}
