/* A Billion Years of Continents — scrollytelling globe of continental drift. */

.pg { color: var(--ink); }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.pg-hero {
  max-width: 780px;
  margin: 0 auto;
  padding: 60px 24px 30px;
  text-align: center;
}
.pg-kicker {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent, #e8634a);
  margin-bottom: 16px;
}
.pg-kicker::before,
.pg-kicker::after {
  content: "";
  width: 24px;
  height: 1px;
  background: color-mix(in srgb, var(--accent, #e8634a) 55%, transparent);
}
.pg-hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.1rem, 5.2vw, 3.3rem);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.04;
}
.pg-hero p {
  margin: 0 auto;
  max-width: 60ch;
  color: var(--ink-soft);
  font-size: 1.08rem;
  line-height: 1.62;
}
.pg-hero::after {
  content: "";
  display: block;
  width: 46px;
  height: 3px;
  margin: 26px auto 0;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent, #e8634a) 80%, transparent);
}

/* ── Scrollytelling: sticky globe + scrolling steps ───────────────────────── */
.pg-scrolly {
  max-width: 1400px;
  margin: 12px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1.2fr 0.85fr;
  gap: 34px;
  align-items: start;
}

.pg-stage {
  position: sticky;
  top: calc(var(--nav-h, 64px) + 10px);
  height: calc(100vh - var(--nav-h, 64px) - 20px);
  min-height: 460px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pg-globe {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 30% 20%, color-mix(in srgb, var(--bg-warm) 55%, var(--paper)), var(--paper) 70%);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pg-globe canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.pg-globe canvas:active { cursor: grabbing; }

/* Era caption overlaid on the globe */
.pg-caption {
  position: absolute;
  left: 16px;
  bottom: 14px;
  max-width: calc(100% - 32px);
  padding: 9px 16px 11px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--paper) 64%, transparent);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  border: 1px solid color-mix(in srgb, var(--ink) 9%, transparent);
  box-shadow: 0 8px 22px -14px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.pg-era {
  display: block;
  font-size: clamp(1.4rem, 2.4vw, 1.85rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.04;
  color: var(--ink);
}
.pg-age {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent, #e8634a);
}
.pg-age::before {
  content: "";
  width: 20px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent, #e8634a);
}

/* ── Controls ─────────────────────────────────────────────────────────────── */
.pg-controls {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "play slider" "eras eras";
  align-items: center;
  gap: 10px 12px;
  -webkit-user-select: none;
  user-select: none;
}
.pg-play {
  grid-area: play;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: var(--accent, #e8634a);
  color: #fff;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}
.pg-play:hover { filter: brightness(1.05); }
.pg-slider-wrap { grid-area: slider; display: flex; flex-direction: column; gap: 3px; }
.pg-slider {
  width: 100%;
  height: 34px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.pg-slider::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent, #e8634a), color-mix(in srgb, var(--accent, #e8634a) 30%, var(--rule)));
}
.pg-slider::-moz-range-track {
  height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent, #e8634a), color-mix(in srgb, var(--accent, #e8634a) 30%, var(--rule)));
}
.pg-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 30px; height: 30px; margin-top: -11px; border-radius: 50%; box-sizing: border-box;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e8634a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='3' y1='12' x2='21' y2='12'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3C/svg%3E") center / 18px no-repeat;
  border: 2px solid var(--accent, #e8634a); box-shadow: 0 2px 6px rgba(0,0,0,0.28);
  transition: transform 0.12s;
}
.pg-slider::-webkit-slider-thumb:hover { transform: scale(1.08); }
.pg-slider::-moz-range-thumb {
  width: 30px; height: 30px; border-radius: 50%; box-sizing: border-box;
  background: var(--paper) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e8634a' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='3' y1='12' x2='21' y2='12'/%3E%3Cellipse cx='12' cy='12' rx='4' ry='9'/%3E%3C/svg%3E") center / 18px no-repeat;
  border: 2px solid var(--accent, #e8634a); box-shadow: 0 2px 6px rgba(0,0,0,0.28);
}
.pg-scale {
  display: flex; justify-content: space-between;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint);
}
.pg-view {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: inline-flex;
  padding: 4px;
  gap: 3px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  -webkit-user-select: none;
  user-select: none;
}
.pg-view button {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  min-width: 42px;
  padding: 6px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.pg-view button:hover { color: var(--ink); }
.pg-view button.is-active {
  background: var(--accent, #e8634a);
  color: #fff;
  box-shadow: 0 1px 4px color-mix(in srgb, var(--accent, #e8634a) 45%, transparent);
}
.pg-eras { grid-area: eras; display: flex; flex-wrap: wrap; gap: 6px; }
.pg-era-chip {
  border: 1px solid var(--rule); border-radius: 999px;
  padding: 5px 11px; background: var(--paper); color: var(--ink-soft);
  font: inherit; font-size: 0.76rem; font-weight: 700; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.pg-era-chip:hover { color: var(--ink); border-color: var(--ink-faint); }
.pg-era-chip.is-active { color: #fff; background: var(--accent, #e8634a); border-color: var(--accent, #e8634a); }

/* ── Scrolling narrative steps ────────────────────────────────────────────── */
.pg-steps { display: flex; flex-direction: column; counter-reset: pgstep; }
.pg-step {
  min-height: 76vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 0;
  counter-increment: pgstep;
}
.pg-step-card {
  position: relative;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--rule);
  border-radius: 16px;
  padding: 22px 26px 24px;
  background: color-mix(in srgb, var(--bg-warm) 24%, var(--paper));
  box-shadow: 0 8px 30px -22px rgba(0,0,0,0.5);
  transition: border-color 0.3s, transform 0.3s, box-shadow 0.3s;
}
.pg-step-card::before {
  content: counter(pgstep, decimal-leading-zero);
  position: absolute;
  top: 20px;
  right: 22px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  transition: color 0.3s;
}
.pg-step.is-active .pg-step-card {
  border-color: var(--accent, #e8634a);
  box-shadow: 0 14px 40px -22px color-mix(in srgb, var(--accent, #e8634a) 60%, transparent);
}
.pg-step.is-active .pg-step-card::before { color: var(--accent, #e8634a); }
.pg-step-age {
  display: block;
  padding-right: 34px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--accent, #e8634a);
}
.pg-step-card h2 { margin: 9px 0 10px; font-size: clamp(1.35rem, 2.2vw, 1.6rem); font-weight: 800; letter-spacing: -0.01em; line-height: 1.16; }
.pg-step-card p { margin: 0; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.65; }

/* ── About / data ─────────────────────────────────────────────────────────── */
.pg-about {
  max-width: 900px;
  margin: 48px auto 0;
  padding: 34px 24px 8px;
  border-top: 1px solid var(--rule);
}
.pg-about h2 {
  position: relative;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  padding-bottom: 13px;
}
.pg-about h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 42px;
  height: 3px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent, #e8634a) 80%, transparent);
}
.pg-qa { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; }
.pg-qa-item { border: 1px solid var(--rule); border-radius: 12px; padding: 16px 18px; background: color-mix(in srgb, var(--bg-warm) 26%, var(--paper)); }
.pg-qa-item h3 { margin: 0 0 7px; font-size: 0.98rem; font-weight: 800; color: var(--ink); }
.pg-qa-item p { margin: 0; font-size: 0.9rem; line-height: 1.6; color: var(--ink-soft); }
.pg-attrib {
  margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--rule);
  font-size: 0.78rem; color: var(--ink-faint); line-height: 1.5;
}
.pg-attrib a { color: var(--ink-soft); }

/* ── Mobile "read about this era" button + bottom sheet (hidden on desktop) ── */
.pg-readmore { display: none; }
body.pg-noscroll { overflow: hidden; }

.pg-sheet[hidden] { display: none; }
.pg-sheet {
  position: fixed;
  inset: 0;
  /* Pin to the dynamic viewport so the bottom sheet isn't pushed behind the
     mobile browser's address bar (plain vh maps to the taller layout viewport). */
  height: 100vh;
  height: 100dvh;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.pg-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 30, 0.5);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: pgFade 0.25s ease;
}
@keyframes pgFade { from { opacity: 0; } to { opacity: 1; } }
.pg-sheet-panel {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 82vh;
  max-height: 85dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -12px 40px -18px rgba(0, 0, 0, 0.5);
  animation: pgSheetUp 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes pgSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.pg-sheet-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg-warm) 40%, var(--paper));
  color: var(--ink-soft);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.pg-sheet-body .pg-step-age { padding-right: 44px; }
.pg-sheet-body h2 { margin: 10px 0 12px; font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em; line-height: 1.18; }
.pg-sheet-body p { margin: 0; color: var(--ink-soft); font-size: 1.04rem; line-height: 1.7; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .pg-scrolly { grid-template-columns: 1fr; gap: 0; }
  .pg-stage {
    position: static;
    top: auto;
    height: auto;
    background: var(--paper);
    padding: 8px 0 14px;
    z-index: 5;
  }
  .pg-globe { height: 52vh; min-height: 300px; flex: 0 0 auto; }
  /* On mobile the narrative text is not shown on the background — the reader
     taps "Read about this era" to open it in a sheet instead. */
  .pg-steps { display: none; }
  .pg-readmore {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    padding: 12px 16px;
    border: 1px solid var(--rule);
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-warm) 26%, var(--paper));
    color: var(--ink);
    font: inherit;
    font-size: 0.92rem;
    font-weight: 800;
    cursor: pointer;
  }
  .pg-readmore svg { width: 18px; height: 18px; color: var(--accent, #e8634a); }
}

@media (max-width: 520px) {
  .pg-controls {
    grid-template-columns: auto 1fr;
    grid-template-areas: "play slider" "eras eras";
  }
}

@media (max-width: 640px) {
  body.has-bottom-nav .pg-sheet {
    bottom: calc(60px + env(safe-area-inset-bottom, 0px));
    height: auto;
  }
  body.has-bottom-nav .pg-sheet-panel {
    max-height: calc(100dvh - 60px - env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pg-step-card { transition: none; }
}
