/* ==========================================================================
   Justin Carland — Personal Site
   Fonts: General Sans (display) + Satoshi (body) via Fontshare
   ========================================================================== */

/* --- Design Tokens --- */
:root {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem,     1.2rem  + 2.5vw,  3.5rem);
  --text-3xl:  clamp(2.5rem,   1rem    + 4vw,    5rem);

  /* Spacing (4px base) */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* Fonts */
  --font-display: 'General Sans', 'Helvetica Neue', sans-serif;
  --font-body: 'Satoshi', 'Inter', sans-serif;

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Transitions */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Content widths */
  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;
}

/* --- Light Mode (default) --- */
:root, [data-theme="light"] {
  --color-bg:             #f7f6f2;
  --color-surface:        #ffffff;
  --color-surface-2:      #fbfbf9;
  --color-surface-offset: #f0ede8;
  --color-border:         #dcd9d2;
  --color-divider:        #e8e5e0;
  --color-text:           #1a1814;
  --color-text-muted:     #6b6862;
  --color-text-faint:     #a5a29c;
  --color-primary:        #01696f;
  --color-primary-hover:  #0c4e54;
  --color-primary-highlight: #e0f0f0;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
}

/* --- Dark Mode --- */
[data-theme="dark"] {
  --color-bg:             #111110;
  --color-surface:        #1a1918;
  --color-surface-2:      #201f1e;
  --color-surface-offset: #1d1c1b;
  --color-border:         #2e2d2b;
  --color-divider:        #252423;
  --color-text:           #e0dfdc;
  --color-text-muted:     #8a8884;
  --color-text-faint:     #5a5856;
  --color-primary:        #4f98a3;
  --color-primary-hover:  #6bb4be;
  --color-primary-highlight: #1c2e30;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:             #111110;
    --color-surface:        #1a1918;
    --color-surface-2:      #201f1e;
    --color-surface-offset: #1d1c1b;
    --color-border:         #2e2d2b;
    --color-divider:        #252423;
    --color-text:           #e0dfdc;
    --color-text-muted:     #8a8884;
    --color-text-faint:     #5a5856;
    --color-primary:        #4f98a3;
    --color-primary-hover:  #6bb4be;
    --color-primary-highlight: #1c2e30;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
  }
}


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

html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.15; }
p, li, figcaption { text-wrap: pretty; max-width: 72ch; }
button { cursor: pointer; background: none; border: none; }

::selection {
  background: rgba(1, 105, 111, 0.2);
  color: var(--color-text);
}

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

a, button, [role="button"], input, textarea, select {
  transition: color var(--transition-interactive),
              background var(--transition-interactive),
              border-color var(--transition-interactive),
              box-shadow var(--transition-interactive);
}

@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;
  }
}

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


/* ==========================================================================
   HEADER
   ========================================================================== */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 246, 242, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-divider);
  transition: box-shadow 0.3s ease;
}

[data-theme="dark"] .header {
  background: rgba(17, 17, 16, 0.85);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .header {
    background: rgba(17, 17, 16, 0.85);
  }
}

.header--scrolled {
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.logo svg {
  display: block;
}

.logo:hover {
  color: var(--color-primary);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.nav-link {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  letter-spacing: 0.01em;
}

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

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}

.theme-toggle:hover {
  color: var(--color-text);
  background: var(--color-surface-offset);
}


/* ==========================================================================
   HERO
   ========================================================================== */

.hero {
  padding: clamp(var(--space-20), 12vw, var(--space-32)) var(--space-6) clamp(var(--space-16), 10vw, var(--space-24));
}

.hero-inner {
  max-width: var(--content-default);
  margin: 0 auto;
}

.hero-label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-primary);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-4);
}

.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--color-text);
  margin-bottom: var(--space-6);
}

.hero-subtitle {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  max-width: 52ch;
  line-height: 1.7;
}


/* ==========================================================================
   SECTION SHARED
   ========================================================================== */

.section-label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.section-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  margin-bottom: var(--space-8);
}


/* ==========================================================================
   ABOUT
   ========================================================================== */

.about {
  padding: clamp(var(--space-12), 8vw, var(--space-24)) var(--space-6);
  border-top: 1px solid var(--color-divider);
}

.about-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-12);
}

.about-body p {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-4);
}

.about-body p:last-child {
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .about-inner {
    grid-template-columns: 1fr;
    gap: var(--space-2);
  }
  .section-title {
    margin-bottom: var(--space-6);
  }
}


/* ==========================================================================
   CARDS (What I Do)
   ========================================================================== */

.work {
  padding: clamp(var(--space-12), 8vw, var(--space-24)) var(--space-6);
  border-top: 1px solid var(--color-divider);
}

.work-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  transition: box-shadow var(--transition-interactive),
              border-color var(--transition-interactive);
}

.card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-highlight);
  border-radius: var(--radius-md);
  color: var(--color-primary);
  margin-bottom: var(--space-5);
}

.card-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
}

.card-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.65;
}

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}


/* ==========================================================================
   CONTACT
   ========================================================================== */

.contact {
  padding: clamp(var(--space-12), 8vw, var(--space-24)) var(--space-6);
  border-top: 1px solid var(--color-divider);
}

.contact-inner {
  max-width: var(--content-narrow);
  margin: 0 auto;
}

.contact-text {
  font-size: var(--text-base);
  color: var(--color-text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-6);
}

.contact-email {
  display: inline-block;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-primary);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.contact-email:hover {
  color: var(--color-primary-hover);
  border-bottom-color: var(--color-primary-hover);
}


/* ==========================================================================
   FOOTER
   ========================================================================== */

.footer {
  border-top: 1px solid var(--color-divider);
  padding: var(--space-8) var(--space-6);
}

.footer-inner {
  max-width: var(--content-wide);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-copyright {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.footer-attribution {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-decoration: none;
}

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

@media (max-width: 480px) {
  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}


/* ==========================================================================
   ENTRANCE ANIMATIONS
   ========================================================================== */

.animate-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Stagger cards */
.card.animate-in:nth-child(2) {
  transition-delay: 0.08s;
}
.card.animate-in:nth-child(3) {
  transition-delay: 0.16s;
}
