/* ==========================================================================
   Story pages — /rasoimind
   A page that reads like a short story rather than a brochure: chapters,
   large type, warm grounds and one idea per screen. It sits inside the
   site's header and footer but sets its own palette and rhythm, so it is
   scoped to main.story and loaded only on the pages that use it.

   No web fonts beyond the site's Poppins: the narrative voice uses the
   system's book serif, which every platform has.
   ========================================================================== */

.story {
  --paper: #F6EFE4;
  --paper-deep: #EFE4D3;
  --ink: #0E163F;
  --ink-soft: #3F4459;
  --ember: #1C120C;         /* the warm dark chapters */
  --ember-raised: #2A1B12;
  --ember-text: #F3E6D6;
  --ember-soft: #CDB9A3;
  --copper: #B96E37;
  --copper-light: #D68A4C;
  --copper-dark: #8D4F21;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;

  background: var(--paper);
  color: var(--ink);
  overflow-x: clip;
}

/* Reading progress, under the sticky header */
.story-progress {
  position: sticky;
  top: var(--header-height);
  z-index: 50;
  height: 3px;
  background: transparent;
}
.story-progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--copper-dark), var(--copper-light));
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.story-wrap { width: min(100% - 2rem, 46rem); margin-inline: auto; }
.story-wrap-wide { width: min(100% - 2rem, 72rem); margin-inline: auto; }

/* ---------- Hero ---------- */
.story-hero {
  background: var(--ember);
  color: var(--ember-text);
  padding: clamp(3.5rem, 9vw, 7rem) 0 0;
  text-align: center;
}
.story-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--copper-light);
  font-weight: 600;
  margin-bottom: 1.25rem;
}
.story-hero h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.4rem, 1.4rem + 4.6vw, 5rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: #FFF8EF;
  margin: 0 auto 1.25rem;
  max-width: 14ch;
}
.story-hero h1 em { font-style: italic; color: var(--copper-light); }
.story-lede {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1rem + 0.7vw, 1.45rem);
  line-height: 1.55;
  color: var(--ember-soft);
  max-width: 34rem;
  margin: 0 auto 2.25rem;
}

.story-establish {
  margin: clamp(3rem, 7vw, 5rem) 0 0;
  position: relative;
}
.story-establish img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 78vh;
  object-fit: cover;
  object-position: 40% 50%;
}
.story-establish::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 22%;
  background: linear-gradient(var(--ember), rgba(28, 18, 12, 0));
  pointer-events: none;
}
.story-caption {
  font-size: 0.8rem;
  color: var(--ember-soft);
  padding: 0.75rem 1rem 0;
  text-align: center;
}
.story-hero .story-caption { padding-bottom: 1.25rem; }

/* ---------- Chapters ---------- */
.story-ch { padding: clamp(4.5rem, 11vw, 8.5rem) 0; }
.story-ch-dark { background: var(--ember); color: var(--ember-text); }
.story-ch-deep { background: var(--paper-deep); }

.story-chapter {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--copper-dark);
  margin-bottom: 1.75rem;
}
.story-chapter::before { content: ""; width: 2.5rem; height: 1px; background: currentColor; }
.story-ch-dark .story-chapter { color: var(--copper-light); }

.story-h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2rem, 1.3rem + 3vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.005em;
  margin-bottom: 1.5rem;
  color: inherit;
}
.story-ch-dark .story-h2 { color: #FFF8EF; }

.story-p {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1.02rem + 0.55vw, 1.4rem);
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 1.25rem;
}
.story-ch-dark .story-p { color: var(--ember-soft); }
.story-p strong { color: var(--ink); font-weight: 600; }
.story-ch-dark .story-p strong { color: #FFF8EF; }

.story-time {
  font-family: var(--serif);
  font-size: clamp(3.5rem, 2rem + 7vw, 7rem);
  line-height: 1;
  color: var(--copper);
  margin-bottom: 1rem;
}

/* The thoughts she carries */
.thoughts {
  list-style: none;
  margin: clamp(2.5rem, 6vw, 4rem) 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem 1.25rem;
}
.thoughts li {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.15rem;
  line-height: 1.45;
  background: #FFFCF6;
  border: 1px solid rgba(141, 79, 33, 0.18);
  border-left: 3px solid var(--copper);
  border-radius: 6px 14px 14px 6px;
  padding: 1rem 1.15rem;
  box-shadow: 0 8px 22px rgba(60, 35, 15, 0.08);
  color: var(--ink);
}

.story-moment + .story-moment { margin-top: clamp(3.5rem, 8vw, 5.5rem); }
.story-moment .thoughts { margin-bottom: 0; }

.story-turn {
  margin-top: clamp(3rem, 7vw, 4.5rem);
  font-family: var(--serif);
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.3rem);
  line-height: 1.3;
  color: var(--ink);
  border-top: 1px solid rgba(14, 22, 63, 0.15);
  padding-top: 2rem;
}
.story-turn em { color: var(--copper-dark); }

/* The four steps */
.story-steps {
  list-style: none;
  padding: 0;
  margin: clamp(2.5rem, 6vw, 3.5rem) 0 2rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  counter-reset: story-step;
}
.story-steps li {
  position: relative;
  border-radius: 16px;
  padding: 1.25rem 1.1rem 1.15rem;
  border: 1px solid rgba(243, 230, 214, 0.22);
  background: var(--ember-raised);
}
.story-steps li::before {
  counter-increment: story-step;
  content: counter(story-step);
  display: block;
  font-family: var(--serif);
  font-size: 2rem;
  line-height: 1;
  color: var(--ember-soft);
  margin-bottom: 0.6rem;
}
.story-steps li:not(:last-child)::after {
  content: "→";
  position: absolute;
  right: -0.85rem;
  top: 1.55rem;
  color: var(--copper-light);
  font-size: 1rem;
}
.step-name { display: block; font-weight: 600; font-size: 1.05rem; color: #FFF8EF; }
.step-what { display: block; font-size: 0.9rem; color: var(--ember-soft); margin: 0.2rem 0 0.9rem; }
.step-tag {
  display: inline-block;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(243, 230, 214, 0.3);
  color: var(--ember-soft);
}
.story-steps li.is-unseen {
  background: rgba(214, 138, 76, 0.1);
  border: 1px dashed var(--copper-light);
}
.story-steps li.is-unseen::before { color: var(--copper-light); }
.story-steps li.is-unseen .step-tag { border-color: var(--copper-light); color: var(--copper-light); }
.steps-loop { font-size: 0.85rem; color: var(--ember-soft); text-align: right; margin-bottom: 2.5rem; }

.story-source { font-size: 0.85rem; color: var(--ember-soft); line-height: 1.6; }
.story-source a { color: var(--copper-light); }
.story-note {
  font-size: 0.95rem;
  color: var(--ember-soft);
  border-left: 2px solid rgba(214, 138, 76, 0.5);
  padding-left: 1rem;
  margin: 2rem 0;
  line-height: 1.6;
}

/* Interlude */
.story-interlude { padding: clamp(5rem, 13vw, 10rem) 0; text-align: center; }
.story-interlude p {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 1.1rem + 3.2vw, 3.3rem);
  line-height: 1.25;
  color: var(--ink);
  max-width: 22ch;
  margin: 0 auto;
}
.story-interlude p em { color: var(--copper-dark); }

/* The concept illustration */
.story-figure { margin: clamp(2.5rem, 6vw, 4rem) 0 0; }
.story-figure-frame { position: relative; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35); }
.story-figure-frame img { display: block; width: 100%; height: auto; }
.story-figure figcaption { font-size: 0.8rem; color: var(--ember-soft); margin-top: 1.5rem; }

/* Is / is not */
.isnot { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; margin: 2.5rem 0; }
.isnot-col { border-radius: 18px; padding: 1.75rem 1.5rem; }
.isnot-col h3 { font-size: 0.78rem; letter-spacing: 0.16em; text-transform: uppercase; margin-bottom: 1.1rem; font-weight: 600; }
.isnot-col ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.9rem; }
.isnot-col li { font-family: var(--serif); font-size: 1.2rem; line-height: 1.4; padding-left: 1.75rem; position: relative; }
.isnot-yes { background: #FFFCF6; border: 1px solid rgba(141, 79, 33, 0.25); }
.isnot-yes h3 { color: var(--copper-dark); }
.isnot-yes li::before { content: "✓"; position: absolute; left: 0; color: var(--copper); font-family: var(--font-main); font-weight: 700; }
.isnot-no { background: transparent; border: 1px dashed rgba(14, 22, 63, 0.3); }
.isnot-no h3 { color: var(--ink-soft); }
.isnot-no li { color: var(--ink-soft); }
.isnot-no li::before { content: "✕"; position: absolute; left: 0; color: #8A8FA3; font-family: var(--font-main); }

.story-rule {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 1.05rem + 1.5vw, 2rem);
  line-height: 1.35;
  text-align: center;
  color: var(--ink);
  padding: 2.25rem 1rem;
  border-top: 1px solid rgba(14, 22, 63, 0.15);
  border-bottom: 1px solid rgba(14, 22, 63, 0.15);
  margin-top: 3rem;
}
.story-rule em { color: var(--copper-dark); }

/* Close: status and the two ways on */
.story-close { text-align: center; margin-top: 3rem; }
.story .badge {
  background: rgba(141, 79, 33, 0.08);
  border: 1px solid rgba(141, 79, 33, 0.3);
  color: var(--copper-dark);
  margin-bottom: 1.5rem;
}
.story-actions { display: flex; flex-wrap: wrap; gap: 0.9rem; justify-content: center; }
.btn-outline-ink { background: transparent; border-color: var(--ink); color: var(--ink); font-weight: 600; }
.btn-outline-ink:hover, .btn-outline-ink:focus-visible { background: var(--ink); color: #fff; transform: translateY(-2px); }

/* ---------- Scenes: a moment and its picture, side by side ---------- */
.scene { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.scene-flip .scene-text { order: 2; }
.scene-figure { margin: 0; }
.scene-figure img { display: block; width: 100%; height: auto; border-radius: 18px; box-shadow: 0 24px 50px rgba(40, 22, 10, 0.22); }
.story-ch-dark .scene-figure img { box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4); }
.story-place {
  display: block;
  font-family: var(--font-main);
  font-size: 0.8rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 0.4rem;
}
.story-turn-dark { color: #FFF8EF; border-top-color: rgba(243, 230, 214, 0.2); }
.story-turn-dark em { color: var(--copper-light); }

/* A phone notification, drawn rather than photographed */
.notif {
  max-width: 22rem;
  margin-top: 1.75rem;
  background: #FFFCF6;
  border: 1px solid rgba(141, 79, 33, 0.22);
  border-radius: 18px;
  padding: 1rem 1.15rem 1.1rem;
  box-shadow: 0 18px 40px rgba(60, 35, 15, 0.14);
}
.notif-app { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; color: var(--copper-dark); margin-bottom: 0.35rem; }
.notif-text { font-family: var(--serif); font-size: 1.2rem; line-height: 1.35; color: var(--ink); margin-bottom: 0.9rem; }
.notif-btn {
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--copper-dark);
  background: var(--copper-light);
  color: var(--ink);
  cursor: pointer;
}
.notif-btn:hover, .notif-btn:focus-visible { background: #e39a5c; }
.notif-sent { font-size: 0.95rem; color: var(--ink-soft); line-height: 1.5; }

@media (max-width: 860px) {
  .scene { grid-template-columns: 1fr; }
  .scene-flip .scene-text { order: 0; }
}

/* ---------- Reveal on scroll ----------
   Only once story.js has run (it adds .story-js), so the page reads in full
   without JavaScript. */
.story-js [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.16, 1, 0.3, 1); }
.story-js [data-reveal].is-in { opacity: 1; transform: none; }
.story-js .thoughts li[data-reveal] { transition-delay: calc(var(--i, 0) * 90ms); }

@media (prefers-reduced-motion: reduce) {
  .story-js [data-reveal] { opacity: 1; transform: none; transition: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .story-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .story-steps li:nth-child(2)::after { content: "↓"; right: 1rem; top: auto; bottom: -1.05rem; }
  .story-steps li:nth-child(3)::after { content: "←"; right: auto; left: -0.85rem; }
  .story-steps li:nth-child(3) { order: 4; }
  .story-steps li:nth-child(4) { order: 3; }
  .story-steps li:nth-child(4)::after { content: "↑"; position: absolute; right: auto; left: 1rem; top: -1.05rem; }
  .isnot { grid-template-columns: 1fr; }
  .steps-loop { text-align: left; }
}
@media (max-width: 520px) {
  .story-establish img { max-height: none; }
}
