/* ============================================================
   red-book.css: /red-book/, the Lord of the Rings terminal.
   Sister page to /citadel/, /grail-diary/ and the rest: vellum
   and gold leaf instead of glass. The book lies open in the
   study at Bag End, every room on the site is a waypoint on
   one road, and the page ends at the Grey Havens.

   THE RING IS A SWITCH, AND IT RE-TINTS THE PAGE. Putting it
   on moves one token, --warm, from firelight to the cold of
   the wraith-world; every surface below paints with it, so a
   single class on <body> turns the whole page without a
   second set of rules. The inscription lights at the same
   time, because that is the one thing the Ring actually does
   on its own.
   ============================================================ */

/* these pages load no shared stylesheet, so they carry their own reset */
* { margin: 0; padding: 0; box-sizing: border-box; }
a { color: inherit; text-decoration: none; }
button { font: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }
html.smooth { scroll-behavior: smooth; }   /* added after load, so back/forward restoration is not animated */

.rb {
  --iw-a: #d9b45f;   /* the shared world button, interface-world.css */
  --iw-bg: #140f09;
  --titl:  "Cinzel", Georgia, serif;
  --unic:  "Cormorant Unicase", "Cinzel", Georgia, serif;   /* the plate's lettering */
  --body:  "EB Garamond", Georgia, serif;
  --sans:  "Cinzel", Georgia, serif;   /* interface-world.css reads this */
  --mono:  "EB Garamond", Georgia, serif;

  /* the one token the Ring moves: everything warm on the page is mixed
     from it, so one class re-tints the lot */
  --warm:  #d9b45f;
  --dark:   #140f09;
  --dark-2: #0b0806;
  --vellum: #e6d8b4;
  --vellum-2: #d2bf92;
  --ink:    #342a18;
  --ink-2:  #5f4d2c;
  --ink-3:  #87714a;
  --gold:   #d9b45f;
  --cream:  #f1e6c8;
  --dim:    #c6b894;
  --mute:   #a0916e;
  --line:   rgba(217, 180, 95, 0.22);
  --ease:   cubic-bezier(.16, 1, .3, 1);

  background: var(--dark);
  color: var(--cream);
  font-family: var(--body);
  font-size: 1.07rem;
  min-height: 100vh;
  padding-bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
  transition: background .9s var(--ease);
}
/* the wraith-world: the warmth drains out of the one token and the page
   follows it, because nothing below names a warm color of its own */
.rb.is-worn {
  --warm:  #9fb6c9;
  --gold:  #cfe0ee;
  --cream: #e8f1f8;
  --dim:   #b6c6d4;
  --mute:  #8da0b0;
  --line:  rgba(207, 224, 238, 0.26);
  --vellum: #cfd8e0;
  --vellum-2: #b3c0cb;
  --ink:   #1b222a;
  --ink-2: #39485a;
  --ink-3: #64788c;
  background: #070a0d;
}

/* ───────────── the study ───────────── */
.rb-study { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.rb-study > span { position: absolute; inset: 0; }
.rb-wall {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' seed='9'/%3E%3CfeColorMatrix values='0 0 0 0 0.18 0 0 0 0 0.13 0 0 0 0 0.07 0 0 0 0.42 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23w)'/%3E%3C/svg%3E"),
    linear-gradient(165deg, #1b1510, #0f0b07 60%, #16100a);
}
/* firelight from the hearth on the left, and the dark closing in at the edges */
.rb-fire {
  background:
    radial-gradient(48% 42% at 8% 18%, color-mix(in srgb, var(--warm) 20%, transparent), transparent 72%),
    radial-gradient(120% 92% at 50% 48%, transparent 46%, rgba(0, 0, 0, .72));
  animation: rb-flicker 7s ease-in-out infinite;
  transition: background .9s var(--ease);
}
@keyframes rb-flicker { 0%, 100% { opacity: 1; } 42% { opacity: .9; } 68% { opacity: .96; } }
.rb-motes i {
  position: absolute; left: var(--x); top: var(--y);
  width: 3px; height: 3px; border-radius: 50%;
  background: color-mix(in srgb, var(--warm) 60%, #fff);
  box-shadow: 0 0 7px color-mix(in srgb, var(--warm) 70%, transparent);
  animation: rb-rise var(--t) ease-in-out var(--d) infinite;
}
@keyframes rb-rise {
  0%, 100% { transform: translate(0, 0); opacity: .16; }
  50%      { transform: translate(-22px, -40px); opacity: .6; }
}

.rb-blocks { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ───────────── the header ───────────── */
.rb-top {
  position: sticky; top: 0; z-index: 7;
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  padding: 0.7rem clamp(0.9rem, 3vw, 2rem);
  background: linear-gradient(180deg, rgba(11, 8, 6, .95), rgba(11, 8, 6, .7));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  font-family: var(--titl);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
}
.rb-exit, .rb-oath-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.78rem; border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  background: color-mix(in srgb, var(--warm) 6%, transparent);
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
  cursor: pointer;
}
.rb-exit svg, .rb-oath-btn svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.rb-exit:hover, .rb-exit:focus-visible,
.rb-oath-btn:hover, .rb-oath-btn:focus-visible {
  color: var(--gold); border-color: var(--gold);
  background: color-mix(in srgb, var(--warm) 14%, transparent);
}
.rb-oath-btn[aria-pressed="true"] { color: #070a0d; background: var(--gold); border-color: var(--gold); }
.rb-top-mid { color: var(--mute); flex: 1 1 auto; min-width: 0; }
.rb-top-r { display: inline-flex; align-items: center; gap: 0.7rem; color: var(--mute); }

/* ───────────── the layout ───────────── */
.rb-main {
  position: relative; z-index: 1;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(1.4rem, 4vw, 3rem) clamp(0.9rem, 3vw, 2rem) 0;
  display: grid; gap: clamp(2.2rem, 5vw, 3.6rem);
}

/* ───────────── the title plate ───────────── */
.rb-plate {
  position: relative;
  padding: clamp(1.5rem, 4vw, 3rem);
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
  background:
    radial-gradient(40px 30px at 16% 14%, color-mix(in srgb, var(--ink-3) 16%, transparent), transparent 70%),
    radial-gradient(32px 24px at 84% 80%, color-mix(in srgb, var(--ink-3) 14%, transparent), transparent 70%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='v'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='4' seed='4'/%3E%3CfeColorMatrix values='0 0 0 0 0.4 0 0 0 0 0.32 0 0 0 0 0.16 0 0 0 0.15 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23v)'/%3E%3C/svg%3E"),
    linear-gradient(168deg, var(--vellum), var(--vellum-2));
  box-shadow: 0 36px 80px rgba(0, 0, 0, .6);
  /* the tooled border of a bound cover, drawn rather than pictured */
  outline: 1px solid color-mix(in srgb, var(--warm) 46%, transparent);
  outline-offset: -14px;
  transition: background .9s var(--ease);
}

/* the Ring */
.rb-ring-stage { display: grid; place-items: center; margin-bottom: 1.1rem; }
.rb-ring { width: min(240px, 62vw); height: auto; }
.rb-band, .rb-band-in {
  fill: none; stroke: url(#rbGold); stroke-width: 17;
}
.rb-band-in { stroke-width: 4; opacity: .62; }
/* the inscription: dark on the band until the Ring is worn, then alight */
.rb-script path {
  fill: none; stroke: color-mix(in srgb, var(--ink) 60%, transparent);
  stroke-width: 2; stroke-linecap: round;
  transition: stroke .7s var(--ease), filter .7s var(--ease);
}
.rb.is-worn .rb-script path {
  stroke: #ffb24a;
  filter: drop-shadow(0 0 6px rgba(255, 150, 40, .95));
}
/* worn, the band itself cools to the metal of the wraith-world */
.rb.is-worn .rb-band, .rb.is-worn .rb-band-in { stroke: #b9cad8; }

.rb-kicker {
  font-family: var(--titl); font-size: 0.72rem; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 0.6rem;
}
.rb-title {
  font-family: var(--unic); font-weight: 700;
  font-size: clamp(1.7rem, 5.2vw, 3rem); line-height: 1.08;
  color: var(--ink); margin-bottom: 0.8rem;
}
.rb-sub {
  font-size: 1.04rem; line-height: 1.64; color: var(--ink-2);
  max-width: 62ch; margin: 0 auto 1.1rem;
}
/* the verse: the one line the Ring changes */
.rb-oath-line {
  font-family: var(--titl); font-size: clamp(0.92rem, 2.3vw, 1.08rem);
  letter-spacing: 0.04em; color: var(--ink);
  padding: 0.7rem 1rem; margin: 0 auto 1.4rem;
  max-width: 54ch;
  border-top: 1px solid color-mix(in srgb, var(--warm) 40%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--warm) 40%, transparent);
}
/* the particulars. Each label sits directly above its value, so a row never
   reads as "Kept by | Of | Office" across three columns: the pairs stay
   pairs however many fit on a line. */
.rb-plate-meta dl {
  display: grid; gap: 0.9rem 1.4rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  text-align: left; max-width: 760px; margin: 0 auto;
}
.rb-plate-meta > dl > div {
  display: grid; gap: 0.12rem; align-content: start;
  padding-left: 0.6rem;
  border-left: 1px solid color-mix(in srgb, var(--warm) 34%, transparent);
}
.rb-plate-meta dt {
  font-family: var(--titl); font-size: 0.66rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-3);
}
.rb-plate-meta dd { font-size: 0.97rem; color: var(--ink); }

/* ───────────── headings ───────────── */
.rb-h {
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap;
  font-family: var(--titl); font-weight: 600;
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--gold); margin-bottom: 1.2rem;
}
.rb-h--sm { font-size: clamp(1.1rem, 2.4vw, 1.4rem); }
.rb-h span {
  font-family: var(--body); font-weight: 400; font-size: 0.86rem;
  letter-spacing: 0.04em; color: var(--mute);
}
.rb-think { width: 22px; height: 22px; flex: 0 0 auto; }

/* ───────────── the road ───────────── */
/* one continuous line down the left, with every waypoint hung off it: the
   road is a pseudo-element on the list, so no extra markup carries it */
.rb-stations { position: relative; display: grid; gap: 0.75rem; padding-left: 2.1rem; }
.rb-stations::before {
  content: ""; position: absolute; top: 0.9rem; bottom: 0.9rem; left: 0.72rem;
  width: 2px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--warm) 46%, transparent) 8%, color-mix(in srgb, var(--warm) 46%, transparent) 92%, transparent);
}
.rb-stations li { opacity: 0; animation: rb-walk .5s var(--ease) forwards; animation-delay: calc(var(--i) * 0.06s); }
@keyframes rb-walk { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }

.rb-station {
  position: relative; display: grid; grid-template-columns: auto 1fr;
  gap: 0.85rem; align-items: start;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: color-mix(in srgb, var(--warm) 4%, rgba(0, 0, 0, .2));
  transition: border-color .22s var(--ease), background .22s var(--ease), transform .22s var(--ease);
}
.rb-station:hover, .rb-station:focus-visible {
  border-color: var(--c, var(--gold));
  background: color-mix(in srgb, var(--warm) 10%, rgba(0, 0, 0, .2));
  transform: translateX(4px);
}
/* the waymark on the road, which is also the device for that room */
.rb-mark {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: 42px; height: 42px; margin-left: -2.72rem;
  border: 1px solid var(--c, var(--gold)); border-radius: 50%;
  background: var(--dark);
  color: var(--c, var(--gold));
}
.rb-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.rb-body { display: grid; gap: 0.12rem; min-width: 0; }
.rb-k {
  font-family: var(--titl); font-size: 0.66rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--c, var(--gold));
}
.rb-n { font-family: var(--titl); font-weight: 600; font-size: 1.1rem; color: var(--cream); }
.rb-real { font-size: 0.82rem; font-style: italic; color: var(--mute); }
.rb-f { font-size: 0.95rem; line-height: 1.5; color: var(--dim); margin-top: 0.1rem; }
.rb-station--own { background: color-mix(in srgb, var(--warm) 9%, rgba(0, 0, 0, .2)); }
.rb-station--calm .rb-k { color: #4fbf85; }

/* ───────────── two panels ───────────── */
.rb-cols { display: grid; gap: clamp(1.2rem, 3vw, 2rem); }
@media (min-width: 900px) { .rb-cols { grid-template-columns: 1fr 1fr; align-items: start; } }
.rb-panel {
  padding: clamp(1.1rem, 3vw, 1.8rem);
  border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(170deg, color-mix(in srgb, var(--warm) 5%, transparent), rgba(0, 0, 0, .22));
}

/* the Fellowship */
.rb-fellow { display: grid; gap: 0.85rem; }
.rb-fellow li { display: grid; grid-template-columns: auto 1fr; gap: 0.8rem; align-items: start; }
.rb-f-n {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid color-mix(in srgb, var(--warm) 50%, transparent);
  border-radius: 50%;
  font-family: var(--titl); font-size: 0.82rem; color: var(--gold);
  background: color-mix(in srgb, var(--warm) 7%, transparent);
}
.rb-fellow b { font-family: var(--titl); font-weight: 600; font-size: 1.02rem; color: var(--cream); }
.rb-fellow p { font-size: 0.93rem; line-height: 1.52; color: var(--dim); margin-top: 0.14rem; }
/* the ninth is not written yet, so its mark is open */
.rb-fellow-last .rb-f-n { border-style: dashed; color: var(--mute); }

/* the seeing-stones */
.rb-stones { display: grid; gap: 0.5rem; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.rb-stone {
  display: grid; grid-template-columns: auto 1fr; gap: 0.6rem;
  align-items: center;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line); border-radius: 7px;
  background: color-mix(in srgb, var(--warm) 4%, transparent);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.rb-stone b, .rb-stone i { grid-column: 2; }
.rb-stone:hover, .rb-stone:focus-visible {
  border-color: var(--w, var(--gold));
  background: color-mix(in srgb, var(--w, var(--gold)) 12%, transparent);
  transform: translateY(-2px);
}
/* the stone itself: a dark sphere with one point of light turning in it */
.rb-orb {
  grid-row: span 2;
  width: 26px; height: 26px; border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, color-mix(in srgb, var(--w, var(--gold)) 85%, #fff), transparent 42%),
    radial-gradient(circle at 60% 66%, color-mix(in srgb, var(--w, var(--gold)) 40%, transparent), transparent 55%),
    #0a0a0e;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, .8), 0 0 10px color-mix(in srgb, var(--w, var(--gold)) 30%, transparent);
}
.rb-stone b { font-family: var(--titl); font-weight: 600; font-size: 0.95rem; color: var(--cream); }
.rb-stone i { font-style: italic; font-size: 0.8rem; color: var(--mute); }

/* ───────────── the ending ───────────── */
.rb-end-btn {
  justify-self: center;
  padding: 0.75rem 1.6rem; border-radius: 999px;
  border: 1px solid var(--gold); color: var(--gold);
  background: color-mix(in srgb, var(--warm) 8%, transparent);
  font-family: var(--titl); font-size: 1rem; letter-spacing: 0.05em;
  cursor: pointer;
  transition: background .25s var(--ease), color .25s var(--ease), transform .25s var(--ease);
}
.rb-end-btn:hover, .rb-end-btn:focus-visible { background: var(--gold); color: var(--dark); transform: translateY(-2px); }

.rb-done {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  padding: 1.5rem;
  /* the light over the water in the west, which is the whole image */
  background:
    radial-gradient(70% 50% at 50% 100%, rgba(240, 232, 206, .16), transparent 70%),
    radial-gradient(90% 70% at 50% 42%, rgba(20, 15, 9, .96), rgba(6, 5, 4, .99));
  opacity: 0; visibility: hidden;
  transition: opacity .8s var(--ease), visibility .8s;
  text-align: center;
}
.rb.is-sailed .rb-done { opacity: 1; visibility: visible; }
.rb-done-orb { width: 96px; height: 96px; margin: 0 auto 1rem; }
.rb-done-k {
  font-family: var(--titl); font-size: 0.74rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--mute); margin-bottom: 0.4rem;
}
.rb-done-t {
  font-family: var(--unic); font-size: clamp(1.5rem, 5vw, 2.4rem);
  color: var(--gold); margin-bottom: 1.2rem;
}
.rb-done a {
  display: inline-block; padding: 0.6rem 1.3rem; border-radius: 999px;
  border: 1px solid var(--gold); color: var(--gold);
  font-family: var(--titl); font-size: 0.84rem; letter-spacing: 0.06em;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.rb-done a:hover, .rb-done a:focus-visible { background: var(--gold); color: var(--dark); }

/* ───────────── the world button at the foot ───────────── */
.rb-main > .iw--foot { justify-self: center; margin-bottom: 2rem; }

/* ───────────── narrow ───────────── */
/* The road keeps its rail and its waymarks on a phone; only the header's
   middle line goes, and the page keeps every word of its content. */
@media (max-width: 620px) {
  .rb-plate-meta > dl > div { grid-template-columns: 1fr; gap: 0.1rem; }
  .rb-top-mid { display: none; }
  .rb-stations { padding-left: 1.7rem; }
  .rb-mark { width: 36px; height: 36px; margin-left: -2.3rem; }
  .rb-stations::before { left: 0.6rem; }
}

/* ───────────── reduced motion ───────────── */
/* The flicker, the motes and the walk-in are decoration over a page that is
   already complete. Stopped, every waypoint is simply in place. */
@media (prefers-reduced-motion: reduce) {
  .rb-motes i { animation: none; opacity: .32; }
  .rb-fire { animation: none; }
  .rb-stations li { animation: none; opacity: 1; }
  .rb-station:hover, .rb-station:focus-visible { transform: none; }
  .rb-stone:hover, .rb-end-btn:hover { transform: none; }
}
