/* ============================================================
   HOMEPAGE.CSS — index.html specific styles
   ============================================================ */

/* -------- Hero -------- */
.hero {
  position: relative;
  overflow: hidden;
  padding-top: clamp(48px, 6vw, 96px);
  padding-bottom: clamp(48px, 6vw, 96px);
}

.hero .topo {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(ellipse 80% 60% at 70% 40%, transparent 40%, var(--bg) 72%),
    radial-gradient(ellipse 60% 80% at 25% 55%, color-mix(in oklab, var(--accent) 8%, transparent), transparent 65%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='1200' height='900' viewBox='0 0 1200 900'><g fill='none' stroke='%238CA3AF' stroke-opacity='0.35' stroke-width='0.8'><path d='M -20 700 Q 200 560 420 600 T 860 560 T 1240 500'/><path d='M -20 640 Q 220 520 430 540 T 860 500 T 1240 450'/><path d='M -20 580 Q 200 480 440 480 T 860 440 T 1240 400'/><path d='M -20 520 Q 240 440 440 420 T 860 380 T 1240 350'/><path d='M -20 460 Q 220 400 450 360 T 860 320 T 1240 300'/><path d='M -20 400 Q 260 360 460 300 T 860 260 T 1240 250'/><path d='M -20 340 Q 240 320 470 240 T 860 200 T 1240 200'/><path d='M -20 280 Q 280 260 480 180 T 860 140 T 1240 150'/><path d='M -20 220 Q 260 200 490 120 T 860 80 T 1240 100'/></g></svg>");
  background-size: cover;
  background-position: center;
  animation: topoDrift 90s linear infinite;
}

@keyframes topoDrift {
  0%   { background-position: center 0%, 25% 55%, center; }
  50%  { background-position: center 2%, 22% 52%, center; }
  100% { background-position: center 0%, 25% 55%, center; }
}

[data-theme="dark"] .hero .topo { opacity: 0.18; }

@media (prefers-reduced-motion: reduce) {
  .hero .topo { animation: none; }
}

/* Hero two-column layout */
.hero-inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
}

.hero-text {
  position: relative;
  z-index: 1;
}

/* Photo placeholder — replace with <img> when ready */
.hero-photo {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.hero-photo img {
  width: clamp(200px, 22vw, 340px);
  height: auto;
  aspect-ratio: 5 / 6;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

.hero-photo-placeholder {
  width: clamp(200px, 22vw, 340px);
  aspect-ratio: 5 / 6;
  border: 2px dashed var(--rule);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-3);
  background: var(--surface);
}

.hero-photo-placeholder svg {
  width: 56px;
  height: 56px;
  opacity: 0.5;
}

.hero-photo-placeholder span {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
}

@media (max-width: 768px) {
  .hero-inner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .hero-photo {
    display: flex;
    justify-content: center;
  }
  .hero-photo img {
    width: clamp(180px, 50vw, 280px);
  }
  .route-card {
    margin-left: auto;
    margin-right: auto;
  }
}

/* Kicker pill */
.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: color-mix(in oklab, var(--bg) 85%, var(--accent) 2%);
  position: relative;
  z-index: 1;
}

.hero-kicker .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

/* Hero headline */
.hero h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(32px, 5vw, 72px);
  line-height: 0.96;
  margin: 24px 0 20px;
  letter-spacing: -0.025em;
  max-width: 14ch;
  position: relative;
  z-index: 1;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero .sub {
  max-width: 56ch;
  font-size: clamp(15px, 1.4vw, 18px);
  color: var(--ink-2);
  margin: 0 0 36px;
  position: relative;
  z-index: 1;
}

/* Route card */
.route-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 720px;
  font-family: var(--font-mono);
  position: relative;
  z-index: 1;
}

.route-card .cell {
  padding: 16px 18px;
  border-right: 1px solid var(--rule);
}

.route-card .cell:last-child { border-right: none; }

.route-card .k {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin-bottom: 5px;
}

.route-card .v {
  font-size: 14px;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.route-card .v b { color: var(--accent); font-weight: 500; }

@media (max-width: 600px) {
  .route-card { grid-template-columns: repeat(2, 1fr); }
  .route-card .cell:nth-child(2) { border-right: none; }
  .route-card .cell:nth-child(1),
  .route-card .cell:nth-child(2) { border-bottom: 1px solid var(--rule); }
}

/* -------- About -------- */
#about { background: var(--surface); }

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: clamp(28px, 4vw, 64px);
  align-items: start;
}

@media (max-width: 840px) {
  .about-grid { grid-template-columns: 1fr; }
}

.about-grid .lede p {
  font-size: clamp(17px, 1.6vw, 21px);
  line-height: 1.55;
  color: var(--ink);
  margin: 0 0 18px;
  font-weight: 400;
}

.about-grid .lede p + p {
  font-size: 15px;
  color: var(--ink-2);
  line-height: 1.7;
}

.stack-card {
  border: 1px solid var(--rule);
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
}

.stack-card h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  text-transform: uppercase;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
}

.stack-card h3::before {
  content: '';
  width: 16px;
  height: 1px;
  background: var(--ink-3);
  flex-shrink: 0;
}

.stack-card h3 + h3 { margin-top: 22px; }

/* -------- Outside / Chapters -------- */
.chapters {
  display: grid;
  gap: 2px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.chapter {
  display: grid;
  grid-template-columns: 200px 1fr 260px;
  gap: 28px;
  padding: 32px clamp(20px, 3vw, 36px);
  background: var(--bg);
  align-items: start;
  border-left: 2px solid transparent;
  transition: border-color 0.2s;
}

.chapter:hover {
  border-left-color: var(--accent);
}

@media (max-width: 960px) {
  .chapter { grid-template-columns: 1fr; gap: 14px; }
}

.chapter .idx {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.chapter .idx .n {
  display: block;
  font-size: 34px;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-top: 4px;
  font-family: var(--font-display);
}

.chapter h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(20px, 2.2vw, 28px);
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.chapter p { margin: 0 0 12px; color: var(--ink-2); max-width: 58ch; }

.route-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  background: var(--rule);
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  align-self: start;
}

.route-meta .m {
  background: var(--bg);
  padding: 11px 13px;
  border: 1px solid transparent;
  transition: border-color 0.15s, background-color 0.15s;
}

.route-meta .m:hover {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 5%, var(--bg));
}

.route-meta .k {
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.route-meta .v {
  font-size: 13px;
  color: var(--ink);
}

.route-meta .m {
  transition: border-color 0.15s;
}

.route-meta .m:hover {
  border-color: var(--accent);
}

.route-meta .v b { color: var(--accent); font-weight: 500; }

/* Elevation SVG line */
.elev {
  grid-column: 1 / -1;
  height: 52px;
  width: 100%;
  margin-top: 4px;
}

/* -------- Photography -------- */
#photo { background: var(--surface); }

.photo-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.photo-head .lead { max-width: 56ch; color: var(--ink-2); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 110px;
  gap: 6px;
}

.photo-grid .ph {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--slate-mid), var(--deep-slate));
  border: 1px solid var(--rule);
  transition: transform 0.3s ease;
  cursor: pointer;
}

.photo-grid .ph img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.photo-grid .ph:hover img { transform: scale(1.04); }
.photo-grid .ph:hover { z-index: 1; }

/* Varied spans */
.photo-grid .ph:nth-child(1) { grid-column: span 3; grid-row: span 3; }
.photo-grid .ph:nth-child(2) { grid-column: span 3; grid-row: span 2; }
.photo-grid .ph:nth-child(3) { grid-column: span 2; grid-row: span 2; }
.photo-grid .ph:nth-child(4) { grid-column: span 1; grid-row: span 1; }
.photo-grid .ph:nth-child(5) { grid-column: span 2; grid-row: span 2; }
.photo-grid .ph:nth-child(6) { grid-column: span 2; grid-row: span 1; }
.photo-grid .ph:nth-child(7) { grid-column: span 2; grid-row: span 2; }
.photo-grid .ph:nth-child(8) { grid-column: span 2; grid-row: span 2; }
.photo-grid .ph:nth-child(9) { grid-column: span 2; grid-row: span 2; }
.photo-grid .ph:nth-child(10) { grid-column: span 2; grid-row: span 2; }
.photo-grid .ph:nth-child(11) { grid-column: span 2; grid-row: span 2; }
.photo-grid .ph:nth-child(12) { grid-column: span 2; grid-row: span 2; }

@media (max-width: 840px) {
  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 130px;
  }
  .photo-grid .ph { grid-column: span 1 !important; grid-row: span 1 !important; }
  .photo-grid .ph:nth-child(1),
  .photo-grid .ph:nth-child(2) { grid-column: span 2 !important; grid-row: span 2 !important; }
}

/* -------- Lightbox modal -------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.9);
  align-items: center;
  justify-content: center;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--warm-white);
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
  opacity: 0.8;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.4);
  border: none;
  color: var(--warm-white);
  font-size: 24px;
  cursor: pointer;
  padding: 16px 12px;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 10;
}
.lightbox-nav:hover { opacity: 1; }
.lightbox-prev { left: 16px; }
.lightbox-next { right: 16px; }

/* -------- Scroll-to-top -------- */
.scroll-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
  pointer-events: none;
}
.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.scroll-top:hover { background: var(--accent-2); }
.scroll-top:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

@media (max-width: 600px) {
  .scroll-top { bottom: 20px; right: 20px; width: 40px; height: 40px; }
}

/* -------- Photo grid loading & focus -------- */
.photo-grid .ph {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--slate-mid), var(--deep-slate));
  border: 1px solid var(--rule);
  transition: transform 0.3s ease;
  cursor: pointer;
}
@media (prefers-reduced-motion: reduce) {
  .photo-grid .ph { transition: none; }
}

.photo-grid .ph img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
  opacity: 0;
}
.photo-grid .ph img.loaded { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .photo-grid .ph img { transition: none; }
}

.photo-grid .ph:hover img { transform: scale(1.04); }
.photo-grid .ph:hover { z-index: 1; }

.photo-grid .ph:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  z-index: 1;
}

.photo-grid .ph::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--accent);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  border-radius: var(--radius);
}

.photo-grid .ph:hover::after {
  opacity: 0.4;
}

/* -------- Homepage print -------- */
@media print {
  .hero .topo { opacity: 0.12 !important; }
  .hero h1 { font-size: 32pt !important; }
  .route-card .cell { padding: 8px 12px !important; }
  section { padding: 24px 0 !important; }
  .photo-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    grid-auto-rows: 100px !important;
    gap: 8px !important;
  }
  .photo-grid .ph { grid-column: span 1 !important; grid-row: span 1 !important; }
  .lightbox, .scroll-top, .photo-grid .ph:hover { display: none !important; }
}
