/* ---- Variables ---- */
:root {
  --bg: #fafaf8;
  --text: #1a1a1a;
  --text-muted: #666;
  --text-link: #3a3a3a;
  --border: #e5e2dc;
  --nav-bg: rgba(250, 250, 248, 0.85);
  --hub-width: 1100px;
  --content-width: 680px;
  --font: 'Cormorant Garamond', Georgia, serif;
}

[data-theme="dark"] {
  --bg: #0c0c0c;
  --text: #eae8e1;
  --text-muted: #888;
  --text-link: #c8c6bf;
  --border: #252525;
  --nav-bg: rgba(12, 12, 12, 0.85);
}

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

/* ---- Base ---- */
html {
  font-size: 19px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a {
  color: var(--text);
  text-decoration: none;
}

/* ---- Scroll Reveal ---- */
.reveal {
  transform: translateY(40px);
  will-change: transform;
  transition: transform 0.85s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.revealed {
  transform: translateY(0);
}

/* Stagger children inside a revealed parent */
.content-card-grid .reveal:nth-child(2) { transition-delay: 0.1s; }
.content-card-grid .reveal:nth-child(3) { transition-delay: 0.2s; }
.recent-writing article:nth-child(2) { transition-delay: 0.05s; }
.recent-writing article:nth-child(3) { transition-delay: 0.1s; }
.recent-writing article:nth-child(4) { transition-delay: 0.15s; }
.recent-writing article:nth-child(5) { transition-delay: 0.2s; }

@media (prefers-reduced-motion: reduce) {
  .reveal {
    transform: none;
    transition: none;
    will-change: auto;
  }
}

/* ---- Sticky Nav / Glass ---- */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  transition: background 0.25s ease;
}

nav {
  max-width: var(--hub-width);
  margin: 0 auto;
  padding: 1.4rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-name {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.site-name:hover { text-decoration: none; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 2rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.nav-right a {
  color: var(--text-muted);
  transition: color 0.15s;
}

.nav-right a:hover,
.nav-right a.active {
  color: var(--text);
  text-decoration: none;
}

#theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.6rem;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

#theme-toggle:hover { color: var(--text); }

/* ---- Main wrapper ---- */
main { overflow-x: hidden; }

/* ---- Hero ---- */
.home-hero {
  margin: 0 auto;
  padding: 5rem 2rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: calc(100vh - 64px);
  justify-content: center;
  position: relative;
}

.hero-photo {
  animation: heroFadeUp 1s cubic-bezier(0.16, 1, 0.3, 1) both;
  margin-bottom: 2rem;
}

.portrait {
  width: 260px;
  height: 260px;
  object-fit: cover;
  object-position: center 12%;
  border-radius: 50%;
  display: block;
}

.hero-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 560px;
}

.hero-text h1 {
  font-size: clamp(2.8rem, 4vw, 3.8rem);
  font-weight: 400;
  line-height: 1.0;
  letter-spacing: -0.01em;
  animation: heroFadeUp 1s 0.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.tagline {
  font-size: clamp(1.2rem, 2vw, 1.45rem);
  font-weight: 400;
  line-height: 1.5;
  animation: heroFadeUp 1s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.bio {
  font-size: 1.1rem;
  color: var(--text);
  opacity: 0.75;
  line-height: 1.7;
  animation: heroFadeUp 1s 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.hero-text .social-links {
  animation: heroFadeUp 1s 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.scroll-hint {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--text-muted);
  opacity: 0;
  animation: heroFadeUp 1s 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards,
             scrollBounce 2s 1.8s ease-in-out infinite;
}

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

@keyframes scrollBounce {
  0%, 100% { transform: translateX(-50%) translateY(0); opacity: 0.45; }
  50%       { transform: translateX(-50%) translateY(7px); opacity: 0.9; }
}

/* ---- Social Icons ---- */
.social-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.social-links a {
  color: var(--text-muted);
  transition: color 0.2s;
  display: flex;
  align-items: center;
}

.social-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.social-links svg {
  width: 20px;
  height: 20px;
}

/* ---- Hub sections (YouTube + Substack) ---- */
.hub-section {
  border-top: 1px solid var(--border);
  padding: 6rem 2rem;
}

.hub-section-inner {
  max-width: var(--hub-width);
  margin: 0 auto;
  width: 100%;
}

.hub-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2rem;
}

.hub-label {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hub-see-all {
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.hub-see-all:hover {
  color: var(--text);
  text-decoration: none;
}

.hub-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ---- Shared content card grid (YouTube + Substack) ---- */
.content-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}

.content-card {
  display: block;
  transition: opacity 0.2s;
}

.content-card:hover {
  opacity: 0.6;
  text-decoration: none;
}

.card-thumb {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 5px;
  background: var(--border);
  margin-bottom: 0.9rem;
}

.card-thumb--empty {
  background: var(--border);
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.content-card:hover .card-thumb img {
  transform: scale(1.03);
}

.card-title {
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
}

/* ---- Instagram ---- */
.hub-instagram {
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
}

.instagram-moment {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  transition: opacity 0.2s;
  text-align: center;
}

.instagram-moment:hover {
  opacity: 0.6;
  text-decoration: none;
}

.instagram-moment svg {
  width: 26px;
  height: 26px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.insta-handle {
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.insta-cta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* ---- Recent Writing (Home) ---- */
.recent-writing {
  border-top: 1px solid var(--border);
  padding: 4rem 0 5rem;
}

.writing-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 2rem;
}

.recent-writing h2 {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.recent-writing article {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  gap: 2rem;
  transition: opacity 0.2s;
}

.recent-writing article:hover { opacity: 0.55; }

.recent-writing article a { font-size: 1rem; flex: 1; }
.recent-writing article a:hover { text-decoration: none; }

.recent-writing time,
.writing-archive time {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.view-all {
  display: block;
  text-align: right;
  margin-top: 1.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.view-all:hover {
  color: var(--text);
  text-decoration: none;
}

/* ---- Writing Archive ---- */
.writing-archive {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 3.5rem 2rem 5rem;
}

.writing-archive h1 {
  font-size: 2.5rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  margin-bottom: 2.5rem;
}

.year-group { margin-bottom: 0.25rem; }

.year-label {
  display: block;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 2rem 0 0.75rem;
}

.writing-archive article {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  gap: 2rem;
  transition: opacity 0.2s;
}

.writing-archive article:hover { opacity: 0.55; }
.writing-archive article a { font-size: 1rem; flex: 1; }
.writing-archive article a:hover { text-decoration: none; }

/* ---- Single Post ---- */
.post {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 3.5rem 2rem 5rem;
}

.post-header {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  font-weight: 400;
  line-height: 1.25;
  margin-bottom: 0.6rem;
  letter-spacing: 0.01em;
}

.post-header time {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.post-content {
  font-size: 1.05rem;
  line-height: 1.85;
}

.post-content p { margin-bottom: 1.5rem; }

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 400;
  margin: 3rem 0 0.75rem;
}

.post-content h3 {
  font-size: 1.2rem;
  font-weight: 400;
  margin: 2.25rem 0 0.5rem;
}

/* Fixed: links visible within post body */
.post-content a {
  color: var(--text-link);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  transition: text-decoration-color 0.2s;
}

.post-content a:hover {
  text-decoration-color: var(--text);
}

.post-content blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1.5rem;
  margin: 2rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.post-content li { margin-bottom: 0.4rem; }

.post-content img {
  max-width: 100%;
  height: auto;
  margin: 2rem 0;
  border-radius: 4px;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ---- Post Navigation ---- */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  gap: 2rem;
}

.post-nav a {
  color: var(--text-muted);
  transition: color 0.2s;
}

.post-nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.post-nav-next {
  margin-left: auto;
  text-align: right;
}

/* ---- Footer ---- */
footer { border-top: 1px solid var(--border); }

footer p {
  max-width: var(--hub-width);
  margin: 0 auto;
  padding: 1.75rem 2rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  letter-spacing: 0.04em;
}

/* ---- Responsive ---- */
@media (max-width: 720px) {
  html { font-size: 17px; }

  nav { padding: 1.1rem 1.25rem; }
  .nav-right { gap: 1.25rem; }

  .home-hero {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    min-height: auto;
    padding: 3rem 1.25rem;
  }

  .hero-photo { order: -1; }

  .portrait {
    aspect-ratio: 4 / 3;
    object-position: center 20%;
  }

  .hero-text h1 { font-size: 3rem; }

  .hub-section {
    min-height: auto;
    padding: 3rem 1.25rem;
  }

  .content-card-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  /* On mobile show 2 columns for cards */
  @media (min-width: 480px) {
    .content-card-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  .hub-instagram { min-height: 40vh; }
  .insta-handle { font-size: 1.3rem; }

  .writing-inner,
  .writing-archive,
  .post {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .post-nav {
    flex-direction: column;
    gap: 0.75rem;
  }

  .post-nav-next {
    margin-left: 0;
    text-align: left;
  }
}
