/* devil.quest — a watercolour field-journal
   Palette: #0F1E3D Inkwell Navy · #2B3E66 Slate Indigo · #B8A06A Brass Patina
            #8C8E92 Pewter Wash · #F2EADA Bone Paper · #1F2A44 Iron Gall Body
   Type: Commissioner (body/chrome) · Cormorant Garamond 600 italic (display) */

:root {
  --ink-navy:   #0F1E3D;
  --slate:      #2B3E66;
  --brass:      #B8A06A;
  --pewter:     #8C8E92;
  --paper:      #F2EADA;
  --iron-gall:  #1F2A44;
  --rail-w:     320px;
  --ledger-h:   56px;
  --lift-ease:  cubic-bezier(0.2, 0.7, 0.2, 1.0);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--iron-gall);
  font-family: 'Commissioner', system-ui, sans-serif;
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- paper grain overlay ---------- */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0.06;
  mix-blend-mode: multiply;
}
.grain svg { width: 100%; height: 100%; display: block; }

/* shared hover-lift */
.lift {
  transition: transform 220ms var(--lift-ease), box-shadow 220ms var(--lift-ease);
  will-change: transform;
}
.lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 18px rgba(15, 30, 61, 0.18);
}

/* ============ SIDEBAR RAIL ============ */
.rail {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--rail-w);
  height: 100vh;
  background:
    linear-gradient(90deg,
      rgba(242, 234, 218, 1) 0%,
      rgba(242, 234, 218, 1) 60%,
      rgba(242, 234, 218, 0.4) 100%),
    var(--paper);
  border-right: 1px solid rgba(43, 62, 102, 0.18);
  z-index: 30;
  overflow: hidden;
}
.rail-bleed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  mix-blend-mode: multiply;
  pointer-events: none;
}
.rail-inner {
  position: relative;
  z-index: 2;
  height: 100%;
  padding: 38px 26px 26px 30px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* wordmark */
.wordmark {
  line-height: 1.05;
  text-shadow: 0 0 8px var(--paper);
}
.wordmark-devil,
.wordmark-quest {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 2.4rem;
  color: var(--ink-navy);
}
.wordmark-dot {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 2.4rem;
  color: var(--brass);
}
.wordmark-sub {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 350;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--slate);
}

/* table of contents */
.toc { flex: 0 0 auto; }
.toc ol { list-style: none; }
.toc li { margin-bottom: 2px; }
.toc a {
  display: grid;
  grid-template-columns: 24px 30px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 3px;
  text-decoration: none;
  color: var(--ink-navy);
  text-shadow: 0 0 8px var(--paper);
}
.toc a.active {
  background: rgba(43, 62, 102, 0.10);
}
.toc .ic { width: 24px; height: 24px; }
.toc .ic svg { width: 100%; height: 100%; display: block; }
.toc .rn {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--brass);
}
.toc .lbl {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

/* ribbon thermometer */
.thermo {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  gap: 10px;
  min-height: 60px;
  margin-left: 4px;
}
.thermo svg {
  width: 18px;
  height: 100%;
  overflow: visible;
}
.thermo-track {
  fill: none;
  stroke: rgba(43, 62, 102, 0.22);
  stroke-width: 6;
  stroke-linecap: round;
}
.thermo-fill {
  fill: none;
  stroke: rgba(43, 62, 102, 0.55);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 120ms linear;
}
.thermo-cap {
  fill: var(--brass);
  stroke: var(--ink-navy);
  stroke-width: 0.8;
  transition: cy 120ms linear;
}
.thermo-label {
  writing-mode: vertical-rl;
  font-size: 0.62rem;
  font-weight: 350;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pewter);
  align-self: center;
}

/* rocking mascot */
.mascot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mascot svg { width: 78px; height: 78px; flex: 0 0 78px; }
.mascot-rock {
  transform-origin: 28px 70px;
  animation: rock 16s ease-in-out infinite;
}
@keyframes rock {
  0%, 100% { transform: rotate(-2deg); }
  50%      { transform: rotate(2deg); }
}
.mascot-cap {
  font-size: 0.66rem;
  font-weight: 350;
  letter-spacing: 0.06em;
  color: var(--pewter);
  line-height: 1.3;
}

/* ============ MAIN CANVAS ============ */
.canvas {
  margin-left: var(--rail-w);
  max-width: 1080px;
  padding: 0 64px var(--ledger-h) 96px;
}

/* chapter spreads */
.spread {
  min-height: 100vh;
  padding-bottom: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.spread:first-child { padding-top: 40px; }

.seam {
  width: calc(100% + 96px);
  margin-left: -96px;
  height: 70px;
  display: block;
  margin-bottom: 24px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 800ms ease, transform 800ms ease;
}
.seam.in { opacity: 1; transform: translateY(0); }

.spread-grid {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 48px;
  align-items: start;
}

.prose { max-width: 64ch; }
.chapter-no {
  font-size: 0.72rem;
  font-weight: 350;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pewter);
  margin-bottom: 8px;
}
.chapter-title {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: clamp(3.2rem, 7vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--ink-navy);
  margin-left: -24px;          /* bleed into the rail's right edge */
  margin-bottom: 28px;
}
.prose p { margin-bottom: 1.1em; }
.prose p:last-child { margin-bottom: 0; }
.dropcap::first-letter {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 3.6em;
  line-height: 0.8;
  float: left;
  margin: 0.08em 0.08em 0 0;
  color: var(--slate);
}
.prose em { color: var(--ink-navy); font-style: italic; }

/* cartouche pull-quotes */
.cartouche {
  position: relative;
  margin: 1.6em 0 1.6em 8px;
  padding: 18px 22px;
  font-family: 'Commissioner', sans-serif;
  font-weight: 500;
  font-style: italic;
  font-size: 1.3125rem;
  line-height: 1.45;
  color: var(--ink-navy);
  background: rgba(43, 62, 102, 0.07);
  border: 1.5px solid rgba(43, 62, 102, 0.30);
  border-radius: 4px;
  max-width: 30ch;
}
.cart-a { transform: rotate(-1.8deg); }
.cart-b { transform: rotate(2.4deg); }
.cartouche::before {
  content: "";
  position: absolute;
  inset: -8px -10px;
  z-index: -1;
  background: radial-gradient(ellipse at 30% 40%, rgba(15,30,61,0.10), transparent 70%);
  border-radius: 50%;
}

.iso-list {
  list-style: none;
  margin: 1.2em 0;
}
.iso-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 0.5em;
}
.iso-list .bullet { flex: 0 0 22px; width: 22px; height: 22px; transform: translateY(4px); }
.iso-list .bullet svg { width: 100%; height: 100%; }

.colophon {
  margin-top: 2.4em;
  font-size: 0.82rem;
  font-weight: 350;
  letter-spacing: 0.06em;
  color: var(--pewter);
  text-transform: lowercase;
}
.colophon span {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.10em;
}

/* isometric vignettes */
.vignette {
  position: sticky;
  top: 90px;
}
.iso {
  width: 220px;
  height: 220px;
  display: block;
  margin-left: auto;
  filter: drop-shadow(0 2px 6px rgba(15, 30, 61, 0.10));
}
.iso.lift:hover {
  transform: translateY(-4px);
  box-shadow: none;
  filter: drop-shadow(0 8px 18px rgba(15, 30, 61, 0.18));
}
.vignette-cap {
  margin-top: 12px;
  font-size: 0.74rem;
  font-weight: 350;
  font-style: italic;
  line-height: 1.35;
  color: var(--pewter);
  text-align: right;
  max-width: 220px;
  margin-left: auto;
}

/* ============ LEDGER STRIP ============ */
.ledger {
  position: fixed;
  left: var(--rail-w);
  right: 0;
  bottom: 0;
  height: var(--ledger-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 28px 0 96px;
  background: linear-gradient(180deg, rgba(242,234,218,0.92), rgba(242,234,218,0.98));
  border-top: 1px solid rgba(43, 62, 102, 0.20);
  backdrop-filter: blur(2px);
  z-index: 20;
  font-size: 0.72rem;
  font-weight: 350;
  letter-spacing: 0.08em;
  color: var(--pewter);
}
.ledger-cell { white-space: nowrap; }
.ledger-mark {
  margin-left: auto;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0;
  color: var(--ink-navy);
}
.ledger-cog { width: 24px; height: 24px; flex: 0 0 24px; }
.ledger-cog svg { width: 100%; height: 100%; display: block; transform-origin: 12px 12.6px; }

/* ============ RESPONSIVE — tucked drawer ============ */
@media (max-width: 900px) {
  :root { --rail-w: 0px; }
  .rail {
    transform: translateX(-100%);
    transition: transform 280ms var(--lift-ease);
    width: 280px;
    box-shadow: 0 0 24px rgba(15, 30, 61, 0.25);
  }
  .rail:hover,
  .rail:focus-within { transform: translateX(0); }
  .rail::after {
    content: "≡ studio";
    position: absolute;
    right: -64px;
    top: 24px;
    transform: rotate(90deg);
    transform-origin: left top;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--slate);
    background: var(--paper);
    padding: 6px 12px;
    border: 1px solid rgba(43,62,102,0.2);
    border-top: none;
  }
  .canvas {
    margin-left: 0;
    padding: 0 24px var(--ledger-h) 28px;
  }
  .seam { width: calc(100% + 28px); margin-left: -28px; }
  .chapter-title { margin-left: 0; }
  .spread-grid { grid-template-columns: 1fr; gap: 24px; }
  .vignette { position: static; order: -1; }
  .iso { margin: 0 auto; }
  .vignette-cap { text-align: center; margin: 12px auto 0; }
  .ledger { left: 0; padding: 0 16px; gap: 14px; }
  .ledger-cell:nth-child(1) { display: none; }
}

@media (max-width: 520px) {
  .cartouche { max-width: 100%; transform: none; }
  .ledger { font-size: 0.62rem; }
}
