/* North Davis Heights — shared design system
 * Extends Timothy's original editorial/topographic aesthetic across
 * multiple pages. All page-specific layout lives inline per page. */

:root {
  --paper:    #f3efe6;
  --paper-2:  #ece6d9;
  --ink:      #2a2620;
  --ink-soft: #6f6656;
  --line:     rgba(120, 104, 78, 0.30);
  --line-strong: rgba(120, 104, 78, 0.55);
  --accent:   #9a6a3a;
  --sky:      #c9d3cf;
  --paper-shadow: rgba(74, 60, 36, 0.10);
  --max-width: 1180px;
  --gutter: clamp(1.6rem, 4vw, 3.4rem);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { min-height: 100%; }

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(120% 90% at 50% 0%, var(--sky) 0%, var(--paper) 42%),
    var(--paper);
  color: var(--ink);
  font-family: "Archivo", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  position: relative;
  min-height: 100vh;
}

/* drifting topographic contours — fixed background across all pages */
.topo {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
}
.topo path { fill: none; stroke: var(--line); stroke-width: 1; }
.topo .grp { animation: drift 26s ease-in-out infinite alternate; }
@keyframes drift {
  from { transform: translateY(-10px); }
  to   { transform: translateY(14px); }
}

/* paper grain */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 2;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* frame — the master layout wrapper, z above topo + grain */
.frame {
  position: relative;
  z-index: 3;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--gutter);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(2rem, 5vw, 4rem);
}

/* masthead — shared site header */
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-soft);
  flex-wrap: wrap;
  gap: 0.8rem;
}
.masthead-mark {
  color: var(--ink);
  text-decoration: none;
  font-weight: 500;
}
.masthead-mark:hover { color: var(--accent); }

.masthead-nav {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}
.masthead-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s;
}
.masthead-nav a:hover,
.masthead-nav a[aria-current="page"] {
  color: var(--accent);
}

/* footer */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  flex-wrap: wrap;
  gap: 0.6rem;
}
.footer b { color: var(--accent); font-weight: 600; }
.footer a { color: var(--ink-soft); text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* type primitives */
h1, h2, h3 {
  font-family: "Cormorant Garamond", serif;
  font-weight: 300;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--ink);
}
h1 em, h2 em, h3 em {
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
}

h1 { font-size: clamp(2.8rem, 8vw, 5.6rem); }
h2 { font-size: clamp(2rem, 4.5vw, 3.2rem); }
h3 { font-size: clamp(1.4rem, 2.4vw, 1.8rem); }

p { color: var(--ink); }
p + p { margin-top: 1rem; }

.eyebrow {
  font-family: "Archivo", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 500;
}

.tagline {
  font-family: "Cormorant Garamond", serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.15rem, 2.4vw, 1.6rem);
  color: var(--ink-soft);
  line-height: 1.45;
}

.rule {
  width: 64px;
  height: 1px;
  background: var(--accent);
  border: 0;
  margin: 1.6rem 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, color 0.2s;
}
a:hover { border-bottom-color: var(--accent); }

/* buttons — editorial ghost style, hairline only */
.btn {
  display: inline-block;
  font-family: "Archivo", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 0.85rem 1.5rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  border-radius: 0;
}
.btn:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn-accent {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-accent:hover {
  background: var(--accent);
  color: var(--paper);
}
.btn-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-top: 1.6rem;
}

/* images — generous margin, hairline border */
.photo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  background: var(--paper-2);
  box-shadow: 4px 6px 18px var(--paper-shadow);
}
.photo-frame {
  margin: clamp(2rem, 5vw, 4rem) 0;
}
.photo-frame figcaption {
  margin-top: 0.85rem;
  font-family: "Archivo", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* photo placeholder — used until real photos drop into images/ */
.photo-placeholder {
  position: relative;
  aspect-ratio: 3 / 2;
  background:
    repeating-linear-gradient(135deg,
      transparent 0 18px,
      rgba(120, 104, 78, 0.06) 18px 19px),
    var(--paper-2);
  border: 1px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-placeholder::after {
  content: attr(data-label);
  font-family: "Archivo", sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: var(--paper);
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--line-strong);
}

/* page section primitives */
.section {
  padding: clamp(2.5rem, 6vw, 5rem) 0;
  border-top: 1px solid var(--line);
}
.section:first-child { border-top: 0; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: clamp(1.5rem, 3vw, 2.4rem);
  flex-wrap: wrap;
}
.section-head .eyebrow { color: var(--ink-soft); }
.section-head h2 { flex: 1; min-width: 16rem; }

.lede {
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  line-height: 1.45;
  color: var(--ink);
  max-width: 38em;
  font-weight: 400;
}

.col-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 4vw, 4rem);
}
@media (max-width: 760px) {
  .col-2 { grid-template-columns: 1fr; }
}

/* animation utilities — opt-in via class */
@keyframes fade  { to { opacity: 1; } }
@keyframes rise  { to { transform: translateY(0); } }
@keyframes grow  { from { transform: scaleX(0); opacity: 0; }
                   to   { transform: scaleX(1); opacity: 1; } }

.fade-in {
  opacity: 0;
  animation: fade 1s ease 0.2s forwards;
}
.rule.grow-in {
  opacity: 0;
  transform-origin: left;
  animation: grow 0.9s ease 0.6s forwards;
}

@media (prefers-reduced-motion: reduce) {
  .topo .grp { animation: none; }
  .fade-in, .rule.grow-in { animation: none; opacity: 1; transform: none; }
}

/* utilities */
.center { text-align: center; }
.muted  { color: var(--ink-soft); }
.no-wrap { white-space: nowrap; }
.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;
}

/* ============================================================
   dark mode — same editorial palette, turned to night
   ============================================================ */

[data-theme="dark"] {
  --paper:        #14110d;
  --paper-2:      #1d1812;
  --ink:          #ece6d4;
  --ink-soft:     #8b8068;
  --line:         rgba(190, 170, 130, 0.22);
  --line-strong:  rgba(190, 170, 130, 0.40);
  --accent:       #d49a64;
  --sky:          #1a1f30;
  --paper-shadow: rgba(0, 0, 0, 0.50);
}

/* paper grain reads a touch heavier on the dark field */
[data-theme="dark"] body::after { opacity: 0.07; }

/* photo placeholder hatch needs lighter stripes on dark */
[data-theme="dark"] .photo-placeholder {
  background:
    repeating-linear-gradient(135deg,
      transparent 0 18px,
      rgba(190, 170, 130, 0.05) 18px 19px),
    var(--paper-2);
}

/* default .btn (ink-based) inverts contrast in dark */
[data-theme="dark"] .btn {
  color: var(--ink);
  border-color: var(--ink);
}
[data-theme="dark"] .btn:hover {
  background: var(--ink);
  color: var(--paper);
}

/* theme-aware transition on the body so the swap feels deliberate, not jarring */
body, .photo-placeholder, .btn {
  transition: background 0.45s ease, color 0.45s ease, border-color 0.45s ease;
}


/* ============================================================
   theme toggle button — sits inside .masthead-nav
   ============================================================ */

.theme-toggle {
  background: transparent;
  border: 1px solid var(--line);
  cursor: pointer;
  padding: 0.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-soft);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  border-radius: 0;
  line-height: 0;
  margin-left: 0.4rem;
}
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.theme-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}
.theme-toggle svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }


/* ============================================================
   starfield — fixed background layer, only visible in dark mode
   injected by js/theme.js on page load
   ============================================================ */

.starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.4s ease;
}
[data-theme="dark"] .starfield { opacity: 1; }

.starfield circle { fill: #f3efe6; }
.starfield .twinkle {
  animation: twinkle 4s ease-in-out infinite;
  transform-origin: center;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.9; }
  50%      { opacity: 0.18; }
}
@media (prefers-reduced-motion: reduce) {
  .starfield .twinkle { animation: none; }
  body, .photo-placeholder, .btn { transition: none; }
}
