/* ============================================================
   SAVED BY THE BELL — Victorian dark design system
   ============================================================ */

:root{
  --bg:#0b0908;
  --bg-2:#100d0a;
  --panel:#151109;
  --panel-2:#1a150d;
  --rule:#2b2218;
  --rule-soft:#1e1811;
  --bone:#e8dcc4;
  --bone-dim:#c9bda2;
  --dim:#9a8c70;
  --dim-2:#6d6250;
  --amber:#d9a441;
  --amber-bright:#f0c060;
  --amber-deep:#8a6420;
  --blood:#a03a2c;
  --verdigris:#6d8a7a;
  --f-display:"IM Fell English SC", Georgia, "Times New Roman", serif;
  --f-fell:"IM Fell English", Georgia, "Times New Roman", serif;
  --f-body:"Newsreader", Georgia, "Times New Roman", serif;
  --f-mono:"IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

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

html{ scroll-behavior:smooth; }

body{
  background:var(--bg);
  color:var(--bone);
  font-family:var(--f-body);
  font-size:1.06rem;
  line-height:1.75;
  font-optical-sizing:auto;
  overflow-x:hidden;
}

::selection{ background:var(--amber-deep); color:var(--bone); }

/* ---------- grain overlay ---------- */
.grain{
  position:fixed; inset:-50%;
  width:200%; height:200%;
  pointer-events:none;
  z-index:60;
  opacity:.05;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  animation:grainshift 1.2s steps(4) infinite;
}
@keyframes grainshift{
  0%{ transform:translate(0,0); }
  25%{ transform:translate(-2%,1%); }
  50%{ transform:translate(1%,-2%); }
  75%{ transform:translate(-1%,2%); }
  100%{ transform:translate(2%,-1%); }
}

/* ---------- topbar ---------- */
.topbar{
  position:fixed; top:0; left:0; right:0;
  z-index:50;
  display:flex; align-items:center; justify-content:space-between;
  gap:1rem;
  padding:.65rem 1.25rem;
  background:linear-gradient(to bottom, rgba(11,9,8,.96), rgba(11,9,8,.82));
  border-bottom:1px solid var(--rule-soft);
  backdrop-filter:blur(6px);
}
.logo{
  font-family:var(--f-display);
  font-size:1.02rem;
  letter-spacing:.06em;
  color:var(--bone-dim);
  white-space:nowrap;
}
.logo b{ color:var(--amber); font-weight:normal; }
.chapters{
  display:flex; gap:1.1rem;
  overflow-x:auto;
  scrollbar-width:none;
  font-family:var(--f-mono);
  font-size:.62rem;
  text-transform:uppercase;
  letter-spacing:.14em;
}
.chapters::-webkit-scrollbar{ display:none; }
.chapters a{
  color:var(--dim);
  text-decoration:none;
  white-space:nowrap;
  padding:.2rem 0;
  border-bottom:1px solid transparent;
  transition:color .25s, border-color .25s;
}
.chapters a:hover{ color:var(--amber); border-color:var(--amber-deep); }

.progress{
  position:fixed; top:0; left:0; right:0;
  height:2px; z-index:55;
  background:transparent;
}
.progress i{
  display:block; height:100%;
  width:0%;
  background:linear-gradient(to right, var(--amber-deep), var(--amber-bright));
  box-shadow:0 0 8px rgba(217,164,65,.5);
}

/* ---------- reveal ---------- */
.reveal{
  opacity:0;
  transform:translateY(22px);
  transition:opacity .9s ease, transform .9s ease;
}
.reveal.in{
  opacity:1;
  transform:none;
}

/* ---------- hero ---------- */
.hero{
  min-height:100svh;
  display:flex; align-items:center; justify-content:center;
  text-align:center;
  padding:6.5rem 1.5rem 4rem;
  background:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(217,164,65,.10), transparent 60%),
    radial-gradient(ellipse 60% 40% at 50% 115%, rgba(160,58,44,.08), transparent 65%),
    var(--bg);
  position:relative;
}
.hero-inner{ max-width:760px; }

.kicker{
  font-family:var(--f-mono);
  font-size:.66rem;
  letter-spacing:.34em;
  text-transform:uppercase;
  color:var(--dim);
  margin-bottom:2.2rem;
}

.hero h1{
  font-family:var(--f-display);
  font-weight:normal;
  font-size:clamp(3rem, 9vw, 6.2rem);
  line-height:1.02;
  letter-spacing:.02em;
  color:var(--bone);
  margin:1.6rem 0 1.4rem;
  text-shadow:0 0 40px rgba(217,164,65,.15);
}
.hero h1 .amp{
  font-family:var(--f-fell);
  font-style:italic;
  font-size:.55em;
  color:var(--amber);
  vertical-align:.12em;
}

.standfirst{
  font-size:clamp(1.02rem, 2.2vw, 1.2rem);
  color:var(--bone-dim);
  max-width:620px;
  margin:0 auto;
}
.standfirst em{
  font-family:var(--f-fell);
  font-style:italic;
  color:var(--amber-bright);
}

.ringtally{
  margin-top:2rem;
  font-family:var(--f-mono);
  font-size:.72rem;
  letter-spacing:.18em;
  text-transform:uppercase;
  color:var(--dim);
}

.scrollcue{
  margin-top:3.2rem;
  font-family:var(--f-fell);
  font-style:italic;
  color:var(--dim-2);
  font-size:.95rem;
  animation:bob 3.4s ease-in-out infinite;
}
@keyframes bob{
  0%,100%{ transform:translateY(0); opacity:.7; }
  50%{ transform:translateY(7px); opacity:1; }
}

/* ---------- the bell ---------- */
.bellrig{
  display:inline-flex;
  flex-direction:column;
  align-items:center;
  cursor:pointer;
  user-select:none;
  -webkit-tap-highlight-color:transparent;
  outline-offset:8px;
}
.bellrig:focus-visible{ outline:2px solid var(--amber); }
.bellsvg{ width:min(210px, 48vw); height:auto; overflow:visible; }
.bellgroup{
  transform-origin:130px 40px;
}
.bellgroup.swing{ animation:swing 2.6s cubic-bezier(.36,.07,.19,.97) 1; }
@keyframes swing{
  0%{ transform:rotate(0); }
  12%{ transform:rotate(9deg); }
  30%{ transform:rotate(-7.5deg); }
  48%{ transform:rotate(5.5deg); }
  64%{ transform:rotate(-3.5deg); }
  80%{ transform:rotate(1.8deg); }
  100%{ transform:rotate(0); }
}
.bellbody{
  fill:url(#bellgrad);
  fill:#241b0e;
  stroke:var(--amber);
  stroke-width:2.5;
}
.belllip{ fill:#1a130a; stroke:var(--amber); stroke-width:2; }
.bellcrown{ fill:none; stroke:var(--amber); stroke-width:2.5; }
.clapperrod{ stroke:var(--amber-deep); stroke-width:2; }
.clapper{ fill:var(--amber-deep); stroke:var(--amber); stroke-width:1.5; }
.rope{ stroke:#7a6a4e; stroke-width:3; stroke-dasharray:1 5; stroke-linecap:round; }
.ropeknot{ fill:#7a6a4e; }
.pullhint{
  margin-top:.9rem;
  font-family:var(--f-fell);
  font-style:italic;
  font-size:.95rem;
  color:var(--dim);
  transition:color .3s;
}
.bellrig:hover .pullhint{ color:var(--amber); }
.bellrig.small .bellsvg{ width:min(120px, 30vw); }
.bellrig.small .pullhint{ display:none; }

/* ---------- chapters ---------- */
.chapter{
  max-width:1060px;
  margin:0 auto;
  padding:6.5rem 1.5rem 2rem;
  scroll-margin-top:4rem;
}
.chapnum{
  font-family:var(--f-mono);
  font-size:.66rem;
  letter-spacing:.4em;
  text-transform:uppercase;
  color:var(--amber-deep);
  text-align:center;
}
.chapter h2{
  font-family:var(--f-display);
  font-weight:normal;
  font-size:clamp(2rem, 5vw, 3.2rem);
  text-align:center;
  margin:.7rem 0 1.2rem;
  color:var(--bone);
}
.rule{
  width:min(320px, 60%);
  height:1px;
  margin:0 auto 3rem;
  background:linear-gradient(to right, transparent, var(--amber-deep), transparent);
  position:relative;
}
.rule::after{
  content:"❦";
  position:absolute;
  left:50%; top:50%;
  transform:translate(-50%,-52%);
  background:var(--bg);
  padding:0 .7rem;
  color:var(--amber-deep);
  font-size:.9rem;
}

.prose{
  max-width:680px;
  margin:0 auto;
}
.prose p{ margin-bottom:1.5rem; }
.prose .drop::first-letter{
  font-family:var(--f-display);
  font-size:3.6em;
  float:left;
  line-height:.82;
  padding:.06em .12em 0 0;
  color:var(--amber);
}
.prose em{ color:var(--bone); }

blockquote.quote{
  font-family:var(--f-fell);
  font-style:italic;
  font-size:clamp(1.25rem, 3vw, 1.6rem);
  line-height:1.5;
  color:var(--amber-bright);
  text-align:center;
  max-width:640px;
  margin:3rem auto;
  padding:0 1rem;
}
blockquote.quote cite{
  display:block;
  margin-top:1.1rem;
  font-family:var(--f-mono);
  font-style:normal;
  font-size:.66rem;
  letter-spacing:.22em;
  text-transform:uppercase;
  color:var(--dim);
}

/* ---------- EKG ---------- */
.ekgfig{
  margin:3rem 0;
  border:1px solid var(--rule);
  background:
    linear-gradient(rgba(217,164,65,.03), rgba(217,164,65,.03)),
    var(--bg-2);
  padding:1.2rem 1rem .9rem;
}
#ekg{ width:100%; height:auto; display:block; }
.ekgfig figcaption{
  margin-top:.8rem;
  font-family:var(--f-fell);
  font-style:italic;
  font-size:.95rem;
  color:var(--dim);
  text-align:center;
}

/* ---------- stats ---------- */
.statrow{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
  gap:1px;
  background:var(--rule-soft);
  border:1px solid var(--rule-soft);
  max-width:940px;
  margin:3rem auto;
}
.stat{
  background:var(--panel);
  padding:2rem 1.6rem;
  text-align:center;
}
.statnum{
  font-family:var(--f-display);
  font-size:clamp(2.6rem, 6vw, 3.6rem);
  color:var(--amber);
  line-height:1;
}
.statplus{
  font-family:var(--f-display);
  font-size:2rem;
  color:var(--amber-deep);
}
.statlabel{
  display:block;
  margin-top:.9rem;
  font-size:.86rem;
  line-height:1.55;
  color:var(--dim);
}

/* ---------- coffin lab ---------- */
.coffinlab{
  display:grid;
  grid-template-columns:1.25fr .75fr;
  gap:1.5rem;
  align-items:start;
  max-width:1060px;
  margin:2.5rem auto 3rem;
}
.coffinfig{
  border:1px solid var(--rule);
  background:
    radial-gradient(ellipse 70% 40% at 50% 0%, rgba(217,164,65,.05), transparent 60%),
    var(--bg-2);
  padding:1rem;
}
#coffinsvg{ width:100%; height:auto; display:block; }
.coffinfig figcaption{
  margin-top:.7rem;
  font-family:var(--f-fell);
  font-style:italic;
  font-size:.9rem;
  color:var(--dim);
  text-align:center;
}

/* diagram strokes */
#coffinsvg .moon{ fill:#3a3122; }
#coffinsvg .moonsky{ fill:var(--bg-2); }
#coffinsvg .stars circle{ fill:var(--dim-2); opacity:.8; }
#coffinsvg .ground{ stroke:var(--bone-dim); stroke-width:2; }
#coffinsvg .grass path{ stroke:var(--verdigris); stroke-width:1.4; fill:none; opacity:.7; }
#coffinsvg .soilhatch path{ stroke:#241c12; stroke-width:1.2; fill:none; }
#coffinsvg .shaft{ stroke:#3d3223; stroke-width:2; fill:none; stroke-dasharray:6 4; }
#coffinsvg .ladder line{ stroke:var(--bone-dim); stroke-width:1.6; opacity:.85; }
#coffinsvg .laddershaft{ fill:rgba(21,17,9,.6); stroke:#3d3223; stroke-width:1.5; }
#coffinsvg .hatch{ stroke:var(--bone-dim); stroke-width:1.6; fill:none; }
#coffinsvg .coffinlid{ fill:#1c150c; stroke:var(--amber-deep); stroke-width:2; }
#coffinsvg .coffinbody{ fill:#171008; stroke:var(--amber-deep); stroke-width:2; }
#coffinsvg .coffinseam{ stroke:var(--amber-deep); stroke-width:1; opacity:.6; }
#coffinsvg .window rect{ fill:rgba(217,164,65,.12); stroke:var(--amber); stroke-width:1.5; }
#coffinsvg .window line{ stroke:var(--amber); stroke-width:1; opacity:.5; }
#coffinsvg .body circle{ fill:none; stroke:var(--bone-dim); stroke-width:2; }
#coffinsvg .body path{ fill:none; stroke:var(--bone-dim); stroke-width:2; }
#coffinsvg .body .hand{ fill:var(--bone-dim); stroke:none; }
#coffinsvg .cord{ stroke:var(--blood); stroke-width:1.8; fill:none; stroke-dasharray:5 4; }
#coffinsvg .cordtube line{ stroke:var(--dim); stroke-width:1.6; }
#coffinsvg .bellhousing rect{ fill:#1c150c; stroke:var(--amber-deep); stroke-width:1.8; }
#coffinsvg .bellhousing path{ fill:none; stroke:var(--amber-deep); stroke-width:1.8; }
#coffinsvg .minibell{ fill:var(--amber-deep); stroke:var(--amber); stroke-width:1; }
#coffinsvg .miniclapper{ fill:var(--amber); }
#coffinsvg .airtube line{ stroke:var(--verdigris); stroke-width:1.8; }
#coffinsvg .ventcap{ fill:none; stroke:var(--verdigris); stroke-width:1.8; }
#coffinsvg .flagsignal rect{ fill:#1c150c; stroke:var(--dim); stroke-width:1.6; }
#coffinsvg .spring{ stroke:var(--dim); stroke-width:1.4; fill:none; }
#coffinsvg .flagsignal line{ stroke:var(--dim); stroke-width:1.6; }
#coffinsvg .flag{ fill:var(--blood); stroke:none; }

/* hotspots */
.hotspot{ cursor:pointer; outline:none; }
.hotspot circle{
  fill:rgba(11,9,8,.85);
  stroke:var(--amber);
  stroke-width:1.6;
  transition:fill .25s, stroke .25s;
}
.hotspot text{
  font-family:var(--f-mono);
  font-size:13px;
  fill:var(--amber);
  text-anchor:middle;
  pointer-events:none;
  transition:fill .25s;
}
.hotspot:hover circle, .hotspot:focus-visible circle{ fill:var(--amber-deep); }
.hotspot.active circle{ fill:var(--blood); stroke:var(--amber-bright); }
.hotspot.active text{ fill:var(--bone); }

/* panel */
.coffinpanel{
  position:sticky;
  top:4.5rem;
  border:1px solid var(--rule);
  background:var(--panel);
  padding:1.8rem 1.6rem;
  min-height:280px;
}
.panelnum{
  font-family:var(--f-mono);
  font-size:.66rem;
  letter-spacing:.3em;
  text-transform:uppercase;
  color:var(--amber-deep);
}
.coffinpanel h3{
  font-family:var(--f-display);
  font-weight:normal;
  font-size:1.5rem;
  margin:.5rem 0 .9rem;
  color:var(--amber-bright);
}
.coffinpanel p:last-child{
  font-size:.95rem;
  color:var(--bone-dim);
}
.coffinpanel.flash{ animation:panelflash .5s ease; }
@keyframes panelflash{
  0%{ border-color:var(--amber-bright); box-shadow:0 0 24px rgba(217,164,65,.25); }
  100%{ border-color:var(--rule); box-shadow:none; }
}

/* ---------- patents ---------- */
.patentgrid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(290px, 1fr));
  gap:1.2rem;
  max-width:1060px;
  margin:1rem auto 2rem;
}
.patent{
  border:1px solid var(--rule);
  background:var(--panel);
  padding:1.7rem 1.5rem;
  position:relative;
  transition:transform .35s ease, border-color .35s ease, box-shadow .35s ease;
}
.patent:hover{
  transform:translateY(-4px);
  border-color:var(--amber-deep);
  box-shadow:0 12px 30px rgba(0,0,0,.4);
}
.ptag{
  font-family:var(--f-mono);
  font-size:.6rem;
  letter-spacing:.28em;
  text-transform:uppercase;
  color:var(--blood);
}
.patent h3{
  font-family:var(--f-display);
  font-weight:normal;
  font-size:1.35rem;
  margin:.55rem 0 .2rem;
  color:var(--bone);
}
.pdate{
  font-family:var(--f-mono);
  font-size:.68rem;
  letter-spacing:.12em;
  color:var(--dim);
  margin-bottom:.9rem;
}
.pdesc{
  font-size:.92rem;
  line-height:1.65;
  color:var(--bone-dim);
}

/* ---------- myth cards ---------- */
.mythgrid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:1.2rem;
  max-width:1060px;
  margin:1rem auto 2rem;
}
.mythcard{
  display:grid;
  position:relative;
  width:100%;
  min-height:230px;
  background:none;
  border:none;
  padding:0;
  cursor:pointer;
  perspective:1200px;
  font:inherit;
  color:inherit;
  text-align:left;
}
.mythfront, .mythback{
  grid-area:1 / 1;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:.8rem;
  min-height:230px;
  padding:1.8rem 1.6rem;
  border:1px solid var(--rule);
  background:var(--panel);
  backface-visibility:hidden;
  -webkit-backface-visibility:hidden;
  transition:transform .7s cubic-bezier(.4,.1,.2,1), opacity .7s;
}
.mythfront{ align-items:center; text-align:center; }
.mythphrase{
  font-family:var(--f-display);
  font-size:1.5rem;
  color:var(--amber);
}
.mythhint{
  font-family:var(--f-mono);
  font-size:.62rem;
  letter-spacing:.24em;
  text-transform:uppercase;
  color:var(--dim-2);
}
.mythback{
  transform:rotateY(180deg);
  opacity:0;
  background:var(--panel-2);
  border-color:var(--amber-deep);
}
.mythcard.flipped .mythfront{ transform:rotateY(180deg); opacity:0; }
.mythcard.flipped .mythback{ transform:rotateY(0); opacity:1; }
.mythverdict{
  font-family:var(--f-fell);
  font-style:italic;
  font-size:1.1rem;
  color:var(--amber-bright);
}
.mythtext{
  font-size:.9rem;
  line-height:1.6;
  color:var(--bone-dim);
}

/* ---------- closing ---------- */
.closing{
  text-align:center;
  padding:3rem 0 2rem;
}
.closingline{
  margin-top:1.4rem;
  font-family:var(--f-fell);
  font-style:italic;
  font-size:1.15rem;
  color:var(--dim);
  transition:color .4s;
}
.closingline.lit{ color:var(--amber-bright); }

/* ---------- colophon ---------- */
.colophon{
  max-width:680px;
  margin:4rem auto 0;
  padding:3rem 1.5rem 5rem;
  text-align:center;
  font-size:.85rem;
  color:var(--dim);
  line-height:1.7;
}
.colophon .rule{ margin-bottom:2rem; }
.colophonhead{
  font-family:var(--f-fell);
  font-style:italic;
  color:var(--amber-deep);
  margin-bottom:1.4rem;
}
.colophon p{ margin-bottom:1.1rem; }
.colophon strong{
  font-family:var(--f-mono);
  font-size:.68rem;
  letter-spacing:.2em;
  text-transform:uppercase;
  color:var(--bone-dim);
}
.colophon em{ color:var(--bone-dim); }

/* ---------- responsive ---------- */
@media (max-width: 860px){
  .coffinlab{ grid-template-columns:1fr; }
  .coffinpanel{ position:static; min-height:0; }
  .chapters{ gap:.9rem; }
}
@media (max-width: 560px){
  .topbar{ padding:.55rem .9rem; }
  .logo{ font-size:.9rem; }
  .chapter{ padding:5rem 1.15rem 1.5rem; }
  .stat{ padding:1.5rem 1.1rem; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior:auto; }
  .reveal{ opacity:1; transform:none; transition:none; }
  .grain{ animation:none; }
  .scrollcue{ animation:none; }
  .bellgroup.swing{ animation:none; }
  .mythfront, .mythback{ transition:opacity .3s; }
  .mythcard.flipped .mythfront{ transform:none; }
  .mythcard.flipped .mythback{ transform:none; }
}
