/* ==========================================================================
   dmfernandes.com design system + page styles
   All colors are defined as CSS variables and used only via var().
   Dark theme is the default; [data-theme="light"] switches the palette.
   System font stack, no webfonts, no external requests.
   ========================================================================== */

:root {
  /* Dark palette (default) */
  --color-bg: #0d1319;
  --color-bg-alt: #111a23;
  --color-surface: #16212c;
  --color-surface-raised: #1a2634;
  --color-text: #e8eef4;
  --color-text-muted: #a3b3c2;
  --color-heading: #f2f6fa;
  --color-accent: #62b6ff;
  --color-accent-2: #46d4c8;
  --color-accent-contrast: #0d1319;
  --color-border: #24313f;
  --color-border-strong: #31414f;
  --color-result-bg: #14222c;
  --color-shadow: rgba(0, 0, 0, 0.35);
  color-scheme: dark;

  /* Typography scale */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.125rem;
  --text-lg: clamp(1.25rem, 1.1rem + 0.8vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.3rem + 1.2vw, 1.875rem);
  --text-2xl: clamp(2.125rem, 1.6rem + 2.6vw, 3rem);
  --leading-body: 1.7;
  --leading-tight: 1.2;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2.5rem;
  --space-6: 4.5rem;

  --content-width: 46rem;
  --radius: 10px;
  --radius-sm: 6px;
}

:root[data-theme="light"] {
  --color-bg: #ffffff;
  --color-bg-alt: #f4f7fa;
  --color-surface: #ffffff;
  --color-surface-raised: #ffffff;
  --color-text: #1c2733;
  --color-text-muted: #4d5b6a;
  --color-heading: #101a24;
  --color-accent: #0d5ea8;
  --color-accent-2: #077a72;
  --color-accent-contrast: #ffffff;
  --color-border: #d8e0e8;
  --color-border-strong: #c2ced9;
  --color-result-bg: #f0f6fb;
  --color-shadow: rgba(16, 26, 36, 0.08);
  color-scheme: light;
}

/* Reset-ish */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-text-size-adjust: 100%;
  transition: background-color 0.25s ease, color 0.25s ease;
}

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

/* Layout: one centered column */
.container {
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

section {
  padding-block: var(--space-6);
  scroll-margin-top: var(--space-5);
}

/* Headings */
h1,
h2,
h3 {
  line-height: var(--leading-tight);
  color: var(--color-heading);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.015em;
}

h1 {
  font-size: var(--text-2xl);
  font-weight: 750;
}

h2 {
  font-size: var(--text-xl);
}

h3 {
  font-size: var(--text-lg);
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--color-accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-thickness: 2px;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

ul {
  margin: 0 0 var(--space-3);
  padding-left: 1.25rem;
}

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

li::marker {
  color: var(--color-accent);
}

/* Section kicker: small accent label above each section heading */
.kicker {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

/* Top bar: brand monogram + theme toggle */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  transition: background-color 0.25s ease;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-3);
}

.brand {
  font-weight: 800;
  font-size: var(--text-md);
  letter-spacing: 0.02em;
  color: var(--color-heading);
  text-decoration: none;
}

.brand .brand-dot {
  color: var(--color-accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.25s ease;
}

.theme-toggle:hover {
  border-color: var(--color-accent);
}

.theme-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
}

/* Show sun in dark mode (click → light), moon in light mode */
.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

:root[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

/* Hero */
.hero {
  padding-block: var(--space-6);
  background:
    radial-gradient(60rem 24rem at 85% -10%, var(--color-surface) 0%, transparent 60%),
    var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.hero h1 {
  margin-bottom: var(--space-2);
  background: linear-gradient(100deg, var(--color-heading) 30%, var(--color-accent) 75%, var(--color-accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--color-heading); /* fallback if background-clip unsupported */
  width: fit-content;
}

.hero .role {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
}

.hero .pitch {
  font-size: var(--text-lg);
  line-height: 1.5;
  max-width: 40rem;
  margin-bottom: var(--space-3);
}

.hero .location {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  list-style: none;
  padding: 0;
  margin: 0;
}

.hero-links li {
  margin: 0;
}

/* Button-style links */
.btn {
  display: inline-block;
  padding: 0.625rem 1.125rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

.btn-primary:hover {
  box-shadow: 0 4px 14px var(--color-shadow);
  color: var(--color-accent-contrast);
}

.btn-secondary {
  background: transparent;
  color: var(--color-text);
  border-color: var(--color-border-strong);
}

.btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* About */
.about-lede {
  font-size: var(--text-md);
}

/* Alternating band to separate long sections */
.band {
  background: var(--color-bg-alt);
  border-block: 1px solid var(--color-border);
  transition: background-color 0.25s ease;
}

/* Case studies as cards */
.case-study {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-5) var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: 0 8px 24px var(--color-shadow);
  overflow: hidden;
}

.case-study::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent-2));
}

.case-study:last-of-type {
  margin-bottom: 0;
}

.case-study h3 {
  padding-right: var(--space-3);
}

.case-study .summary {
  font-size: var(--text-md);
  color: var(--color-text-muted);
  max-width: 40rem;
  margin-bottom: var(--space-4);
}

/* Result callout: always visible, even when the full story is collapsed */
.case-study .result {
  background: var(--color-result-bg);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent-2);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  margin-bottom: 0;
}

/* Case study diagrams: inline SVG, every color a theme variable */
.diagram {
  margin: 0 0 var(--space-4);
}

.diagram svg {
  display: block;
  width: 100%;
  max-width: 36rem;
  height: auto;
  font-family: var(--font-body);
}

.diagram figcaption {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-2);
}

.dg-box {
  fill: var(--color-bg-alt);
  stroke: var(--color-border-strong);
}

.dg-box-main {
  fill: var(--color-result-bg);
  stroke: var(--color-accent);
}

.dg-pill {
  fill: none;
  stroke: var(--color-accent-2);
}

.dg-text {
  fill: var(--color-text);
  font-size: 13px;
}

.dg-text-strong {
  fill: var(--color-heading);
  font-weight: 600;
}

.dg-text-small {
  fill: var(--color-accent-2);
  font-size: 12px;
}

.dg-note {
  fill: var(--color-text-muted);
  font-size: 11px;
  font-style: italic;
}

.dg-diamond {
  fill: var(--color-bg-alt);
  stroke: var(--color-accent-2);
}

.dg-arrow {
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 1.5;
}

.dg-arrowhead {
  fill: var(--color-text-muted);
}

/* Expandable full story (native details element, no JavaScript) */
.cs-details {
  margin-top: var(--space-4);
}

.cs-details > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-accent);
  list-style: none;
  padding: var(--space-2) 0;
  user-select: none;
}

.cs-details > summary::-webkit-details-marker {
  display: none;
}

.cs-details > summary::before {
  content: "\25B8"; /* small triangle */
  display: inline-block;
  transition: transform 0.2s ease;
}

.cs-details[open] > summary::before {
  transform: rotate(90deg);
}

.cs-details > summary:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cs-details .hide-label {
  display: none;
}

.cs-details[open] .hide-label {
  display: inline;
}

.cs-details[open] .show-label {
  display: none;
}

.cs-body {
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-2);
  padding-top: var(--space-4);
}

.cs-body > p:last-child,
.cs-body > ul:last-child {
  margin-bottom: 0;
}

@media (min-width: 640px) {
  .case-study {
    padding-inline: var(--space-5);
  }
}

/* Skills strip */
.skills-groups {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-3);
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .skills-groups {
    grid-template-columns: 1fr 1fr;
  }
}

.skills-groups li {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.skills-groups li:hover {
  border-color: var(--color-accent);
  transform: translateY(-2px);
}

.skills-groups .group-name {
  display: block;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: var(--space-1);
}

.skills-groups .group-items {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Contact */
.contact-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.contact-links li {
  margin: 0;
}

/* Footer */
footer {
  border-top: 1px solid var(--color-border);
  padding-block: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Skip link for keyboard users: hidden until focused */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--color-surface);
  color: var(--color-accent);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  z-index: 10;
}

.skip-link:focus {
  left: var(--space-3);
  top: var(--space-3);
}

/* Wide screens: use the canvas. The page widens and content sections split
   into a left rail (section heading) and a right content column, so large
   displays get an editorial layout instead of one narrow centered strip.
   Paragraph measure stays readable; only the frame around it grows. */
@media (min-width: 1200px) {
  .container {
    max-width: 64rem;
  }

  .hero {
    padding-block: 7rem;
  }

  .hero h1 {
    font-size: 3.5rem;
  }

  .hero .pitch {
    font-size: 1.625rem;
    max-width: 44rem;
  }

  .rail {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    column-gap: var(--space-6);
    align-items: start;
  }

  .rail > h2 {
    grid-column: 1;
    grid-row: 1 / span 9; /* covers every content row so sticky lasts the whole section */
    position: sticky;
    top: var(--space-4);
  }

  .rail > :not(h2) {
    grid-column: 2;
  }

  .skills-groups {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Respect users who turn off animation */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }
}
