/* ============================================================================
 * Isle of Trains: All Aboard - Campaign Logbook
 *
 * A printed reference sheet, not a dashboard. Everything sits on one full-bleed
 * island scene - bright sky, sun, clouds, rolling hills, the line running across
 * them - and the chapters are dense bordered cards printed on top of it, each
 * carrying the same strong flat-colour blocks the campaign sheet in the box
 * uses: gold Objective, green Special Rules, heavy dark borders on everything.
 *
 * Deliberately NOT: translucent panels on a dark background, generous padding,
 * hairline borders, muted tints. The source material is a boldly printed sheet
 * of card, so the borders are thick, the fills are solid, and the gaps are small.
 *
 * Palette. The scene sits two steps down in lightness from a midday sky, so the
 * cream cards printed on it stay the brightest thing on the sheet:
 *   sky            #2275a5 -> #49abd8
 *   sun            #eec72f
 *   clouds         #dbe8ef
 *   hills          #6eb441 / #4f8a3a
 *   grass strip    #4f8a3a / #5a9c3f
 *   embankment     #c39056
 *   ink (all rules)#23372c
 *   paper          #fbf3de   dull paper #ece0c2
 *   gold block     #f3c33f
 *   green block    #7ac86a
 *   signal red     #d94f3d
 *
 * All selectors are scoped under .iot-tracker so the global
 * reset-typography.css cannot override fonts on bare element selectors
 * (known overlay gotcha).
 * ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Alfa+Slab+One&family=Changa:wght@500;600;700;800&display=swap');

.iot-tracker {
    --iot-ink: #23372c;
    --iot-ink-soft: #4a6152;
    --iot-paper: #fbf3de;
    --iot-paper-dull: #ece0c2;
    --iot-gold: #f3c33f;
    --iot-gold-deep: #a97c11;
    --iot-green: #7ac86a;
    --iot-green-deep: #2f6b23;
    --iot-red: #d94f3d;
    --iot-sky: #4fb0e8;
    --iot-sky-pale: #cbeaf8;
    --iot-brown: #8a5f33;

    position: relative;
    box-sizing: border-box;
    margin: 20px 0;
    padding: 0 0 30px;
    overflow: hidden;
    border: 5px solid var(--iot-ink);
    border-radius: 10px;
    /* The sky carries on behind the card grid - the scene is the whole sheet,
       not a header image with a dashboard underneath. */
    background: linear-gradient(180deg, #2275a5 0%, #2b99ca 22%, #49abd8 46%, #43a4d1 100%);
    color: var(--iot-ink);
    font-family: 'Changa', system-ui, -apple-system, sans-serif;
    font-size: 15px;
}

.iot-tracker *,
.iot-tracker *::before,
.iot-tracker *::after { box-sizing: border-box; }

/* Grass along the bottom edge, so the sheet lands on the island rather than
   just stopping. */
.iot-tracker::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 22px;
    background: repeating-linear-gradient(90deg, #4f8a3a 0 14px, #5a9c3f 14px 28px);
    border-top: 3px solid var(--iot-ink);
}

/* ========== The scene ========== */

.iot-scene {
    position: relative;
    padding: 16px 18px 14px;
    border-bottom: 5px solid var(--iot-ink);
    overflow: hidden;
}

/* Sun sits in the gap between the title plate and the plaques - it is the one
   band of open sky in the banner row, so nothing has to be drawn over. */
.iot-sun {
    position: absolute;
    top: 4px;
    left: 47%;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: #eec72f;
    border: 4px solid var(--iot-ink);
    box-shadow: 0 0 0 11px rgba(238, 199, 47, 0.32), 0 0 0 22px rgba(238, 199, 47, 0.15);
}

/* Outlined clouds, to match everything else on the sheet being drawn with a
   heavy dark line. Soft white puffs read as smudges next to it. */
.iot-cloud {
    position: absolute;
    /* An <svg> with height:auto falls back to the 150px default replaced-element
       height, and preserveAspectRatio then centres the drawing inside it - which
       silently parks every cloud ~47px below where its `top` says. Pinning the
       ratio makes height:auto resolve to the real one. */
    aspect-ratio: 118 / 56;
    height: auto;
    /* Cloud fill, via currentColor on the shared <symbol>. Off-white rather than
       pure white - against the dimmed sky, #fff is the brightest thing on the
       sheet and drags the eye off the line. */
    color: #dbe8ef;
}
/* Kept up in the banner band and out over the sea on the left. Anything lower
   crosses the platform and puts a cloud through a passenger's head. */
.iot-cloud--a { top: 10px;  left: 25%; width: 112px; }
.iot-cloud--b { top: 96px;  left: 1%;  width: 84px; }
.iot-cloud--c { top: 18px;  left: 61%; width: 120px; }

.iot-hill {
    position: absolute;
    bottom: 0;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    border-top: 4px solid var(--iot-ink);
}
.iot-hill--far { left: -8%;  width: 68%; height: 118px; background: #6eb441; }
.iot-hill--mid { right: -12%; width: 78%; height: 92px;  background: #4f8a3a; }

/* ---- Banner: title plate + score plaques ---- */

.iot-banner {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.iot-plate {
    padding: 8px 18px 10px;
    background: var(--iot-paper);
    border: 4px solid var(--iot-ink);
    border-radius: 6px;
    box-shadow: 4px 4px 0 rgba(35, 55, 44, 0.35), inset 0 0 0 2px var(--iot-gold);
    transform: rotate(-1deg);
}

.iot-eyebrow {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--iot-brown);
}

.iot-title {
    display: block;
    margin-top: 1px;
    font-family: 'Alfa Slab One', Georgia, serif;
    font-size: 1.8rem;
    line-height: 1.05;
    color: var(--iot-ink);
}

.iot-plaques {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.iot-plaque {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    padding: 5px 10px 6px;
    background: var(--iot-paper);
    border: 3px solid var(--iot-ink);
    border-radius: 5px;
    box-shadow: 3px 3px 0 rgba(35, 55, 44, 0.3);
}

.iot-plaque b {
    font-family: 'Alfa Slab One', Georgia, serif;
    font-size: 1.5rem;
    line-height: 1;
    font-weight: 400;
}
.iot-plaque b i { font-style: normal; font-size: 0.85rem; color: var(--iot-ink-soft); }

.iot-plaque em {
    margin-top: 2px;
    font-style: normal;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--iot-ink-soft);
    white-space: nowrap;
}

.iot-plaque--beaten { background: var(--iot-green); }
.iot-plaque--beaten em { color: var(--iot-green-deep); }
.iot-plaque--derail b { color: #8e2b1d; }
.iot-plaque--now { background: var(--iot-gold); }
.iot-plaque--now em { color: var(--iot-gold-deep); }

/* ---- The line ---- */

.iot-line {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-start;
    gap: 4px;
    /* Full-bleed inside the scene: the line runs off both edges rather than
       stopping inside the padding. Done with matching negative margin and
       padding instead of negative insets on the rail, because a child sticking
       out past the scroll container's own box is what puts a scrollbar under
       the platform at full width. */
    margin: 28px -18px 0;
    padding: 60px 18px 0;   /* padding-top = headroom for the tokens above the line */
    overflow-x: auto;
    overflow-y: hidden;
}

/* Dirt bed the sleepers are laid on. */
.iot-embankment {
    position: absolute;
    left: 0;
    right: 0;
    top: 66px;
    height: 34px;
    background: #c39056;
    border-top: 3px solid var(--iot-ink);
    border-bottom: 3px solid var(--iot-ink);
}

/* Sleepers, then the two steel rails over the top of them. */
.iot-rail {
    position: absolute;
    left: 0;
    right: 0;
    top: 72px;
    height: 20px;
    background:
        repeating-linear-gradient(90deg, #6b4a2b 0 8px, transparent 8px 22px),
        linear-gradient(180deg,
            transparent 0 4px, #4e5860 4px 7px,
            transparent 7px 13px, #4e5860 13px 16px, transparent 16px 20px);
}

.iot-stop {
    position: relative;
    flex: 1 1 0;
    /* Wide enough that the train and a waiting passenger sit side by side at the
       current chapter instead of on top of each other. */
    min-width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

.iot-stop-dot {
    position: relative;
    z-index: 2;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 4px solid var(--iot-ink);
    background: var(--iot-paper);
    box-shadow: 2px 2px 0 rgba(35, 55, 44, 0.4);
    font-family: 'Alfa Slab One', Georgia, serif;
    font-size: 1.05rem;
    color: var(--iot-ink);
}

/* Station name on a little printed ticket. */
.iot-stop-name {
    position: relative;
    z-index: 2;
    padding: 3px 6px;
    background: var(--iot-paper);
    border: 2px solid var(--iot-ink);
    border-radius: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--iot-ink);
}

.iot-stop--beaten .iot-stop-dot { background: var(--iot-green); }
.iot-stop--beaten .iot-stop-name { background: #d7f0cf; }
.iot-stop--active .iot-stop-dot { background: var(--iot-red); color: #fff2ef; }
.iot-stop--ondeck .iot-stop-dot { background: var(--iot-gold); }
.iot-stop--upcoming .iot-stop-dot,
.iot-stop--norecord .iot-stop-dot { background: var(--iot-paper-dull); color: var(--iot-ink-soft); }
.iot-stop--upcoming .iot-stop-name,
.iot-stop--norecord .iot-stop-name { background: var(--iot-paper-dull); color: var(--iot-ink-soft); }

/* The game's own progress-train token, parked at the current chapter. */
.iot-loco {
    position: absolute;
    top: -55px;
    left: 0;
    width: 84px;
    height: auto;
    filter: drop-shadow(2px 3px 0 rgba(35, 55, 44, 0.45));
}

/* A passenger meeple waits at every chapter still to be played, and is gone
   from any chapter that has been beaten - the line empties out behind you. */
.iot-passenger {
    position: absolute;
    top: -52px;
    right: 2px;
    height: 58px;
    width: auto;
    filter: drop-shadow(2px 3px 0 rgba(35, 55, 44, 0.4));
}

/* ========== The chapter cards ========== */

.iot-chapters {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    /* Cards take their natural height rather than stretching to the tallest in
       the row. A chapter with no Special Rules block would otherwise carry a
       hand-span of dead paper before its footer, which is exactly the airy
       dashboard look this sheet is not. */
    align-items: start;
    gap: 12px;
    padding: 16px 18px 0;
}

.iot-chapter {
    display: flex;
    flex-direction: column;
    padding: 10px 12px 0;
    overflow: hidden;
    background: var(--iot-paper);
    border: 4px solid var(--iot-ink);
    border-radius: 6px;
    box-shadow: 4px 4px 0 rgba(35, 55, 44, 0.35), inset 0 0 0 2px rgba(169, 124, 17, 0.35);
}

.iot-chapter--upcoming,
.iot-chapter--norecord { background: var(--iot-paper-dull); }
.iot-chapter--ondeck { box-shadow: 4px 4px 0 rgba(35, 55, 44, 0.35), inset 0 0 0 3px var(--iot-gold); }
.iot-chapter--beaten { box-shadow: 4px 4px 0 rgba(35, 55, 44, 0.35), inset 0 0 0 3px var(--iot-green); }
.iot-chapter--active { box-shadow: 4px 4px 0 rgba(35, 55, 44, 0.35), inset 0 0 0 3px var(--iot-red); }

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

.iot-chapter-head {
    display: flex;
    align-items: center;
    gap: 9px;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--iot-ink);
}

.iot-chapter-num {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    border: 3px solid var(--iot-ink);
    background: var(--iot-gold);
    font-family: 'Alfa Slab One', Georgia, serif;
    font-size: 1.2rem;
    color: var(--iot-ink);
}

.iot-chapter-titles { flex: 1 1 auto; min-width: 0; }

.iot-chapter-eyebrow {
    display: block;
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--iot-brown);
}

.iot-chapter-name {
    display: block;
    font-family: 'Alfa Slab One', Georgia, serif;
    font-size: 1.02rem;
    line-height: 1.12;
    color: var(--iot-ink);
}

.iot-stamp {
    flex-shrink: 0;
    align-self: flex-start;
    padding: 3px 8px;
    border: 2px solid;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    transform: rotate(-3deg);
}

.iot-stamp--ok { color: var(--iot-green-deep); background: var(--iot-green); border-color: var(--iot-green-deep); }
.iot-stamp--open { color: #fff2ef; background: var(--iot-red); border-color: #8e2b1d; }
.iot-stamp--ondeck { color: var(--iot-gold-deep); background: var(--iot-gold); border-color: var(--iot-gold-deep); }
.iot-stamp--ahead { color: var(--iot-ink-soft); background: transparent; border-color: var(--iot-ink-soft); border-style: dashed; }

/* ---- Briefing ---- */

.iot-flavour {
    margin: 8px 0;
    padding-left: 9px;
    border-left: 4px solid var(--iot-brown);
    font-size: 0.8rem;
    font-style: italic;
    line-height: 1.32;
    color: #55452f;
}

/* ---- The two printed blocks ---- */

.iot-box {
    margin-bottom: 8px;
    padding: 6px 9px 8px;
    border: 3px solid var(--iot-ink);
    border-radius: 4px;
}

.iot-box-label {
    display: inline-block;
    margin-bottom: 3px;
    padding: 1px 7px;
    border-radius: 3px;
    background: var(--iot-ink);
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.iot-box-text,
.iot-box-list {
    margin: 0;
    font-size: 0.86rem;
    font-weight: 600;
    line-height: 1.28;
}
.iot-box-list { padding-left: 16px; }
.iot-box-list li + li { margin-top: 3px; }

.iot-box--objective { background: var(--iot-gold); }
.iot-box--objective .iot-box-label { color: var(--iot-gold); }
.iot-box--objective .iot-box-text { color: #33270a; }

.iot-box--rules { background: var(--iot-green); }
.iot-box--rules .iot-box-label { color: #b6f0a8; }
.iot-box--rules .iot-box-list { color: #123a0c; }

/* ---- Run record: a dark strip across the foot of the card ---- */

.iot-chapter-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin: auto -12px 0;
    padding: 6px 12px;
    background: var(--iot-ink);
    color: var(--iot-paper);
}

.iot-pips { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }

.iot-pip {
    width: 30px;
    height: auto;
    display: block;
}
/* A derailed run is the same token, tipped on its side and drained of colour.
   Lightened rather than dimmed: the strip behind it is nearly black, so a faded
   token just disappears. */
.iot-pip--loss {
    filter: grayscale(1) brightness(1.7);
    opacity: 0.8;
    transform: rotate(90deg);
}

.iot-pips-empty {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #9db3a6;
}

.iot-record {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--iot-gold);
}

.iot-note {
    flex: 1 1 100%;
    font-size: 0.75rem;
    font-style: italic;
    color: #c9d6cd;
}

/* ========== Narrow ========== */

@media (max-width: 1100px) {
    /* The plaques wrap onto their own row here, which frees the top-right
       corner and takes the mid-sky band the low cloud was sitting in. `left`
       has to be unset explicitly - with both offsets and a width, left wins. */
    .iot-sun { left: auto; right: 16px; width: 56px; height: 56px; }
    .iot-cloud--b { display: none; }
}

@media (max-width: 900px) {
    .iot-chapters { grid-template-columns: 1fr; padding: 12px 12px 0; }
    .iot-scene { padding: 12px 12px 10px; }
    .iot-line { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
    .iot-title { font-size: 1.4rem; }
    .iot-plaque { min-width: 78px; }
    /* Tokens come down a size so a stop still holds both of them without
       widening the scroll any further than it already is. */
    .iot-stop { min-width: 116px; }
    .iot-loco { width: 70px; top: -46px; }
    .iot-passenger { height: 48px; top: -42px; }
}

@media (max-width: 640px) {
    /* The title plate goes full width down here and the plaques stack under it,
       so there is no open sky left to put the weather in - it would only sit
       behind the plate. Sky, hills and the line carry the scene on their own. */
    .iot-sun,
    .iot-cloud { display: none; }
    .iot-line { margin-top: 18px; }
}
