/* Ken Corey — kencorey.com
   Design: Editorial Warmth — magazine-style personal site */

/* Fonts loaded via <link> in base.html for better LCP */

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

:root {
  --bg:         #f7f3ec;
  --surface:    #ffffff;
  --surface-alt:#f0ebe2;
  --border:     #ddd6cb;
  --text:       #2c2825;
  --text-light: #5c564e;
  --muted:      #7d776f;
  --accent:     #c4553d;
  --accent-h:   #a8432e;
  --accent-soft:#fdf0ed;
  --sage:       #5e8c61;
  --sage-soft:  #eef4ee;
  --max-w:      1100px;
  --max-w-text: 740px;
  --display:    'Fraunces', Georgia, serif;
  --body:       'Source Sans 3', system-ui, sans-serif;
  --radius:     8px;
  --shadow:     0 2px 12px rgba(44,40,37,0.08);
  --shadow-lg:  0 8px 32px rgba(44,40,37,0.12);
}

/* ── Reset & Base ── */
html {
  font-size: 17px;
  scroll-behavior: smooth;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-weight: 400;
  line-height: 1.75;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent-h); }
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus {
  top: 1rem;
}

/* ── Screen reader only ── */
.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;
}

/* ── Layout ── */
.wrapper { max-width: var(--max-w); margin: 0 auto; padding: 0 1.5rem; }
.wrapper--narrow { max-width: var(--max-w-text); }

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 64px;
}
.site-logo {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 32;
}
.site-logo:hover { color: var(--accent); }

/* Nav */
.site-nav { display: flex; flex-wrap: wrap; gap: 0.15rem; align-items: center; }
.site-nav a {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-decoration: none;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  transition: background 0.2s, color 0.2s;
}
.site-nav a:hover { background: var(--surface-alt); color: var(--text); }
.site-nav a[aria-current="true"] {
  background: var(--accent);
  color: #fff;
}

/* Nav dropdown */
.nav-item { position: relative; }
.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.35rem 0;
  z-index: 100;
}
.nav-dropdown a {
  display: block;
  border-radius: 0;
  padding: 0.45rem 1rem;
  white-space: nowrap;
}
.nav-item:hover .nav-dropdown,
.nav-item:focus-within .nav-dropdown { display: block; }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text);
}
.nav-toggle svg { width: 24px; height: 24px; }

/* Hamburger → X animation */
.nav-toggle line { transition: transform 0.2s, opacity 0.2s; transform-origin: center; }
.nav-toggle.is-open .nav-toggle__line1 { transform: translateY(6px) rotate(45deg); }
.nav-toggle.is-open .nav-toggle__line2 { opacity: 0; }
.nav-toggle.is-open .nav-toggle__line3 { transform: translateY(-6px) rotate(-45deg); }


/* ── Hero / Banner ── */
.hero-banner {
  position: relative;
  min-height: 45vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: url('/static/images/default-bg.jpg') no-repeat center center;
  background-size: cover;
  overflow: hidden;
}
.hero-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(44,40,37,0.3) 0%, rgba(44,40,37,0.55) 100%);
}
.hero-banner__content {
  position: relative;
  text-align: center;
  padding: 3rem 1.5rem;
  max-width: 700px;
}
.hero-banner__title {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  color: #ffffff;
  line-height: 1.15;
  text-shadow: 0 2px 16px rgba(0,0,0,0.25);
  font-variation-settings: 'opsz' 72;
  margin-bottom: 0.5rem;
}
.hero-banner__subtitle {
  font-family: var(--body);
  font-size: 1.1rem;
  color: rgba(255,255,255,0.9);
  font-weight: 400;
}
.hero-banner--small { min-height: 22vh; }
.hero-banner--small .hero-banner__title {
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
}

/* ── Homepage sections ── */
.home-intro {
  padding: 4rem 0 3rem;
}
.home-intro__text {
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text-light);
  max-width: var(--max-w-text);
}
.home-intro__text p { margin-bottom: 1rem; }
.home-intro__text a { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

/* Section headings */
.section-label {
  font-family: var(--display);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-variation-settings: 'opsz' 12;
}
.section-title {
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 1.5rem;
  font-variation-settings: 'opsz' 48;
}

/* Project cards grid */
.projects-section { padding: 3rem 0 4rem; }
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}
.project-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
}
.project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.project-card__icon {
  font-size: 2rem;
  margin-bottom: 1rem;
  display: block;
  width: 3rem;
  height: 3rem;
  line-height: 3rem;
  text-align: center;
  background: var(--accent-soft);
  border-radius: var(--radius);
}
.project-card--sage .project-card__icon { background: var(--sage-soft); }
.project-card__title {
  font-family: var(--display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
  font-variation-settings: 'opsz' 24;
}
.project-card__desc {
  font-size: 0.95rem;
  color: var(--text-light);
  line-height: 1.65;
  flex: 1;
}
.project-card__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
}
.project-card__link::after {
  content: '\2192';
  transition: transform 0.2s;
}
.project-card:hover .project-card__link::after {
  transform: translateX(3px);
}

/* ── Recent Posts on Home ── */
.recent-section { padding: 0 0 4rem; }
.post-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.post-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.post-card__body { padding: 1.5rem; }
.post-card__category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.post-card__title {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin: 0.4rem 0;
  font-variation-settings: 'opsz' 20;
}
.post-card__title a { color: inherit; text-decoration: none; }
.post-card__title a:hover { color: var(--accent); }
.post-card__meta {
  font-size: 0.8rem;
  color: var(--muted);
}
.post-card__summary {
  font-size: 0.9rem;
  color: var(--text-light);
  margin-top: 0.5rem;
  line-height: 1.6;
}

/* ── Blog listing (category pages) ── */
.blog-listing { padding: 3rem 0 4rem; }

.blog-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2.5rem;
  align-items: start;
}

/* Sidebar toggle (desktop: hidden) */
.blog-sidebar__toggle { display: none; }

/* Sidebar */
.blog-sidebar {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}
.blog-sidebar h2 {
  font-family: var(--display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 0.75rem;
  font-variation-settings: 'opsz' 12;
}
.blog-sidebar ol {
  list-style: decimal;
  padding-left: 1.25rem;
  margin: 0;
}
.blog-sidebar li {
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.4;
}
.blog-sidebar a {
  color: var(--text-light);
  text-decoration: none;
}
.blog-sidebar a:hover { color: var(--accent); }

/* Articles list */
.blog-articles { min-width: 0; }

.post-article {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 2.5rem;
  margin-bottom: 2rem;
  scroll-margin-top: 5rem;
}
.post-article__title {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.25;
  margin-bottom: 0.25rem;
  font-variation-settings: 'opsz' 36;
}
.post-article__title a { color: var(--text); }
.post-article__title a:hover { color: var(--accent); }
.post-article__meta {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

/* Truncated preview */
.post-article__preview {
  display: block;
  text-decoration: none;
  color: inherit;
}
.post-body--truncated {
  max-height: 12em;
  overflow: hidden;
  max-width: 100%;
  -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}
.post-body--truncated img { max-width: 100%; }
.post-article__fade { display: none; }

/* ── Single post ── */
.single-post { padding: 3rem 0 4rem; }
.single-post__meta {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* About page headshot */
.about-headshot {
  text-align: center;
  margin: 2rem 0 1.5rem;
}
.about-headshot__img {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface-alt);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Post body typography */
.post-body { font-size: 1.05rem; line-height: 1.85; }
.post-body p { margin-bottom: 1.2em; }
.post-body h2, .post-body h3 {
  font-family: var(--display);
  font-weight: 700;
  margin: 2em 0 0.6em;
  line-height: 1.3;
  font-variation-settings: 'opsz' 32;
}
.post-body h2 { font-size: 1.5rem; }
.post-body h3 { font-size: 1.2rem; }
.post-body img {
  border-radius: var(--radius);
  margin: 1.5em 0;
  box-shadow: var(--shadow);
  content-visibility: auto;
}
.post-body a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(196,85,61,0.3);
}
.post-body a:hover { text-decoration-color: var(--accent); }
.post-body blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.75em 1.25em;
  background: var(--accent-soft);
  color: var(--text-light);
  margin: 1.5em 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic;
}
.post-body ul, .post-body ol {
  margin: 1em 0;
  padding-left: 1.5em;
}
.post-body li { margin-bottom: 0.4em; }

/* Key takeaways callout box */
.key-takeaways {
  background: var(--surface-alt);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
}
.key-takeaways h2, .key-takeaways h3 {
  margin-top: 0;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  font-family: var(--body);
  font-weight: 700;
  margin-bottom: 0.75rem;
}
.key-takeaways ul {
  margin: 0;
  padding-left: 1.25em;
}
.key-takeaways li { margin-bottom: 0.35em; }

/* Stat callout — wrap a number/stat in <strong class="stat"> */
.post-body .stat {
  display: block;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  margin: 0.25em 0;
  font-variation-settings: 'opsz' 48;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.back-link::before { content: '\2190'; }
.back-link:hover { color: var(--accent-h); }

/* Breadcrumb */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text-light); }

/* Post author footer */
.post-author {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.post-author__photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid var(--surface-alt);
}
.post-author__name {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}
.post-author__name a { color: var(--accent); text-decoration: none; }
.post-author__name a:hover { text-decoration: underline; }
.post-author__bio {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.6;
}

/* Related posts */
.related-posts {
  margin-top: 2.5rem;
  padding: 1.5rem 1.75rem;
  background: var(--surface-alt);
  border-radius: var(--radius);
}
.related-posts h3 {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  font-variation-settings: 'opsz' 20;
}
.related-posts ul {
  list-style: none;
  padding: 0;
}
.related-posts li {
  padding: 0.35rem 0;
}
.related-posts a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}
.related-posts a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Footer ── */
.site-footer {
  background: var(--text);
  color: rgba(255,255,255,0.7);
  padding: 3rem 0;
  margin-top: 2rem;
}
.site-footer .wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.site-footer__copy {
  font-size: 0.85rem;
}
.site-footer__links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}
.site-footer__links a {
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
  text-decoration: none;
  transition: color 0.2s;
}
.site-footer__links a:hover { color: #fff; }

/* ── Responsive ── */
@media (max-width: 768px) {
  html { font-size: 16px; }

  .nav-toggle { display: block; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
  }
  .site-nav.is-open { display: flex; }
  .site-nav > a,
  .site-nav > .nav-item > a {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.65rem 0;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    background: none;
  }
  .site-nav > a:last-child { border-bottom: none; }

  /* Dropdown always visible on mobile, indented */
  .nav-item { width: 100%; }
  .nav-dropdown {
    display: flex;
    flex-direction: column;
    position: static;
    border: none;
    border-left: 2px solid var(--accent-soft);
    box-shadow: none;
    padding: 0 0 0 1rem;
    min-width: 0;
    margin-bottom: 0.5rem;
  }
  .nav-dropdown a {
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-light);
  }
  .nav-dropdown a:last-child { border-bottom: none; }

  .hero-banner { min-height: 35vh; }
  .hero-banner--small { min-height: 18vh; }

  .projects-grid { grid-template-columns: 1fr; }
  .post-cards { grid-template-columns: 1fr; }
  .post-article { padding: 1.5rem; }

  /* Fix iOS tap-nav issue: override hover/focus-within rules on mobile */
  .nav-item:hover .nav-dropdown,
  .nav-item:focus-within .nav-dropdown { display: flex; }

  .blog-listing { padding-top: 1rem; }

  /* Blog layout: single column with popup sidebar */
  .blog-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .blog-sidebar {
    position: sticky;
    top: 4.25rem;
    z-index: 10;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
  }
  .blog-sidebar h2 { display: none; }
  .blog-sidebar__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 1rem;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    cursor: pointer;
    box-shadow: var(--shadow);
  }
  .blog-sidebar__chevron { font-size: 0.75rem; }
  .blog-sidebar ol {
    display: none;
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 20;
    list-style: decimal;
    padding: 0.5rem 0 0.5rem 2.5rem;
    margin: 0;
  }
  .blog-sidebar.is-open ol { display: block; }
  .blog-sidebar li { margin-bottom: 0; }
  .blog-sidebar a {
    white-space: normal;
    padding: 0.5rem 1rem 0.5rem 0;
    background: none;
    border-radius: 0;
    font-size: 0.9rem;
    display: block;
    border-bottom: 1px solid var(--border);
  }
  .blog-sidebar li:last-child a { border-bottom: none; }

  .site-footer .wrapper { flex-direction: column; text-align: center; }
  .site-footer__links { justify-content: center; }
}

@media (max-width: 480px) {
  .wrapper { padding: 0 1rem; }
  .hero-banner__title { font-size: 1.6rem; }
  .section-title { font-size: 1.4rem; }
}

/* ── Print ── */
@media print {
  .site-header, .site-footer, .hero-banner, .nav-toggle { display: none; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .wrapper { max-width: 100%; padding: 0; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
