/* ============================================
   Stanley Blyth — Shared Stylesheet
   ============================================ */

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

:root {
  --ink:       #18140f;
  --parchment: #f4ede0;
  --sand:      #e6d9c2;
  --clay:      #b07d4e;
  --rust:      #7a3f20;
  --moss:      #445238;
  --fog:       #bfb39e;
  --cream:     #f5f0eb;
}

/* =====================
   DARK MODE — warm brown/tan palette
   ===================== */
html.dark {
  --ink:       #e8d4b5;
  --parchment: #2e2216;
  --sand:      #2a1e14;
  --clay:      #c9975e;
  --rust:      #c26a40;
  --moss:      #526342;
  --fog:       #7a6a56;
  --cream:     #231810;
}

html.dark body {
  background: var(--cream);
  color: var(--ink);
}

html.dark nav {
  background: rgba(22, 16, 10, 0.94);
  border-bottom-color: rgba(201, 151, 94, 0.14);
}

html.dark .identity-strip {
  background: #1a1108;
}

html.dark .section-card {
  background: #2a1e14;
}

html.dark .section-card:hover {
  background: #312416;
}

html.dark .section-card.featured {
  background: #3a4d2e;
}

html.dark .section-card.featured:hover {
  background: #2f3f25;
}

html.dark .latest-posts {
  background: #2a1e14;
}

html.dark footer {
  background: #1a1108;
}

html.dark .sections-grid {
  background: rgba(201, 151, 94, 0.12);
  border-color: rgba(201, 151, 94, 0.12);
}

html.dark .writing-item {
  border-bottom-color: rgba(201, 151, 94, 0.18);
}

html.dark .writing-item:first-child {
  border-top-color: rgba(201, 151, 94, 0.18);
}

/* =====================
   DARK MODE TOGGLE
   ===================== */
.dark-toggle {
  background: none;
  border: 1px solid rgba(176, 125, 78, 0.3);
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  border-radius: 2px;
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.55;
  transition: opacity 0.2s, border-color 0.2s, color 0.2s;
  margin-left: 1.5rem;
  flex-shrink: 0;
}
.dark-toggle:hover { opacity: 1; border-color: var(--clay); color: var(--clay); }

/* =====================
   NAV DROPDOWN (Career)
   ===================== */
.nav-dropdown {
  position: relative;
}

.nav-dropdown > a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  vertical-align: middle;
}

.nav-dropdown > a::after {
  content: none !important;
}

.nav-dropdown > a .dropdown-caret {
  display: inline-block;
  font-size: 0.5rem;
  opacity: 0.5;
  transition: transform 0.2s;
  pointer-events: none;
}

.nav-dropdown:hover > a .dropdown-caret,
.nav-dropdown.open > a .dropdown-caret {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 1.2rem);
  left: 50%;
  transform: translateX(-50%);
  background: var(--cream);
  border: 1px solid rgba(176, 125, 78, 0.22);
  border-radius: 4px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.06);
  min-width: 280px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 600;
}

html.dark .nav-dropdown-menu {
  background: #231810;
  border-color: rgba(201, 151, 94, 0.2);
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.85rem 1.3rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  opacity: 0.6;
  border-bottom: 1px solid rgba(176, 125, 78, 0.1);
  transition: opacity 0.2s, background 0.2s, color 0.2s;
  white-space: nowrap;
}

html.dark .nav-dropdown-menu a {
  border-bottom-color: rgba(201, 151, 94, 0.1);
}

.nav-dropdown-menu a:last-child { border-bottom: none; }
.nav-dropdown-menu a:hover { opacity: 1; color: var(--clay); background: rgba(176, 125, 78, 0.06); }

.nav-dropdown-menu .menu-period {
  display: block;
  font-size: 0.52rem;
  opacity: 0.45;
  margin-top: 0.2rem;
  font-style: normal;
}

html { scroll-behavior: smooth; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Jost', sans-serif;
  font-weight: 300;
  line-height: 1.7;
  overflow-x: hidden;
}

/* GRAIN TEXTURE */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
}

/* =====================
   NAVIGATION
   ===================== */

nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 4rem;
  background: rgba(245, 240, 235, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(176, 125, 78, 0.12);
}

.nav-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-logo:hover { color: var(--clay); }

.nav-links {
  display: flex;
  gap: 2.4rem;
  list-style: none;
}

.nav-links a {
  font-family: 'DM Mono', monospace;
  font-size: 0.64rem;
  font-weight: 300;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  opacity: 0.5;
  position: relative;
  transition: opacity 0.25s, color 0.25s;
  outline: none;
}
.nav-links a:focus-visible {
  outline: 1px solid var(--clay);
  outline-offset: 3px;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--clay);
  transition: width 0.25s ease;
}

.nav-links a:hover { opacity: 1; color: var(--clay); }
.nav-links a:hover::after { width: 100%; }

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

footer {
  background: var(--ink);
  padding: 3rem 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 300;
  color: var(--parchment);
}

.footer-nav {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.footer-nav a {
  font-family: 'DM Mono', monospace;
  font-size: 0.56rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
  opacity: 0.45;
  text-decoration: none;
  transition: opacity 0.2s;
}
.footer-nav a:hover { opacity: 1; }

.footer-copy {
  font-family: 'DM Mono', monospace;
  font-size: 0.55rem;
  color: var(--fog);
  opacity: 0.3;
}

/* =====================
   BUTTONS
   ===================== */

.btn-primary {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--cream);
  background: var(--rust);
  padding: 0.9rem 2.2rem;
  border: none;
  cursor: pointer;
  display: inline-block;
  transition: background 0.25s, transform 0.2s;
}
.btn-primary:hover { background: var(--clay); transform: translateY(-2px); }

.btn-ghost {
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  opacity: 0.5;
  transition: opacity 0.2s;
}
.btn-ghost:hover { opacity: 1; }

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

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

/* =====================
   SCROLL REVEAL
   ===================== */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* =====================
   PAGE HEADER
   (section index pages)
   ===================== */

.page-header {
  padding: 8rem 4rem 3.5rem;
  border-bottom: 1px solid rgba(176,125,78,0.15);
  opacity: 0;
  animation: fadeUp 0.6s ease forwards 0.1s;
}

.page-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--clay);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.page-eyebrow::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--clay);
}

.page-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 300;
  color: var(--ink);
  line-height: 1.1;
}

.page-title em {
  font-style: italic;
  color: var(--clay);
}

.page-sub {
  font-family: 'Jost', sans-serif;
  font-size: 0.9rem;
  color: var(--ink);
  opacity: 0.5;
  margin-top: 0.8rem;
  max-width: 52ch;
  line-height: 1.7;
}

/* =====================
   POST LIST
   (section index pages)
   ===================== */

.post-list {
  padding: 0 4rem 5rem;
}

.post-item {
  display: grid;
  grid-template-columns: 120px 1fr 130px;
  gap: 3rem;
  align-items: baseline;
  padding: 2rem 0;
  border-bottom: 1px solid rgba(176,125,78,0.12);
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: padding-left 0.25s ease;
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.post-item:first-child { border-top: 1px solid rgba(176,125,78,0.12); }
.post-item:hover { padding-left: 0.8rem; }

.post-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--clay);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.3s ease;
}
.post-item:hover::before { transform: scaleY(1); }

.post-tag {
  font-family: 'DM Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--clay);
}

.post-title-link {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  transition: color 0.2s;
}
.post-item:hover .post-title-link { color: var(--rust); }

.post-date {
  font-family: 'DM Mono', monospace;
  font-size: 0.55rem;
  color: var(--fog);
  text-align: right;
  opacity: 0.7;
}

/* Post animation delays */
.post-item:nth-child(1) { animation-delay: 0.3s; }
.post-item:nth-child(2) { animation-delay: 0.38s; }
.post-item:nth-child(3) { animation-delay: 0.46s; }
.post-item:nth-child(4) { animation-delay: 0.54s; }
.post-item:nth-child(5) { animation-delay: 0.62s; }
.post-item:nth-child(6) { animation-delay: 0.70s; }

/* =====================
   RESPONSIVE
   ===================== */

/* =====================
   HAMBURGER BUTTON
   ===================== */

.nav-burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  margin-left: 1rem;
  width: 36px;
  height: 36px;
}

.nav-burger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

nav.nav-open .nav-burger span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
nav.nav-open .nav-burger span:nth-child(2) { opacity: 0; }
nav.nav-open .nav-burger span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

@media (max-width: 960px) {
  nav { padding: 1.1rem 2rem; }
  .nav-links { gap: 1.5rem; }
}

@media (max-width: 768px) {
  nav { padding: 1.1rem 1.5rem; }

  .nav-burger { display: flex; }

  .nav-links {
    position: fixed;
    top: 57px;
    left: 0; right: 0;
    background: rgba(245, 240, 235, 0.98);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-direction: column;
    align-items: flex-start;
    padding: 1.8rem 2rem;
    gap: 1.4rem;
    border-bottom: 1px solid rgba(176,125,78,0.15);
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 490;
  }

  html.dark .nav-links {
    background: rgba(22, 16, 10, 0.98);
  }

  nav.nav-open .nav-links {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .nav-links a {
    font-size: 0.75rem;
    opacity: 0.7;
  }

  .page-header { padding: 6rem 1.5rem 2.5rem; }
  .post-list { padding: 0 1.5rem 4rem; }
  .post-item { grid-template-columns: 70px 1fr; gap: 1rem; }
  .post-date { display: none; }
  footer {
    padding: 2.5rem 1.5rem;
    flex-direction: column;
    gap: 1.2rem;
    text-align: center;
  }
  .footer-nav { display: none; }
}
