/* chronicle — what the dream remembers
 *
 * The page is a core log: time down the left, the dream's own colour laid
 * down as sediment in the middle (one row per 30 s, newest on top, older
 * days compacted), and the eras written up beside it.
 */

body:has(.chronicle-page) .video-bg { display: none; }
body:has(.chronicle-page) { background: #050505; }
body:has(.chronicle-page) .logo-container,
body:has(.chronicle-page) footer { filter: invert(1); }

.chronicle-page {
    --ink: #e8e2d4;
    --ink-soft: #a39d90;
    --ink-faint: #5d5850;
    --rule: rgba(232, 226, 212, 0.07);
    --paper: #070707;
    --core-w: 340px;
    --depth-w: 104px;
    --gutter: 28px;
    color: var(--ink);
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 20px 4rem;
    position: relative;
}

.chronicle-page ::selection { background: rgba(232, 226, 212, 0.25); }

/* ------------------------------------------------------------------ head */

.chr-head { text-align: center; margin: 0 auto 2.25rem; }

.chr-title {
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: 0.34em;
    text-transform: lowercase;
    margin: 0 0 0.35rem;
    padding-left: 0.34em; /* optically centre the tracking */
    color: var(--ink);
}

.chr-sub {
    margin: 0;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
}

.chr-status {
    margin: 1.4rem auto 0;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    display: inline-flex;
    align-items: center;
    gap: 0.6em;
    min-height: 1.2em;
}

.chr-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink-faint);
    flex: none;
}
.chr-status.live .chr-dot {
    background: #d9c79a;
    box-shadow: 0 0 0 0 rgba(217, 199, 154, 0.6);
    animation: chr-breathe 2.6s ease-out infinite;
}
@keyframes chr-breathe {
    0% { box-shadow: 0 0 0 0 rgba(217, 199, 154, 0.55); }
    80%, 100% { box-shadow: 0 0 0 9px rgba(217, 199, 154, 0); }
}

.chr-legend {
    max-width: 34rem;
    margin: 0.9rem auto 0;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--ink-faint);
    letter-spacing: 0.02em;
}

/* ------------------------------------------------------------ the sheet */

.chr-sheet {
    position: relative;
    display: grid;
    grid-template-columns: var(--depth-w) var(--core-w) minmax(0, 1fr);
    column-gap: var(--gutter);
}

.chr-colhead {
    font-size: 0.68rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ink-faint);
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 0;
}
.chr-colhead.depth { text-align: right; }

/* the deposit: where new sediment arrives */
.chr-deposit {
    grid-column: 2;
    position: relative;
    align-self: stretch;
    min-height: 118px;
    padding-top: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.chr-deposit a {
    display: block;
    width: 168px;
    aspect-ratio: 2 / 1;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(232, 226, 212, 0.12), 0 8px 30px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 2;
}
.chr-deposit img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chr-deposit .chr-fall {
    width: 1px;
    flex: 1 1 auto;
    min-height: 24px;
    background: linear-gradient(to bottom, rgba(232, 226, 212, 0.55), rgba(232, 226, 212, 0.08));
    margin-top: 2px;
    position: relative;
}
/* a mote of colour falling from the frame into the core */
.chr-status.live ~ * .chr-fall::after, .chr-deposit.live .chr-fall::after {
    content: "";
    position: absolute;
    left: -2px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--mote, #d9c79a);
    box-shadow: 0 0 8px var(--mote, #d9c79a);
    animation: chr-fall 3.2s cubic-bezier(0.5, 0, 0.8, 0.4) infinite;
}
@keyframes chr-fall {
    0% { top: 0; opacity: 0; }
    12% { opacity: 1; }
    88% { opacity: 1; }
    100% { top: calc(100% - 5px); opacity: 0; }
}
.chr-deposit-when {
    position: absolute;
    left: calc(50% + 96px);
    bottom: 38px;
    font-size: 0.72rem;
    color: var(--ink-soft);
    white-space: nowrap;
    letter-spacing: 0.04em;
}
.chr-deposit-when b { color: var(--ink); font-weight: 400; }

/* ------------------------------------------------------------- the log */

.chr-log {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: var(--depth-w) var(--core-w) minmax(0, 1fr);
    column-gap: var(--gutter);
    position: relative;
}

.chr-depth, .chr-eras { position: relative; }

.chr-core {
    position: relative;
    border-radius: 2px;
    background:
        repeating-linear-gradient(135deg, #0d0d0d 0 3px, #161616 3px 6px); /* no record */
    box-shadow: 0 0 0 1px rgba(232, 226, 212, 0.08), 0 30px 80px rgba(0, 0, 0, 0.9);
    cursor: crosshair;
    touch-action: pan-y;
}

.chr-tiles { position: relative; }

.chr-tile {
    position: absolute;
    left: 0;
    right: 0;
    overflow: hidden;
}
.chr-tile img {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    /* newest row on top: the tile's last row (end of the hour) goes up */
    transform: scaleY(-1);
    image-rendering: auto;
    display: block;
    filter: saturate(1.08) contrast(1.04);
}
.chr-tile.crisp img { image-rendering: pixelated; }

/* a missing stretch of core: long silences are shown broken, not to scale */
.chr-gap {
    position: absolute;
    left: -6px;
    right: -6px;
    background: var(--paper);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chr-gap::before, .chr-gap::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 7px;
    background: var(--paper);
}
.chr-gap::before {
    top: -6px;
    clip-path: polygon(0 100%, 4% 20%, 11% 80%, 19% 0, 27% 70%, 36% 30%, 44% 90%, 53% 10%, 61% 60%, 70% 0, 78% 80%, 86% 20%, 93% 70%, 100% 30%, 100% 100%);
}
.chr-gap::after {
    bottom: -6px;
    clip-path: polygon(0 0, 5% 70%, 13% 10%, 21% 90%, 30% 30%, 38% 80%, 47% 0, 55% 60%, 64% 20%, 72% 100%, 81% 40%, 89% 90%, 96% 10%, 100% 60%, 100% 0);
}

/* the core is a cylinder: light from the upper left, grain on top */
.chr-core-shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 2px;
    background:
        linear-gradient(90deg,
            rgba(0, 0, 0, 0.62) 0%,
            rgba(0, 0, 0, 0.18) 9%,
            rgba(255, 250, 235, 0.10) 27%,
            rgba(255, 250, 235, 0.03) 42%,
            rgba(0, 0, 0, 0.00) 58%,
            rgba(0, 0, 0, 0.22) 84%,
            rgba(0, 0, 0, 0.66) 100%);
}
.chr-core-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.22;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 0 0.5  0 0 0 1.6 -0.3'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

/* hairline + time bubble while reading the core */
.chr-hair {
    position: absolute;
    left: -8px;
    right: -8px;
    height: 1px;
    background: rgba(255, 252, 240, 0.85);
    box-shadow: 0 0 6px rgba(255, 252, 240, 0.6);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 3;
}
.chr-hair.on { opacity: 1; }
.chr-hair-t {
    position: absolute;
    right: calc(100% + 16px);
    top: -0.62rem;
    font-size: 0.72rem;
    color: var(--ink);
    background: var(--paper);
    padding: 0 0.3rem;
    white-space: nowrap;
}

/* -------------------------------------------------------------- depth */

.chr-tick {
    position: absolute;
    right: 0;
    font-size: 0.7rem;
    color: var(--ink-faint);
    transform: translateY(-50%);
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.chr-tick::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 1px;
    background: var(--ink-faint);
    vertical-align: middle;
    margin-left: 6px;
    opacity: 0.7;
}
.chr-tick.major { color: var(--ink-soft); }

.chr-day {
    position: absolute;
    right: 0;
    text-align: right;
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink);
    transform: translateY(-120%);
    white-space: nowrap;
}

.chr-note {
    position: absolute;
    right: -6px;
    width: 180px;
    transform: translateY(-50%);
    text-align: right;
    font-size: 0.72rem;
    line-height: 1.35;
    font-style: italic;
    color: #d9c79a;
    padding-right: 16px;
}
.chr-note::after {
    content: "";
    position: absolute;
    right: -2px;
    top: 50%;
    width: 12px;
    height: 1px;
    background: #d9c79a;
}
.chr-note::before {
    content: "◆";
    font-style: normal;
    margin-right: 0.35em;
    font-size: 0.6rem;
    vertical-align: 0.1em;
}

/* --------------------------------------------------------------- eras */

.chr-era {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    gap: 14px;
    cursor: pointer;
}
.chr-era-rule {
    flex: none;
    width: 2px;
    border-radius: 1px;
    background: var(--era-grad, var(--ink-faint));
    opacity: 0.9;
    transition: width 0.15s, opacity 0.15s;
}
.chr-era:hover .chr-era-rule, .chr-era.lit .chr-era-rule { width: 4px; opacity: 1; }
.chr-era-body { min-width: 0; padding-top: 1px; }
.chr-era-title {
    font-size: 0.86rem;
    line-height: 1.25;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chr-era-meta {
    font-size: 0.7rem;
    color: var(--ink-faint);
    margin-top: 0.12rem;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.chr-era-meta .open { color: #d9c79a; }
.chr-era:hover .chr-era-title { color: #fffaf0; }

.chr-reel {
    display: flex;
    height: 28px;
    margin-top: 0.4rem;
    max-width: 560px;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(232, 226, 212, 0.08);
}
.chr-reel span {
    flex: var(--w) 1 0;
    min-width: 12px;
    background-size: cover;
    background-position: center;
    position: relative;
    transition: filter 0.2s;
}
.chr-reel span + span { box-shadow: -1px 0 0 rgba(0, 0, 0, 0.7); }
.chr-reel span:hover { filter: brightness(1.25); }

.chr-era.thin .chr-era-body { display: none; }
.chr-era.thin { cursor: pointer; }
.chr-era.thin:hover .chr-era-body {
    display: block;
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(5, 5, 5, 0.92);
    padding: 0.35rem 0.6rem;
    border-radius: 2px;
    z-index: 4;
    box-shadow: 0 0 0 1px rgba(232, 226, 212, 0.1);
}
.chr-era:not(.thin) { overflow: hidden; }
.chr-era.compact .chr-reel, .chr-era.line .chr-reel, .chr-era.line .chr-era-meta { display: none; }
.chr-era.line .chr-era-title { font-size: 0.78rem; color: var(--ink-soft); }
.chr-era.line:hover .chr-era-title { color: var(--ink); }
.chr-era-meta i { font-style: normal; }

.chr-gaplabel {
    position: absolute;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    color: var(--ink-faint);
    text-transform: lowercase;
}
.chr-gaplabel::before { content: "— "; }

/* ------------------------------------------------------------- loupe */

.chr-loupe {
    position: absolute;
    z-index: 20;
    width: 340px;
    pointer-events: none;
    background: rgba(6, 6, 6, 0.94);
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(232, 226, 212, 0.14), 0 20px 60px rgba(0, 0, 0, 0.85);
    padding: 8px 8px 10px;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.12s, transform 0.12s;
}
.chr-loupe.on { opacity: 1; transform: none; }
.chr-loupe-img {
    width: 100%;
    aspect-ratio: 2 / 1;
    background: #111 center / cover no-repeat;
    border-radius: 2px;
}
.chr-loupe-when {
    font-size: 0.7rem;
    color: var(--ink-soft);
    margin: 0.55rem 0 0.1rem;
    letter-spacing: 0.04em;
}
.chr-loupe-title { font-size: 0.82rem; color: var(--ink); line-height: 1.3; }
.chr-loupe-prompt {
    font-size: 0.72rem;
    line-height: 1.45;
    color: var(--ink-soft);
    margin: 0.35rem 0 0;
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ------------------------------------------------------------ drawer */

.chr-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(600px, 100vw);
    z-index: 60;
    background: #080808;
    box-shadow: -1px 0 0 rgba(232, 226, 212, 0.1), -40px 0 120px rgba(0, 0, 0, 0.9);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(102%);
    transition: transform 0.32s cubic-bezier(0.2, 0.7, 0.1, 1);
    padding: 1.6rem 1.6rem 3rem;
    color: var(--ink);
}
.chr-drawer.open { transform: none; }
.chr-scrim {
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.chr-scrim.open { opacity: 1; pointer-events: auto; }

.chr-x {
    position: sticky;
    top: 0;
    float: right;
    background: none;
    border: 0;
    color: var(--ink-soft);
    font: inherit;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}
.chr-x:hover { color: var(--ink); }

.chr-d-when { font-size: 0.72rem; letter-spacing: 0.08em; color: var(--ink-soft); }
.chr-d-title { font-size: 1.35rem; font-weight: 400; line-height: 1.3; margin: 0.4rem 0 0.8rem; }
.chr-d-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.4rem;
    font-size: 0.72rem;
    color: var(--ink-faint);
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--rule);
}
.chr-d-stats b { color: var(--ink-soft); font-weight: 400; }

.chr-d-h {
    font-size: 0.66rem;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 1.8rem 0 0.9rem;
}

.chr-scene { margin-bottom: 1.3rem; }
.chr-scene img {
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    border-radius: 2px;
    display: block;
    box-shadow: 0 0 0 1px rgba(232, 226, 212, 0.08);
    background: #111;
}
.chr-scene-line {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--ink-soft);
}
.chr-swatches { display: flex; gap: 3px; margin-left: auto; }
.chr-swatches i { width: 14px; height: 14px; border-radius: 1px; display: block; }
.chr-scene p {
    margin: 0.3rem 0 0;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--ink-soft);
    font-style: italic;
}

.chr-words { list-style: none; padding: 0; margin: 0; font-size: 0.74rem; }
.chr-words li {
    display: grid;
    grid-template-columns: 3.4rem 5.6rem minmax(0, 1fr);
    gap: 0.6rem;
    padding: 0.28rem 0;
    border-bottom: 1px solid rgba(232, 226, 212, 0.04);
    color: var(--ink-soft);
}
.chr-words .t { color: var(--ink-faint); }
.chr-words .slot { color: var(--ink-faint); text-align: right; }
.chr-words .from { text-decoration: line-through; text-decoration-color: rgba(163, 157, 144, 0.5); color: var(--ink-faint); }
.chr-words .to { color: var(--ink); }

.chr-moments {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 3px;
}
.chr-moments img {
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    display: block;
    background: #111;
}
.chr-faded {
    font-size: 0.74rem;
    color: var(--ink-faint);
    font-style: italic;
    line-height: 1.5;
}

/* --------------------------------------------------------------- foot */

.chr-more {
    text-align: center;
    margin-top: 2rem;
    font-size: 0.75rem;
    color: var(--ink-faint);
    letter-spacing: 0.12em;
    min-height: 1.5rem;
}
.chr-foot {
    max-width: 36rem;
    margin: 3.5rem auto 0;
    text-align: center;
    font-size: 0.78rem;
    line-height: 1.7;
    color: var(--ink-faint);
}
.chr-foot a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--rule); }
.chr-foot a:hover { color: var(--ink); }

/* ------------------------------------------------------------- narrow */

@media (max-width: 760px) {
    .chronicle-page { --core-w: 34vw; --depth-w: 46px; --gutter: 12px; padding: 0 10px 3rem; }
    .chr-title { font-size: 1.55rem; letter-spacing: 0.26em; }
    .chr-deposit a { width: 30vw; }
    .chr-deposit-when { left: auto; right: -2px; bottom: 36px; transform: translateX(100%); font-size: 0.66rem; }
    .chr-tick { font-size: 0.62rem; }
    .chr-tick::after { width: 4px; margin-left: 3px; }
    .chr-day { font-size: 0.56rem; letter-spacing: 0.1em; }
    .chr-note { width: 42vw; right: auto; left: calc(100% + 34vw + 20px); text-align: left; padding: 0 0 0 0; z-index: 5; background: rgba(5,5,5,.85); }
    .chr-note::after { display: none; }
    .chr-era { gap: 8px; }
    .chr-era-title { font-size: 0.74rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
    .chr-era-meta { font-size: 0.6rem; }
    .chr-era-meta { white-space: normal; }
    .chr-era-meta .x, .chr-era-meta i:has(+ .x) { display: none; }
    .chr-era.line .chr-era-title { font-size: 0.66rem; -webkit-line-clamp: 1; }
    .chr-reel { height: 22px; }
    .chr-loupe { width: min(300px, 62vw); }
    .chr-hair-t { right: calc(100% + 6px); font-size: 0.62rem; }
}

@media (prefers-reduced-motion: reduce) {
    .chr-status.live .chr-dot, .chr-deposit.live .chr-fall::after { animation: none; }
    .chr-drawer, .chr-scrim, .chr-loupe { transition: none; }
}

/* ------------------------------------------------ additions: band, day rules, caption */

.chr-band {
    position: absolute;
    left: -3px;
    right: -3px;
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(255, 252, 240, 0.8), 0 0 18px rgba(255, 252, 240, 0.25);
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 2;
}

.chr-midnight {
    position: absolute;
    left: calc(-1 * (var(--core-w) + var(--depth-w) + 2 * var(--gutter)));
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, rgba(232, 226, 212, 0.18), rgba(232, 226, 212, 0.05) 70%, transparent);
    pointer-events: none;
}

.chr-caption {
    grid-column: 3;
    align-self: end;
    padding-bottom: 30px;
    min-width: 0;
}
.chr-cap-when { font-size: 0.72rem; color: var(--ink-soft); letter-spacing: 0.04em; }
.chr-cap-when b { color: #d9c79a; font-weight: 400; }
.chr-cap-prompt {
    margin: 0.35rem 0 0.4rem;
    font-size: 0.78rem;
    line-height: 1.5;
    font-style: italic;
    color: var(--ink-soft);
    max-width: 34rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.chr-cap-link {
    font-size: 0.72rem;
    color: var(--ink-soft);
    text-decoration: none;
    border-bottom: 1px solid var(--rule);
}
.chr-cap-link:hover { color: var(--ink); }

.chr-words .t { white-space: nowrap; }

@media (max-width: 760px) {
    .chr-caption { padding-bottom: 12px; }
    .chr-cap-when { font-size: 0.62rem; }
    .chr-cap-prompt { font-size: 0.66rem; -webkit-line-clamp: 3; }
}
