/* ============================================
   Justin Sawyer — Portfolio
   Editorial / Pacific Northwest aesthetic
   ============================================ */

:root {
  /* Light theme — warm paper + ink */
  --bg: #F6F2E9;
  --bg-elevated: #FAF7EF;
  --ink: #1A1B16;
  --ink-soft: #3D3E36;
  --muted: #7A7568;
  --rule: #D8D2C4;
  --accent: #3F5226;          /* deep moss */
  --accent-hover: #2E3D1A;
  --grain-opacity: 0.06;

  /* Type system */
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --body: 'Hanken Grotesk', 'Helvetica Neue', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  /* Spacing */
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --column: min(720px, 100%);
}

[data-theme="dark"] {
  --bg: #14150F;
  --bg-elevated: #1B1C16;
  --ink: #ECE8DD;
  --ink-soft: #C9C4B6;
  --muted: #807A6C;
  --rule: #2E2F26;
  --accent: #A8C271;          /* lifted moss for dark */
  --accent-hover: #C1D88B;
  --grain-opacity: 0.04;
}

/* Honor system preference if no manual override */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14150F;
    --bg-elevated: #1B1C16;
    --ink: #ECE8DD;
    --ink-soft: #C9C4B6;
    --muted: #807A6C;
    --rule: #2E2F26;
    --accent: #A8C271;
    --accent-hover: #C1D88B;
    --grain-opacity: 0.04;
  }
}

/* ============================================
   Reset + base
   ============================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--body);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  transition: background 200ms ease, color 200ms ease;
  min-height: 100vh;
  position: relative;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: inherit;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ============================================
   Grain overlay — subtle paper texture
   ============================================ */

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: multiply;
}

[data-theme="dark"] .grain,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .grain { mix-blend-mode: screen; }
}
[data-theme="dark"] .grain { mix-blend-mode: screen; }

/* ============================================
   Top bar — wordmark + theme toggle
   ============================================ */

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem var(--gutter);
  max-width: 1200px;
  margin: 0 auto;
}

.wordmark {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  font-feature-settings: "ss01";
}

.wordmark::after {
  content: " /";
  color: var(--accent);
  font-style: italic;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 150ms ease;
}

.theme-toggle:hover { background: var(--rule); }

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

.sun-icon { display: none; }
.moon-icon { display: block; }

[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sun-icon { display: block; }
  :root:not([data-theme="light"]) .moon-icon { display: none; }
}

/* ============================================
   Main layout
   ============================================ */

main {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ============================================
   Hero
   ============================================ */

.hero {
  padding: clamp(3rem, 10vw, 7rem) 0 clamp(4rem, 12vw, 9rem);
  max-width: var(--column);
}

.kicker {
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 2rem;
}

.hero-name {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(3.5rem, 12vw, 7rem);
  line-height: 0.95;
  letter-spacing: -0.025em;
  margin: 0 0 1.75rem;
  color: var(--ink);
  font-feature-settings: "ss01", "ss02";
  /* Use Fraunces optical sizing — bigger size = different stress */
  font-variation-settings: "opsz" 144, "SOFT" 30;
}

.hero-name em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.hero-role {
  font-size: clamp(1.125rem, 2.4vw, 1.375rem);
  line-height: 1.5;
  color: var(--ink-soft);
  margin: 0 0 2.5rem;
  max-width: 38ch;
  font-weight: 300;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.875rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  color: var(--muted);
}

.hero-links a {
  position: relative;
  color: var(--ink);
  transition: color 150ms ease;
}

.hero-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: currentColor;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 200ms ease;
}

.hero-links a:hover { color: var(--accent); }
.hero-links a:hover::after { transform: scaleX(1); }

/* ============================================
   Sections
   ============================================ */

.section {
  padding: clamp(2.5rem, 6vw, 5rem) 0;
  border-top: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 720px) {
  .section {
    grid-template-columns: 200px 1fr;
    gap: 4rem;
  }
}

.section-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0;
  align-self: start;
  position: sticky;
  top: 1rem;
}

.section-label .num {
  color: var(--accent);
  margin-right: 0.5rem;
}

/* ============================================
   About
   ============================================ */

.about-body {
  font-size: 1.0625rem;
  max-width: 58ch;
}

.about-body p {
  margin: 0 0 1.25rem;
}

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

.about-body a {
  color: var(--accent);
  border-bottom: 1px solid var(--rule);
  transition: border-color 150ms ease;
}

.about-body a:hover { border-bottom-color: var(--accent); }

/* ============================================
   Projects list
   ============================================ */

.projects {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project {
  border-bottom: 1px solid var(--rule);
}

.project:first-child {
  border-top: 1px solid var(--rule);
}

.project-link {
  display: block;
  padding: 1.5rem 0;
  transition: padding-left 200ms ease;
  position: relative;
}

.project-link::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  color: var(--accent);
  opacity: 0;
  transition: opacity 200ms ease, left 200ms ease;
}

@media (min-width: 720px) {
  .project-link:hover {
    padding-left: 1rem;
  }
  .project-link:hover::before {
    content: "→";
    opacity: 1;
    left: -0.25rem;
  }
}

.project-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1.25rem;
  align-items: baseline;
}

.project-index {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.project-content { min-width: 0; }

.project-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  line-height: 1.15;
  margin: 0 0 0.375rem;
  color: var(--ink);
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 48;
}

.project-link:hover .project-title { color: var(--accent); }

.project-teaser {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 52ch;
}

.project-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

@media (max-width: 540px) {
  .project-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  .project-meta { text-align: left; }
}

/* ============================================
   CTA section
   ============================================ */

.cta-body p {
  font-size: 1.125rem;
  max-width: 50ch;
  margin: 0 0 2rem;
  color: var(--ink-soft);
}

.cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.875rem 1.5rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 0;
  transition: all 150ms ease;
  border: 1px solid var(--rule);
}

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

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

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

/* ============================================
   Footer
   ============================================ */

.footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
  padding: 2.5rem var(--gutter);
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.footer-text {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
}

/* ============================================
   Project detail pages
   ============================================ */

.detail-page main {
  padding-top: 1rem;
  padding-bottom: 4rem;
}

.detail-hero {
  max-width: var(--column);
  padding: clamp(2rem, 6vw, 4rem) 0 2rem;
}

.back-link {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
  display: inline-block;
  margin-bottom: 2rem;
  transition: color 150ms ease;
}

.back-link:hover { color: var(--accent); }

.detail-eyebrow {
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 0 0 1rem;
}

.detail-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.5rem, 7vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  font-variation-settings: "opsz" 96, "SOFT" 30;
}

.detail-summary {
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--ink-soft);
  max-width: 50ch;
  font-weight: 300;
  margin: 0 0 2rem;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  padding: 1.25rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}

.detail-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.detail-meta-label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.detail-meta-value {
  font-family: var(--body);
  font-size: 0.9375rem;
  color: var(--ink);
}

.detail-body {
  max-width: var(--column);
  font-size: 1.0625rem;
}

.detail-body h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  margin: 3rem 0 1rem;
  font-variation-settings: "opsz" 32;
}

.detail-body h2:first-child { margin-top: 0; }

.detail-body p {
  margin: 0 0 1.25rem;
  color: var(--ink-soft);
}

.detail-body strong {
  color: var(--ink);
  font-weight: 500;
}

.detail-body ul {
  padding-left: 1.25rem;
  color: var(--ink-soft);
}

.detail-body li {
  margin-bottom: 0.5rem;
}

.detail-body a {
  color: var(--accent);
  border-bottom: 1px solid var(--rule);
  transition: border-color 150ms ease;
}

.detail-body a:hover { border-bottom-color: var(--accent); }

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0;
  list-style: none;
  padding: 0;
}

.tag {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--rule);
  color: var(--ink-soft);
  letter-spacing: 0.03em;
}
