/*
 * Potemkin page archetypes
 * Five shells share a common header, spacing and terminal rhythm while
 * allowing each surface to retain its own imagery and interaction model.
 */

body[data-page-archetype],
body[data-surface="home"] {
  --page-gutter: clamp(18px, 4.2vw, 72px);
  --page-header-height: clamp(66px, 7vw, 84px);
  --page-section-gap: clamp(72px, 10vw, 152px);
  --page-terminal-gap: clamp(88px, 12vw, 176px);
  --page-reading-measure: 72ch;
  --page-index-width: 1320px;
  --page-viewer-width: 1560px;
  --page-info-width: 1040px;
  --page-shell-line: rgba(199, 154, 69, 0.18);
  --page-shell-cold: rgba(111, 234, 255, 0.12);
}

body[data-page-archetype="index"] {
  /* `clip` avoids the horizontal writing-stage bleed without creating the
     scroll container that would disable sticky chapter positioning. */
  overflow-x: clip !important;
}

body[data-page-archetype] > .site-header,
body[data-surface="home"] > .site-header {
  min-height: var(--page-header-height);
  border-bottom: 1px solid var(--page-shell-line);
  background: linear-gradient(180deg, rgba(2, 2, 2, 0.94), rgba(2, 2, 2, 0.72));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px) saturate(112%);
}

body[data-page-archetype] > .site-header .brand,
body[data-page-archetype] > .site-header .primary-nav,
body[data-surface="home"] > .site-header .brand,
body[data-surface="home"] > .site-header .primary-nav {
  min-height: 44px;
  align-items: center;
}

body[data-page-archetype] > main.page-shell,
body[data-surface="home"] > main {
  position: relative;
  isolation: isolate;
  min-height: calc(100svh - var(--page-header-height));
  padding-bottom: var(--page-terminal-gap);
}

body[data-page-archetype] > main.page-shell :where(section, article, nav)[id],
body[data-surface="home"] > main :where(section, article, nav)[id] {
  scroll-margin-top: calc(var(--page-header-height) + 28px);
}

body[data-page-archetype] > .site-footer,
body[data-surface="home"] > .site-footer {
  min-height: 88px;
  margin-top: 0;
  border-top: 1px solid var(--page-shell-line);
  background: linear-gradient(0deg, rgba(199, 154, 69, 0.025), transparent 76%);
}

body[data-page-archetype] :where(.eyebrow, .story-label, .chapter-number),
body[data-surface="home"] :where(.eyebrow, .story-label, .chapter-number) {
  text-wrap: balance;
}

body[data-page-archetype] :where(h1, h2),
body[data-surface="home"] :where(h1, h2) {
  text-wrap: balance;
}

/* Landing: one dominant invitation followed by large, discrete portals. */
body[data-page-archetype="landing"],
body[data-surface="home"] {
  --page-section-gap: clamp(96px, 14vw, 210px);
}

.page-shell--landing > :where(.hero, .tap-sequence),
body[data-surface="home"] > main > .hero {
  min-height: calc(100svh - var(--page-header-height));
}

/* Index: a clear introduction followed by repeated catalogue systems. */
.page-shell--index {
  --page-index-inset: max(var(--page-gutter), calc((100vw - var(--page-index-width)) / 2));
}

.page-shell--index :where(.section-heading, .writing-index-header, .writing-drafts-header, .article-header) {
  max-width: var(--page-reading-measure);
}

/* Article: long-form reading with a dependable cover/body/end sequence. */
.page-shell--article {
  --page-reading-measure: 68ch;
}

.page-shell--article :where(.editorial-cover-deck, .chapter-copy, .article-copy) {
  max-width: var(--page-reading-measure);
}

.page-shell--article :where(.editorial-cover, .editorial-story-shell, .editorial-end) {
  position: relative;
}

/* Artwork viewer: maximum visual field with a stable information rail. */
.page-shell--viewer {
  width: min(100%, var(--page-viewer-width));
  margin-inline: auto;
}

.page-shell--viewer :where(.artwork-information, .artwork-navigation) {
  border-color: var(--page-shell-line);
}

/* Information: compact explanatory surfaces and utility destinations. */
.page-shell--information:not(.tolis-page) {
  width: min(100%, var(--page-info-width));
  margin-inline: auto;
}

body[data-page-archetype="information"] > main.page-shell:not(.tolis-page) {
  display: grid;
  align-content: center;
  padding-inline: var(--page-gutter);
  padding-top: clamp(64px, 9vw, 124px);
}

body[data-page-archetype="information"] :where(.private-card, .missing-card) {
  width: 100%;
  margin-inline: auto;
}

@media (max-width: 760px) {
  body[data-page-archetype],
  body[data-surface="home"] {
    --page-gutter: clamp(16px, 5vw, 24px);
    --page-header-height: 64px;
    --page-section-gap: clamp(64px, 20vw, 104px);
    --page-terminal-gap: clamp(76px, 22vw, 116px);
    --page-mobile-particle-opacity: 0.76;
  }

  body[data-page-archetype] .shell,
  body[data-surface="home"] .shell {
    width: min(var(--max), calc(100% - (var(--page-gutter) * 2)));
  }

  body[data-page-archetype] :where(h1, h2),
  body[data-surface="home"] :where(h1, h2) {
    line-height: 0.98;
    letter-spacing: -0.025em;
  }

  body[data-page-archetype] > .site-header,
  body[data-surface="home"] > .site-header {
    backdrop-filter: blur(12px);
  }

  body[data-page-archetype] > .site-footer,
  body[data-surface="home"] > .site-footer {
    min-height: 104px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-page-archetype] > .site-header,
  body[data-surface="home"] > .site-header {
    backdrop-filter: none;
  }
}
