/* RAINBOW.ULTRA novel pages
   Rule of the book: the world is ink. The only colour on any page is a thread,
   and each thread keeps its canon colour (source/worldbuilding/THREAD_COLORS.md). */

:root {
    --ink: #000;
    --bone: #f1eee6;
    --tone: #8d8a84;
    --dim: #5a5852;

    /* thread colours */
    --amber: #f0a93b;        /* Grey */
    --bronze: #b5734a;       /* Lekai */
    --green: #58c98b;        /* Lo (green-violet) */
    --violet: #9a6be0;
    --blueviolet: #6e7bff;   /* Coco */
    --gold: #e9c44e;         /* Jessa (gold-violet), Her */
    --fire: #e8562a;         /* Her */
    --silver: #c9ced6;       /* Nydan */
    --slate: #7d8b99;        /* Axiom */
    --crimson: #c8324a;

    --display: 'Dela Gothic One', 'Arial Black', sans-serif;
    --text: 'Shippori Mincho', 'Hiragino Mincho ProN', Georgia, serif;
}

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

html { background: var(--ink); }

body {
    background: var(--ink);
    color: var(--bone);
    font-family: var(--text);
    font-size: 18px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; }
a:focus-visible { outline: 2px solid var(--bone); outline-offset: 4px; }

/* ---------- top bar ---------- */

.bar {
    max-width: 760px;
    margin: 0 auto;
    padding: 18px 16px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--tone);
}
.bar a { text-decoration: none; color: var(--bone); }
.bar a:hover { text-decoration: underline; }

/* ---------- the strip ---------- */

.strip {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 12px 120px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel {
    position: relative;
    overflow: hidden;
    border: 2px solid var(--bone);
    padding: clamp(22px, 6vw, 48px);
    display: flex;
    flex-direction: column;
    gap: 1.1em;
}
.panel.bleed { border-color: transparent; }
.panel.paper { background: var(--bone); color: var(--ink); }
.panel.tall { min-height: 78vh; justify-content: center; }
.panel.short { padding-block: clamp(16px, 4vw, 28px); }
.panel.end { justify-content: flex-end; }

.row { display: grid; gap: 14px; }
.row.two { grid-template-columns: 1fr 1fr; }
.row.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) {
    .row.three { grid-template-columns: 1fr; }
}

.row.three .panel { padding: clamp(14px, 3vw, 24px); }
.row.three .loud.m { font-size: clamp(1.1rem, 3.6vw, 1.7rem); }
@media (max-width: 560px) { .row.three .loud.m { font-size: 1.5rem; } }

.gap { height: clamp(40px, 12vh, 120px); }

/* screentone */
.tone {
    background-image: radial-gradient(circle, rgba(241, 238, 230, 0.26) 1px, transparent 1.5px);
    background-size: 7px 7px;
}
.tone-fade {
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 70%);
    mask-image: linear-gradient(180deg, transparent, #000 70%);
}

/* art layer: sits behind text inside a panel */
.art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.panel > :not(.art) { position: relative; }
svg.inline { display: block; width: 100%; height: auto; }

/* ---------- narration ---------- */

.cap { max-width: 34ch; font-size: 1.12rem; }
.cap.r { margin-left: auto; text-align: right; }
.cap.c { margin-inline: auto; text-align: center; }
.cap.wide { max-width: 46ch; }
.cap.box { background: var(--ink); border: 1.5px solid var(--bone); padding: 0.5em 0.9em; align-self: flex-start; }
.cap.small { font-size: 0.95rem; color: var(--tone); }
.paper .cap.small { color: var(--dim); }

.loud {
    font-family: var(--display);
    font-size: clamp(2rem, 9vw, 4.2rem);
    line-height: 1.08;
    letter-spacing: -0.01em;
    overflow-wrap: break-word;
}
.loud.xl { font-size: clamp(2.6rem, 13vw, 6.2rem); line-height: 0.98; }
.loud.m { font-size: clamp(1.5rem, 6vw, 2.6rem); }
.loud.c { text-align: center; }
.loud.r { text-align: right; }

/* ---------- speech ---------- */

.talk { gap: 1.5em; padding-inline: 0; }

.say {
    position: relative;
    max-width: min(74%, 30rem);
    background: var(--bone);
    color: var(--ink);
    padding: 0.7em 1.15em;
    border-radius: 1.5em;
    font-weight: 500;
    line-height: 1.5;
}
.say.l { align-self: flex-start; margin-left: 13%; }
.say.r { align-self: flex-end; margin-right: 13%; }

/* the speaker's thread runs from the balloon off the edge of the panel */
.say::before {
    content: "";
    position: absolute;
    top: 50%;
    height: 2px;
    width: 60vw;
    background: var(--tg, var(--bone));
}
.say.l::before { right: 100%; }
.say.r::before { left: 100%; }

.who {
    position: absolute;
    bottom: 100%;
    left: 1.2em;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--t, var(--bone));
    line-height: 1.9;
}
.say.r .who { left: auto; right: 1.2em; }

.grey   { --t: var(--amber);      --tg: var(--amber); }
.lekai  { --t: var(--bronze);     --tg: var(--bronze); }
.lo     { --t: var(--green);      --tg: linear-gradient(90deg, var(--violet), var(--green)); }
.coco   { --t: var(--blueviolet); --tg: var(--blueviolet); }
.nydan  { --t: var(--silver);     --tg: var(--silver); }
.axiom  { --t: var(--slate);      --tg: var(--slate); }

/* a voice on the phone */
.say.tel {
    background: var(--ink);
    color: var(--bone);
    border: 1.5px dashed var(--silver);
    border-radius: 3px;
}
.say.tel::before { height: 1px; }

/* a text message */
.msg {
    align-self: flex-start;
    max-width: 30ch;
    border: 1.5px solid var(--amber);
    border-radius: 14px 14px 14px 2px;
    padding: 0.5em 0.9em;
    font-size: 1rem;
}

/* ---------- threads (svg) ---------- */

.th { fill: none; stroke-width: 2; stroke-linecap: round; }
.th.thin { stroke-width: 1; }
.s-amber { stroke: var(--amber); }
.s-bronze { stroke: var(--bronze); }
.s-green { stroke: var(--green); }
.s-violet { stroke: var(--violet); }
.s-coco { stroke: var(--blueviolet); }
.s-gold { stroke: var(--gold); }
.s-silver { stroke: var(--silver); }
.s-slate { stroke: var(--slate); }
.s-crimson { stroke: var(--crimson); }
.s-bone { stroke: var(--bone); }
.s-tone { stroke: var(--tone); }
.f-bone { fill: var(--bone); }
.f-tone { fill: var(--tone); }
.f-ink { fill: var(--ink); }

.maplabel { font-family: var(--text); font-size: 13px; fill: var(--tone); }

/* ---------- crew cards ---------- */

.card { padding: 0 20px 20px; gap: 0.5em; }
.card svg.art { position: relative; inset: auto; width: calc(100% + 40px); margin: 0 -20px auto; height: 130px; flex: none; }
.card .name { font-family: var(--display); font-size: clamp(1.6rem, 6vw, 2.4rem); line-height: 1; }
.card .cap { font-size: 0.98rem; max-width: none; }

/* ---------- eight billion lights ---------- */

.lights { position: relative; }
.lights .sky {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    width: 100vw;
    margin-left: calc(50% - 50vw);
}
.lights canvas { display: block; width: 100%; height: 100%; }
.lights .lines {
    position: relative;
    margin-top: -100vh;
    margin-top: -100svh;
    padding: 55vh 16px 60vh;
    text-align: center;
}
.lights .lines > * { margin: 0 auto 46vh; max-width: 30ch; text-shadow: 0 0 14px #000, 0 0 4px #000; }
.lights .lines > .loud { max-width: none; }
.lights .lines > .close { margin-bottom: 9vh; }
.lights .lines > :last-child { margin-bottom: 0; }

/* ---------- cover / index ---------- */

.cover {
    max-width: 760px;
    margin: 0 auto;
    padding: 12vh 16px 100px;
}
.cover h1 {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(2.6rem, 13vw, 6.4rem);
    line-height: 0.95;
    letter-spacing: -0.02em;
}
.cover .thread { display: block; width: 100%; height: 90px; margin: 28px 0; }
.cover .pitch { max-width: 40ch; font-size: 1.15rem; }
.chapters { list-style: none; margin-top: 64px; border-top: 2px solid var(--bone); }
.chapters li { border-bottom: 1px solid var(--dim); }
.chapters a, .chapters .soon {
    display: grid;
    grid-template-columns: 3ch 1fr auto;
    gap: 16px;
    align-items: baseline;
    padding: 18px 4px;
    text-decoration: none;
}
.chapters .t { font-family: var(--display); font-size: 1.5rem; }
.chapters .d { color: var(--tone); font-size: 0.9rem; }
.chapters .soon { color: var(--dim); }
.chapters a:hover .t { text-decoration: underline; text-underline-offset: 6px; }
.note { margin-top: 40px; color: var(--tone); font-size: 0.9rem; max-width: 52ch; }

.next {
    display: inline-block;
    border: 2px solid var(--bone);
    padding: 0.6em 1.2em;
    text-decoration: none;
    font-weight: 700;
}
.next:hover { background: var(--bone); color: var(--ink); }

/* ================= manga grammar =================
   Borrowed from how manga paces a page: silent panels that look at one detail each,
   weather, lines that move with the subject, lines that close in on a word,
   slanted gutters when things speed up. Still no people drawn. */

.art[data-art] { color: var(--bone); }
.paper .art[data-art] { color: var(--ink); }
.defs { position: absolute; width: 0; height: 0; }

/* silent detail panels */
.row.four { grid-template-columns: repeat(4, 1fr); }
.row.stills { gap: 8px; }
.still { padding: 0; aspect-ratio: 4 / 5; }
.still svg, svg.ink {
    fill: none;
    stroke: var(--bone);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.still svg { display: block; width: 100%; height: 100%; }
.still .fb, svg.ink .fb { fill: var(--bone); stroke: none; }
.still .fk, svg.ink .fk { fill: var(--ink); }
.still .ft, svg.ink .ft { fill: url(#dots); stroke: none; }
.still .thin, svg.ink .thin { stroke-width: 1; }
.still .dim, svg.ink .dim { stroke: var(--dim); }
.still.cap-in { aspect-ratio: auto; padding: 0 0 12px; gap: 0.3em; }
.still.cap-in svg { height: auto; aspect-ratio: 4 / 3; }
.still.cap-in .cap { padding-inline: 12px; font-size: 0.95rem; }

/* a panel that runs off both edges of the screen */
.panel.wide {
    align-self: center;
    flex: none;
    width: 100vw;
    border-left: 0;
    border-right: 0;
    padding-inline: max(22px, calc(50vw - 358px));
}

/* fog: screentone that drifts */
.fog {
    background-image: radial-gradient(circle, rgba(241, 238, 230, 0.5) 1px, transparent 1.6px);
    background-size: 6px 6px;
    -webkit-mask-image:
        radial-gradient(ellipse 34% 20% at 20% 72%, #000, transparent 72%),
        radial-gradient(ellipse 40% 16% at 72% 40%, #000, transparent 72%),
        radial-gradient(ellipse 30% 22% at 50% 96%, #000, transparent 72%),
        radial-gradient(ellipse 26% 12% at 96% 80%, #000, transparent 72%);
    mask-image:
        radial-gradient(ellipse 34% 20% at 20% 72%, #000, transparent 72%),
        radial-gradient(ellipse 40% 16% at 72% 40%, #000, transparent 72%),
        radial-gradient(ellipse 30% 22% at 50% 96%, #000, transparent 72%),
        radial-gradient(ellipse 26% 12% at 96% 80%, #000, transparent 72%);
    -webkit-mask-size: 200% 100%;
    mask-size: 200% 100%;
    animation: drift 46s linear infinite alternate;
}
@keyframes drift {
    from { -webkit-mask-position: 0% 0; mask-position: 0% 0; }
    to { -webkit-mask-position: 100% 0; mask-position: 100% 0; }
}
@media (prefers-reduced-motion: reduce) { .fog { animation: none; } }

/* dread: lines falling from the top of the panel */
.gloom::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(90deg, rgba(241, 238, 230, 0.5) 0 1px, transparent 1px 7px, rgba(241, 238, 230, 0.25) 7px 8px, transparent 8px 17px);
    -webkit-mask-image: linear-gradient(180deg, #000, transparent 62%);
    mask-image: linear-gradient(180deg, #000, transparent 62%);
}

/* a raised voice */
.say.shout {
    background: transparent;
    isolation: isolate;
    font-family: var(--display);
    font-weight: 400;
    font-size: 1.08em;
    line-height: 1.35;
    padding: 1.1em 1.6em;
}
.say.shout::after {
    content: "";
    position: absolute;
    inset: -0.5em -0.7em;
    z-index: -1;
    background: var(--bone);
    clip-path: polygon(99.5% 50.0%, 90.0% 59.9%, 98.0% 75.2%, 87.1% 82.9%, 82.5% 97.1%, 65.2% 90.1%, 56.0% 99.4%, 45.1% 90.0%, 31.5% 98.7%, 23.8% 87.9%, 4.0% 90.8%, 10.4% 70.8%, 0.9% 62.1%, 7.7% 50.0%, 0.9% 37.9%, 9.3% 28.6%, 4.0% 9.2%, 22.5% 10.1%, 31.5% 1.3%, 45.1% 9.8%, 56.0% 0.6%, 65.4% 9.5%, 82.5% 2.9%, 87.6% 16.7%, 98.0% 24.8%, 89.8% 40.2%);
}
.say.shout::before { z-index: -2; }
.say.shout .who { bottom: calc(100% + 0.5em); }

.lean { transform: skewX(-9deg); }

/* slanted gutters */
.cut {
    --s: clamp(20px, 7vw, 52px);
    border: 0;
    background: var(--bone);
    -webkit-clip-path: var(--clip);
    clip-path: var(--clip);
}
.cut::before {
    content: "";
    position: absolute;
    inset: 2px;
    background: var(--ink);
    -webkit-clip-path: var(--clip);
    clip-path: var(--clip);
}
.cut.paper::before { display: none; }
.cut-b { --clip: polygon(0 0, 100% 0, 100% calc(100% - var(--s)), 0 100%); padding-bottom: calc(var(--s) + 22px); }
.cut-t { --clip: polygon(0 var(--s), 100% 0, 100% 100%, 0 100%); margin-top: calc(-1 * var(--s)); padding-top: calc(var(--s) + 22px); }
.cut-b2 { --clip: polygon(0 0, 100% 0, 100% 100%, 0 calc(100% - var(--s))); padding-bottom: calc(var(--s) + 22px); }
.cut-t2 { --clip: polygon(0 0, 100% var(--s), 100% 100%, 0 100%); margin-top: calc(-1 * var(--s)); padding-top: calc(var(--s) + 22px); }
@media (max-width: 560px) {
    .row.three.stills { grid-template-columns: repeat(3, 1fr); }
    .row.stills { gap: 6px; }
    .still.cap-in .cap { padding-inline: 8px; font-size: 0.82rem; line-height: 1.4; }
}

/* display type sitting on top of line work keeps a halo of its own ground */
.over { -webkit-text-stroke: 0.32em var(--ink); paint-order: stroke fill; }
.paper .over { -webkit-text-stroke-color: var(--bone); }

/* ---- added for the January-text CH01 ---- */
:root { --indigo: #5146d9; }           /* bass */
.s-indigo { stroke: var(--indigo); }
.s-dim { stroke: var(--dim); }

/* ---- futures: branches grow as you scroll (same frame as the lights) ---- */
.futures { position: relative; }
.futures .sky { position: sticky; top: 0; height: 100vh; height: 100svh; width: 100vw; margin-left: calc(50% - 50vw); }
.futures canvas { display: block; width: 100%; height: 100%; }
.futures .lines { position: relative; margin-top: -100vh; margin-top: -100svh; padding: 70vh 16px 70vh; text-align: center; }
.futures .lines > * { margin: 0 auto 60vh; max-width: 30ch; text-shadow: 0 0 14px #000, 0 0 6px #000, 0 0 2px #000; }
.futures .lines > .loud { max-width: none; }
.futures .lines > :last-child { margin-bottom: 0; }

/* ---- strings: taut threads that snap as you scroll (same frame as the lights) ---- */
.strings { position: relative; }
.strings .sky { position: sticky; top: 0; height: 100vh; height: 100svh; width: 100vw; margin-left: calc(50% - 50vw); }
.strings canvas { display: block; width: 100%; height: 100%; }
.strings .lines { position: relative; margin-top: -100vh; margin-top: -100svh; padding: 60vh 16px 70vh; text-align: center; }
.strings .lines > * { margin: 0 auto 55vh; max-width: 30ch; text-shadow: 0 0 14px #000, 0 0 6px #000, 0 0 2px #000; }
.strings .lines > .loud { max-width: none; }
.strings .lines > :last-child { margin-bottom: 0; }

/* ---- subscribe form (also inline in read.html) ---- */
.sub form { display: flex; flex-direction: column; gap: 0.9em; }
.sub label { font-size: 1.12rem; max-width: 34ch; }
.sub .fields { display: flex; flex-wrap: wrap; gap: 10px; }
.sub .fields[hidden] { display: none; }
.sub input[type="email"] {
    flex: 1 1 14rem;
    min-width: 0;
    background: var(--ink);
    color: var(--bone);
    border: 1.5px solid var(--bone);
    border-radius: 0;
    padding: 0.7em 0.9em;
    font: inherit;
}
.sub input[type="email"]::placeholder { color: var(--tone); }
.sub button {
    background: var(--bone);
    color: var(--ink);
    border: 1.5px solid var(--bone);
    border-radius: 0;
    padding: 0.7em 1.3em;
    font-family: var(--display);
    font-size: 1rem;
    cursor: pointer;
}
.sub button:hover { background: var(--ink); color: var(--bone); }
.sub button:disabled { opacity: 0.5; cursor: default; }
.sub input:focus-visible, .sub button:focus-visible { outline: 2px solid var(--bone); outline-offset: 3px; }
.sub .trap { position: absolute; left: -9999px; }
.sub .status { font-size: 0.95rem; color: var(--tone); min-height: 1.7em; }

/* ---- novel home ---- */
.cover .start { margin-top: 36px; }
.cover .label { margin-top: 64px; font-family: var(--text); font-weight: 500; font-size: 0.85rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--tone); }
.cover .label + .chapters { margin-top: 12px; }
.cover .sub { margin-top: 56px; }
