/* ==========================================================================
   Page hero. One full-screen opener shared by every page except home.
   Same markup, two directions under review:
     A (default)            Cover sheet: a paper sheet on the ink desk, two
                            sheets fanned behind it from the bottom-right
                            corner, the way the mark fans.
     html[data-hero="b"]    Title page: the whole screen is the paper, set
                            centred like the title page of a filed document.
   --p is scroll progress through the hero (0 to 1), written by phero.js.
   ========================================================================== */

.phero {
  --p: 0;
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(5.25rem, 9vw, 6.25rem) clamp(0.9rem, 3vw, 2.5rem) clamp(1.25rem, 3vw, 2.25rem);
  background: var(--ink);
  overflow: clip;
}

/* ------------------------------------------------------------------ A: sheet */

.phero__stack {
  position: relative;
  width: min(1180px, 100%);
  min-height: calc(100svh - clamp(6.75rem, 12vw, 8.5rem));
  display: grid;
}

.phero__back,
.phero__sheet {
  grid-area: 1 / 1;
  border-radius: 6px;
}

/* The two sheets behind. They hinge on the bottom-right corner like the mark,
   settle in on load, and open a few degrees further as you scroll away. */
.phero__back {
  transform-origin: 96% 100%;
  transition: transform 1.3s var(--ease);
}

.phero__back--1 {
  background: #E4E0D8;
  transform: rotate(calc(-2.2deg - var(--p) * 2deg));
}

.phero__back--2 {
  background: #CFCAC1;
  transform: rotate(calc(-4.6deg - var(--p) * 3.5deg));
}

.js .phero:not(.is-in) .phero__back { transform: rotate(0deg); }

.phero__sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper-sheet);
  color: var(--ink);
  padding: clamp(1.4rem, 3.2vw, 2.6rem) clamp(1.25rem, 4vw, 3.5rem)
           clamp(1.1rem, 2.4vw, 1.9rem) clamp(3rem, 6.5vw, 5.5rem);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25), 0 40px 80px -30px rgba(0, 0, 0, 0.7);
  transform: translateY(calc(var(--p) * -4%));
  transition: transform 0.9s var(--ease), opacity 0.9s var(--ease);
}

.js .phero:not(.is-in) .phero__sheet { transform: translateY(34px); opacity: 0; }

/* Binding holes and the rule beside them, straight off the mark. */
.phero__sheet::before {
  content: "";
  position: absolute;
  left: clamp(0.95rem, 2vw, 1.6rem);
  top: clamp(1.4rem, 3vw, 2.4rem);
  bottom: clamp(1.4rem, 3vw, 2.4rem);
  width: 12px;
  background-image: radial-gradient(circle 6px at 6px 12px, var(--ink) 98%, transparent 100%);
  background-size: 12px 36px;
  background-repeat: repeat-y;
  opacity: 0.9;
}

.phero__sheet::after {
  content: "";
  position: absolute;
  left: clamp(2.2rem, 4.5vw, 3.6rem);
  top: clamp(1.1rem, 2.6vw, 2rem);
  bottom: clamp(1.1rem, 2.6vw, 2rem);
  width: 1px;
  background: var(--paper-rule);
}

.phero__head,
.phero__foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper-soft);
}

.phero__head { padding-bottom: 0.8rem; border-bottom: 1px solid var(--paper-rule); }
.phero__foot { padding-top: 0.9rem; border-top: 1px solid var(--paper-rule); align-items: center; }
.phero__file { color: var(--red); }

.phero__body {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: clamp(2rem, 6vh, 4.5rem);
}

.phero__mark {
  position: absolute;
  right: -2%;
  top: 50%;
  width: min(40%, 460px);
  transform: translateY(-50%) rotate(-4deg);
  opacity: 0.06;
  pointer-events: none;
}

.phero h1 {
  font-size: clamp(2.6rem, 7.6vw, 6rem);
  line-height: 1.02;
  letter-spacing: -0.028em;
  margin: 0 0 clamp(1.1rem, 2.5vw, 1.75rem);
  max-width: 14ch;
}

.phero__sub {
  font-size: var(--f-lead);
  line-height: 1.5;
  color: var(--paper-soft);
  max-width: 44ch;
  margin: 0 0 clamp(1.75rem, 3.5vw, 2.5rem);
}

.phero__rule { display: none; }

.phero .btn-row { position: relative; }

/* Scroll cue: a short line that keeps drawing downward. */
.phero__cue { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; }
.phero__cue i {
  position: relative;
  width: 1px;
  height: 22px;
  background: var(--paper-rule);
  overflow: hidden;
}
.phero__cue i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--red);
  animation: phero-cue 1.8s var(--ease) infinite;
}
@keyframes phero-cue {
  0% { transform: translateY(-100%); }
  60%, 100% { transform: translateY(100%); }
}

@media (max-width: 640px) {
  .phero__stack { min-height: calc(100svh - 6.5rem); }
  .phero__mark { width: 70%; right: -22%; opacity: 0.05; }
  .phero__foot > span:first-child { display: none; }
  .phero__foot { justify-content: flex-end; }
  .phero__back--1 { transform: rotate(calc(-1.4deg - var(--p) * 1.5deg)); }
  .phero__back--2 { transform: rotate(calc(-2.8deg - var(--p) * 2.5deg)); }
}

/* ---------------------------------------------------------- B: title page */

html[data-hero="b"] .phero {
  background: var(--paper);
  padding-inline: clamp(1.25rem, 5vw, 4rem);
}

html[data-hero="b"] .phero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
}

html[data-hero="b"] .phero__back { display: none; }

html[data-hero="b"] .phero__stack { width: min(1100px, 100%); }

html[data-hero="b"] .phero__sheet {
  background: transparent;
  box-shadow: none;
  padding: 0;
  text-align: center;
}

html[data-hero="b"] .phero__sheet::before,
html[data-hero="b"] .phero__sheet::after { display: none; }

/* A document title page: double rule over the caption line. */
html[data-hero="b"] .phero__head {
  border-bottom: 0;
  border-top: 3px double var(--ink);
  padding: 0.9rem 0 0;
}

html[data-hero="b"] .phero__foot { border-top-color: var(--ink); }

html[data-hero="b"] .phero__body { align-items: center; }

html[data-hero="b"] .phero__mark {
  right: 50%;
  width: min(62vh, 560px);
  transform: translate(50%, -50%) rotate(calc(-6deg + var(--p) * 10deg));
  opacity: 0.055;
  transition: transform 0.9s var(--ease);
}

html[data-hero="b"] .phero h1 { max-width: 16ch; margin-inline: auto; }
html[data-hero="b"] .phero__sub { margin-inline: auto; }

html[data-hero="b"] .phero__rule {
  display: block;
  width: 72px;
  height: 2px;
  background: var(--red);
  margin: 0 auto clamp(1.75rem, 3.5vw, 2.5rem);
  transform-origin: center;
  transition: transform 1s var(--ease) 0.5s;
}

html.js[data-hero="b"] .phero:not(.is-in) .phero__rule { transform: scaleX(0); }

html[data-hero="b"] .phero .btn-row { justify-content: center; }

@media (max-width: 640px) {
  html[data-hero="b"] .phero__mark { width: 92vw; }
}

/* Phones: the whole sheet has to fit one screen with the browser bars showing. */
@media (max-width: 640px) {
  .phero h1 { font-size: clamp(2.05rem, 10.2vw, 2.55rem); max-width: none; }
  .phero__sub { font-size: 1rem; line-height: 1.5; margin-bottom: 1.4rem; }
  .phero__body { padding-block: 1.1rem; }
  .phero .btn-row { gap: 0.6rem; }
  .phero .btn { min-height: 2.9rem; }
}


/* ------------------------------------------------------ moving background */
/* Built by phero.js. Transforms and opacity only, no blur, so it stays on
   the compositor (see the Sep 21 layer-budget finding in sheets.css). */

.phero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.phero__stack { z-index: 1; }

/* The animation replaces the faint static mark behind the headline. */
html[data-hero="b"] .phero__mark { display: none; }

/* 1. Transcript */
.phero__bg--transcript {
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 80%, transparent 97%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 80%, transparent 97%);
}

/* Paper pooled behind the copy so the headline never sits on text. */
.phero__bg--transcript::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 50% 44% at 50% 52%, var(--paper) 45%, rgba(244, 242, 238, 0) 100%);
}

.tr__col {
  position: absolute;
  top: 0;
  left: clamp(3.5rem, 7vw, 6rem);
  right: 0;
  font-family: var(--mono);
  font-size: clamp(0.78rem, 1.05vw, 0.95rem);
  line-height: 2.7;
  color: rgba(18, 18, 18, 0.2);
  animation: tr-up 110s linear infinite;
  will-change: transform;
}

.tr__col p { margin: 0; white-space: nowrap; overflow: hidden; }
.tr__col .tn { display: inline-block; width: 3.4em; color: rgba(18, 18, 18, 0.28); }
.tr__col .tw { display: inline-block; width: 2.6em; color: rgba(224, 53, 43, 0.4); }

/* A redacted word: the word is really there, the bar sits on it. */
.tr__col b {
  position: relative;
  display: inline-block;
  font-weight: 400;
  color: transparent;
  transition: color 0.4s linear 0.3s;
}

.tr__col b.is-lift { color: rgba(18, 18, 18, 0.55); }

.tr__col b::before {
  content: "";
  position: absolute;
  inset: 0.5em -0.12em 0.42em;
  background: rgba(18, 18, 18, 0.15);
  transform-origin: right;
  transition: transform 0.72s cubic-bezier(0.76, 0, 0.24, 1);
}

.tr__col b::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.52em;
  height: 1.5px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease) 0.45s;
}

.tr__col b.is-lift::before { transform: scaleX(0); }
.tr__col b.is-lift::after { transform: scaleX(1); }

@keyframes tr-up { to { transform: translateY(-50%); } }

/* 2. Drifting exhibits */
.dr {
  position: absolute;
  top: 100%;
  display: block;
  opacity: 0.16;
  animation: dr-up var(--d) linear var(--o) infinite;
  will-change: transform;
}

.dr svg { display: block; width: 100%; height: auto; }

@keyframes dr-up {
  from { transform: translateY(0) rotate(var(--r)); }
  to { transform: translateY(calc(-100svh - 260px)) rotate(calc(var(--r) * -1)); }
}

@media (max-width: 640px) {
  .tr__col { left: 1rem; right: 1rem; }
  .phero__bg--transcript::after { background: radial-gradient(ellipse 70% 42% at 50% 50%, var(--paper) 40%, rgba(244, 242, 238, 0) 100%); }
  .dr { width: 58px !important; opacity: 0.1; }
  .dr:nth-child(n+7) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .phero__back, .phero__sheet, .phero__mark, .phero__rule { transition: none !important; }
  .phero__cue i::after { animation: none; }
  .tr__col, .dr { animation: none; }
  .dr { top: auto; bottom: 8%; }
}

/* ------------------------------------------------ Sep 28 pass 2 (his notes) */

/* File number, centred over the headline. Same size as the old caption row. */
.phero__file {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 clamp(1.1rem, 2.4vw, 1.6rem);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--red);
}
.phero__file::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
}



/* The outline button sits on moving text, so give it the paper. */
.phero .btn--ghost { background: var(--paper); }
