/* Ancient Rome stage (templates/projects/history_tutor/ancient_rome.html).
   Site edu-theme tokens only. Layout: one full-screen stage: the map fills it, a year slider runs
   along the bottom, a "Now discussing" card sits bottom-left and a drawer (facts, people, events,
   layers) slides in from the right. Gaius floats over the map's bottom-left corner as a round
   avatar; clicking it opens the chat card, and the minus button tucks it away again. */

.rd-app {
    position: relative;
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--primary-dark);
    color: var(--text-primary);
}

.rd-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- guide (left) ---------- */

.rd-guide {
    position: absolute;
    z-index: 9;
    left: 18px;
    bottom: 144px;
    width: min(400px, calc(100% - 36px));
    height: min(640px, calc(100% - 300px));
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 18px;
    box-shadow: 0 18px 44px -16px rgba(30, 15, 25, 0.55);
    overflow: hidden;
    animation: rd-guide-in 0.22s ease both;
}

.rd-guide[hidden] { display: none; }

@keyframes rd-guide-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.rd-guide-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 12px 8px 18px; }
.rd-guide-min { flex: none; align-self: flex-start; font-size: 1.6rem; }

/* the floating Gaius: a round avatar over the map's bottom-left corner, with a greeting and two shortcuts */
.rd-dock {
    position: absolute;
    z-index: 8;
    left: 18px;
    bottom: 144px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    max-width: calc(100% - 100px);
    pointer-events: none;
}

.rd-dock > * { pointer-events: auto; }

.rd-guide-fab {
    position: relative;
    flex: none;
    width: 68px;
    height: 68px;
    padding: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--secondary-dark);
    box-shadow: 0 0 0 3px var(--era, #6b3f8c), 0 10px 26px -8px rgba(30, 15, 25, 0.6);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.rd-guide-fab:hover { transform: scale(1.06); }
.rd-guide-fab:focus-visible { outline: 3px solid var(--accent-blue); outline-offset: 4px; }
.rd-avatar--fab { display: block; width: 100%; height: 100%; }
.rd-fab-dot { position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; border-radius: 50%; background: #c23b5a; border: 2px solid #fff; }
.rd-fab-dot[hidden] { display: none; }

.rd-dock-hint {
    margin-bottom: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--hairline);
    border-radius: 14px 14px 14px 4px;
    box-shadow: 0 8px 22px -12px rgba(30, 15, 25, 0.5);
}

.rd-dock-hint p { margin: 0 0 8px; font-size: 0.9rem; color: var(--text-primary); }
.rd-dock-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rd-dock-chips .rd-chip { background: #fff; }
.rd-dock.is-open { display: none; }
.rd-app:has(.rd-focus:not([hidden])) .rd-dock-hint { display: none; }   /* the card the visitor is reading wins the corner */

.rd-back {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.86rem;
    color: var(--text-muted);
    text-decoration: none;
}

.rd-back:hover { color: var(--accent-blue); }

.rd-guide-id { display: flex; align-items: center; gap: 14px; }
.rd-guide-name { margin: 0; font-size: 1.45rem; color: var(--text-primary); }
.rd-guide-id p { margin: 2px 0 0; font-size: 0.86rem; color: var(--text-muted); }

.rd-avatar {
    flex: none;
    display: inline-block;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    overflow: hidden;
}

.rd-avatar--lg { width: 64px; height: 64px; }

.rd-chat {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 6px 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rd-msg { display: flex; align-items: flex-start; gap: 10px; }
.rd-msg--user { flex-direction: row-reverse; }

.rd-you {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--tertiary-dark);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.rd-bubble {
    min-width: 0;
    max-width: 100%;
    padding: 10px 14px;
    border-radius: 4px 16px 16px 16px;
    background: var(--tertiary-dark);
    line-height: 1.55;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.rd-msg--ai .rd-bubble { white-space: normal; }
.rd-msg--ai .rd-bubble p { margin: 0 0 0.6em; }
.rd-msg--ai .rd-bubble > :last-child { margin-bottom: 0; }
.rd-msg--ai .rd-bubble .rd-list { margin: 0 0 0.6em; padding-left: 1.3em; }
.rd-msg--ai .rd-bubble .rd-list li { margin-bottom: 0.3em; }

.rd-msg--user .rd-bubble {
    border-radius: 16px 4px 16px 16px;
    background: rgba(150, 48, 95, 0.1);
}

.rd-note {
    margin: -6px 0 0 44px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.rd-error {
    margin: 0;
    padding: 9px 12px;
    border-radius: 8px;
    color: #9b2c2c;
    background: rgba(178, 58, 58, 0.08);
    border: 1px solid rgba(178, 58, 58, 0.25);
    font-size: 0.9rem;
}

.rd-typing { display: inline-flex; gap: 4px; padding: 6px 0; }

.rd-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: rd-blink 1.2s infinite ease-in-out;
}

.rd-typing span:nth-child(2) { animation-delay: 0.2s; }
.rd-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes rd-blink {
    0%, 80%, 100% { opacity: 0.25; }
    40% { opacity: 1; }
}

.rd-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 10px;
}

.rd-starters[hidden] { display: none; }

.rd-chip {
    background: transparent;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 6px 13px;
    font: inherit;
    font-size: 0.84rem;
    color: var(--text-primary);
    cursor: pointer;
}

.rd-chip:hover { border-color: var(--accent-blue); color: var(--accent-deep); }

.rd-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin: 0 20px 18px;
    padding: 8px 8px 8px 16px;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 18px;
    box-shadow: 0 6px 20px -14px rgba(40, 20, 30, 0.3);
}

.rd-input:focus-within { border-color: var(--accent-blue); }

.rd-input textarea {
    flex: 1;
    min-width: 0;
    min-height: 28px;
    max-height: 120px;
    resize: none;
    padding: 6px 0;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.rd-input textarea:focus { outline: none; }

.rd-send {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    cursor: pointer;
}

.rd-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- stage (right) ---------- */

.rd-stage {
    --era: #6b3f8c;
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    background: #cddde0;
}

.rd-stage[data-era="kingdom"] { --era: #8a7547; }
.rd-stage[data-era="early_republic"] { --era: #b0623a; }
.rd-stage[data-era="punic_wars"] { --era: #a8433f; }
.rd-stage[data-era="late_republic"] { --era: #96305F; }
.rd-stage[data-era="principate_peak"] { --era: #6b3f8c; }
.rd-stage[data-era="division"] { --era: #3f6f86; }
.rd-stage[data-era="byzantine_early"] { --era: #8e6b2f; }
.rd-stage[data-era="byzantine_middle"] { --era: #a8791a; }
.rd-stage[data-era="byzantine_late"] { --era: #8a3b3b; }

.rd-map { position: absolute; inset: 0; z-index: 0; background: #cddde0; }
.rd-map .leaflet-container, .rd-map.leaflet-container { background: #cddde0; font: inherit; }
.rd-map .leaflet-control-attribution { font-size: 0.68rem; background: rgba(250, 244, 230, 0.8); margin-right: 0; }
.rd-map .leaflet-top.leaflet-left { top: 190px; }
.rd-map .leaflet-bottom { bottom: 136px; }

/* territory fades in as it is won */
.rd-prov { transition: opacity 0.7s ease, fill-opacity 0.7s ease; cursor: pointer; }
.rd-prov--new { opacity: 0; }

.rd-route { stroke-dasharray: 8 6; animation: rd-march 1s linear infinite; }
@keyframes rd-march { to { stroke-dashoffset: -14; } }

/* ancient place names, drawn as map text */
.rd-lbl-wrap, .rd-pulse-wrap, .rd-stop-wrap { background: none; border: none; }
.rd-lbl { position: absolute; white-space: nowrap; transform: translate(-3px, -50%); display: flex; align-items: center; gap: 4px; font-family: var(--font-display, Georgia, serif); color: #2a1d0a; text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff, 0 0 4px #fff, 0 0 6px #fffbe9; }
.rd-lbl-dot { width: 7px; height: 7px; border-radius: 50%; background: #2a1d0a; border: 1.5px solid #fff; flex: none; }
.rd-lbl-text { font-size: 0.86rem; font-weight: 700; }
.rd-lbl--region { transform: translate(-50%, -50%); }
.rd-lbl--region .rd-lbl-text { font-size: 0.98rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: #3a2a10; }
.rd-lbl--people { transform: translate(-50%, -50%); }
.rd-lbl--people .rd-lbl-text { font-size: 0.9rem; font-weight: 800; font-style: italic; letter-spacing: 0.05em; color: #6e1d1d; }
.rd-lbl--sea, .rd-lbl--river { transform: translate(-50%, -50%); }
.rd-lbl--sea .rd-lbl-text { font-style: italic; letter-spacing: 0.2em; text-transform: uppercase; color: #163c4a; font-weight: 700; font-size: 0.86rem; text-shadow: 0 0 3px #e4f1f3, 0 0 3px #e4f1f3, 0 0 5px #e4f1f3; }
.rd-lbl--river .rd-lbl-text { font-style: italic; color: #1d4e5e; font-weight: 700; font-size: 0.8rem; }
.rd-lbl--mountain .rd-lbl-text { font-style: italic; color: #4a3719; font-weight: 700; font-size: 0.8rem; }
.rd-lbl--island .rd-lbl-text { font-size: 0.82rem; font-weight: 700; font-style: italic; color: #3a2a10; }

.rd-tip { font: inherit; font-size: 0.82rem; border-radius: 8px; border: 1px solid var(--hairline); color: var(--text-primary); }

.rd-pulse { position: absolute; transform: translate(-50%, -50%); }
.rd-pulse-ring { display: block; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 3px solid var(--era); animation: rd-ping 1.4s ease-out infinite; }
.rd-pulse-label { position: absolute; left: 16px; top: -10px; white-space: nowrap; padding: 2px 8px; border-radius: 999px; background: var(--era); color: #fff; font-size: 0.78rem; font-weight: 600; }
@keyframes rd-ping { 0% { transform: scale(0.5); opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }

.rd-stop { width: 22px; height: 22px; border-radius: 50%; background: var(--era); color: #fff; border: 2px solid #fff; font-size: 0.74rem; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,0.35); }

/* top bar over the map */
.rd-top {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 16px;
    align-items: start;
    padding: 14px 150px 30px 22px;   /* right: clear of the floating "Tutor AI" button */
    background: linear-gradient(to bottom, rgba(247, 241, 226, 0.96) 0%, rgba(247, 241, 226, 0.9) 62%, rgba(247, 241, 226, 0) 100%);
    pointer-events: none;
}

.rd-top-main { display: contents; }
.rd-back--stage { grid-column: 1; grid-row: 1; margin-bottom: 2px; }
.rd-top h1 { grid-column: 1; grid-row: 2; }
.rd-yearline { grid-column: 1; grid-row: 3; }
.rd-phases { grid-column: 1; grid-row: 4; display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; min-height: 0; }
.rd-phases:empty { display: none; }
.rd-tabs { grid-column: 2; grid-row: 1 / span 4; }

/* what is happening in the current year: wars, crises, political turning points */
.rd-phase { display: inline-flex; align-items: baseline; gap: 8px; padding: 5px 12px; border-radius: 999px; background: #fff; border: 1.5px solid var(--era); box-shadow: 0 2px 8px -4px rgba(40, 20, 30, 0.4); font-size: 0.86rem; color: var(--text-primary); }
.rd-phase b { font-weight: 700; }
.rd-phase small { font-size: 0.74rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rd-phase--war { background: #fdeceb; border-color: #b3261e; }
.rd-phase--war b { color: #7a1712; }
.rd-phase--crisis { background: #fff3dc; border-color: #b9770e; }
.rd-phase--political { background: #eef0fb; border-color: #5b5fc7; }

/* timeline tab */
.rd-tl-now { padding: 12px 14px; background: var(--tertiary-dark); border-radius: 12px; border-left: 4px solid var(--era); }
.rd-tl-year { margin: 0 0 6px; font-family: var(--font-display, Georgia, serif); font-size: 1.35rem; font-weight: 700; color: var(--era); font-variant-numeric: tabular-nums; }
.rd-tl-ruler, .rd-tl-phase { margin: 0 0 6px; font-size: 0.92rem; line-height: 1.45; }
.rd-tl-ruler span { color: var(--text-secondary); }
.rd-tl-phase--war strong { color: #7a1712; }
.rd-tl-phase--crisis strong { color: #8a5a0a; }
.rd-tl-phase--political strong { color: #3f43a3; }
.rd-tl-phase span { color: var(--text-secondary); }
.rd-tl-h { margin: 16px 0 6px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.rd-tl-list { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 2px solid var(--hairline); }
.rd-tl-list--rulers { position: relative; max-height: 270px; overflow-y: auto; scrollbar-width: thin; }
.rd-tl-empty { padding: 8px 10px; font-size: 0.9rem; color: var(--text-muted); }
.rd-tl-item { position: relative; }
.rd-tl-item::before { content: ''; position: absolute; left: -16px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--hairline); }
.rd-tl-item.is-now::before { background: var(--era); border-color: var(--era); }
.rd-tl-item.is-past::before { background: var(--text-muted); border-color: var(--text-muted); }
.rd-tl-btn { width: 100%; display: grid; grid-template-columns: 112px 1fr; column-gap: 8px; align-items: baseline; text-align: left; padding: 7px 8px; border: none; border-radius: 8px; background: transparent; font: inherit; font-size: 0.9rem; color: var(--text-primary); cursor: pointer; }
.rd-tl-btn:hover { background: var(--tertiary-dark); }
.rd-tl-btn small { grid-column: 2; color: var(--text-muted); font-size: 0.78rem; }
.rd-tl-when { font-size: 0.78rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rd-tl-item.is-now .rd-tl-btn { background: rgba(107, 63, 140, 0.1); box-shadow: inset 3px 0 0 var(--era); }
.rd-tl-item.is-now .rd-tl-what { font-weight: 700; }
.rd-tl-item.is-past .rd-tl-what { color: var(--text-secondary); }
.rd-top > * { pointer-events: auto; }
.rd-top-main { min-width: 0; }
.rd-top h1 { margin: 0; font-size: clamp(1.4rem, 2.4vw, 1.9rem); color: var(--text-primary); }
/* home-link.css pads every h1 by 56px; this heading needs its room. */
body:not(.embedded) .rd-top h1 { padding: 0; }
.rd-yearline { margin: 2px 0 8px; color: var(--text-secondary); font-size: 0.92rem; font-variant-numeric: tabular-nums; }

.rd-cats, .rd-filter { display: flex; flex-wrap: wrap; gap: 6px; }

.rd-era, .rd-cat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 5px 12px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.rd-era small { font-weight: 400; color: var(--text-muted); }
.rd-era:hover, .rd-cat:hover { border-color: var(--era); color: var(--accent-deep); }
.rd-era.is-active, .rd-cat.is-active { background: var(--era); border-color: var(--era); color: #fff; }
.rd-era.is-active small { color: rgba(255, 255, 255, 0.85); }

/* quiz progress ring on an era chip */
/* the six eras, along the top of the slider and sized to the years they cover */
.rd-scrub-eras { position: relative; height: 40px; margin-bottom: 3px; }
.rd-scrub-eras .rd-era {
    position: absolute;
    top: 0;
    height: 100%;
    box-sizing: border-box;
    margin: 0 1.5px;
    padding: 3px 7px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    min-width: 0;
    overflow: hidden;
    border-radius: 9px;
    border: 1.5px solid var(--band);
    background: color-mix(in srgb, var(--band) 24%, #fff);
    color: var(--text-primary);
    font-size: 0.78rem;
    line-height: 1.2;
    text-align: left;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.rd-scrub-eras .rd-era small { font-size: 0.66rem; font-weight: 500; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rd-scrub-eras .rd-era:hover { border-color: var(--text-primary); color: var(--text-primary); }
.rd-scrub-eras .rd-era.is-active { background: var(--band); border-color: var(--band); color: var(--on-band); }
.rd-scrub-eras .rd-era.is-active small { color: var(--on-band); opacity: 0.85; }
.rd-scrub-eras .rd-era--narrow { padding: 2px 5px; font-size: 0.72rem; line-height: 1.12; white-space: normal; text-overflow: clip; }
.rd-scrub-eras .rd-era--narrow small { display: none; }
.rd-scrub-eras .rd-ring { position: absolute; top: 4px; right: 4px; }

.rd-ring { width: 14px; height: 14px; border-radius: 50%; background: conic-gradient(var(--accent-green) var(--pct), rgba(120, 110, 100, 0.25) 0); position: relative; flex: none; }
.rd-ring::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--secondary-dark); }
.rd-era.is-active .rd-ring::after { background: var(--era); }

.rd-tabs { display: flex; flex-wrap: nowrap; gap: 6px; justify-content: flex-end; }

.rd-tab {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 7px 12px;
    white-space: nowrap;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: 0 2px 8px -4px rgba(40, 20, 30, 0.35);
}

.rd-tab:hover { border-color: var(--era); }
.rd-tab.is-active { background: var(--era); border-color: var(--era); color: #fff; }

/* era banner when the era changes */
.rd-banner {
    position: absolute;
    z-index: 6;
    top: 38%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 14px 34px;
    border-radius: 14px;
    background: rgba(247, 241, 226, 0.92);
    border: 2px solid var(--era);
    color: var(--text-primary);
    opacity: 0;
    pointer-events: none;
}

.rd-banner strong { display: block; font-family: var(--font-display, Georgia, serif); font-size: 1.7rem; }
.rd-banner span { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.rd-banner.is-on { animation: rd-banner 2.4s ease both; }
@keyframes rd-banner { 0% { opacity: 0; transform: translate(-50%, -44%); } 14% { opacity: 1; transform: translate(-50%, -50%); } 78% { opacity: 1; } 100% { opacity: 0; } }

.rd-panel[hidden], .rd-focus[hidden], .rd-drawer[hidden], .rd-pane[hidden] { display: none; }

/* "Now discussing" card */
.rd-focus {
    position: absolute;
    z-index: 5;
    left: 100px;
    bottom: 144px;
    width: min(400px, calc(100% - 120px));
    max-height: calc(100% - 300px);
    display: flex;
    flex-direction: column;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-top: 4px solid var(--era);
    border-radius: 14px;
    box-shadow: 0 10px 28px -12px rgba(30, 15, 25, 0.5);
}

.rd-focus-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 16px; }
.rd-focus-kind { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--era); }
.rd-focus-body { padding: 4px 16px 14px; overflow-y: auto; }
.rd-focus-body .rd-spot-name { margin: 2px 0 0; }
.rd-focus-person { display: flex; gap: 14px; align-items: flex-start; margin-top: 4px; }
.rd-focus-person .rd-portrait, .rd-focus-person .rd-portrait-fallback { width: 84px; height: 104px; }
.rd-focus-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.rd-route-step { margin: 10px 0 0; line-height: 1.5; font-size: 0.92rem; }

.rd-icon-btn { width: 30px; height: 30px; border: none; border-radius: 50%; background: transparent; font-size: 1.4rem; line-height: 1; color: var(--text-muted); cursor: pointer; }
.rd-icon-btn:hover { background: var(--tertiary-dark); color: var(--text-primary); }

.rd-battle { margin-top: 8px; }
.rd-battle-svg { display: block; width: 100%; max-width: 280px; margin: 0 auto; border: 1px solid var(--hairline); border-radius: 8px; }
.rd-battle-unit rect { stroke: #fff; stroke-width: 0.4; }
.rd-battle-unit text { font-size: 3.2px; fill: #fff; font-weight: 700; pointer-events: none; }
.rd-battle-unit.rd-side-rome rect { fill: #96305F; }
.rd-battle-unit.rd-side-enemy rect { fill: #2F7A6B; }
.rd-battle-unit.rd-side-allied rect { fill: #b98a2c; }
.rd-battle-arrow { stroke-width: 1.4; fill: none; opacity: 0.85; }
.rd-battle-arrow.rd-side-rome, .rd-battle-arrow-head.rd-side-rome { stroke: #96305F; fill: #96305F; }
.rd-battle-arrow.rd-side-enemy, .rd-battle-arrow-head.rd-side-enemy { stroke: #2F7A6B; fill: #2F7A6B; }
.rd-battle-arrow.rd-side-allied, .rd-battle-arrow-head.rd-side-allied { stroke: #b98a2c; fill: #b98a2c; }
.rd-battle-arrow-head { stroke: none; }
.rd-battle-river { font-size: 3px; fill: #4c7682; font-style: italic; }
.rd-battle-unit text { font-size: 4px; }
.rd-battle-legend { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; font-size: 0.8rem; color: var(--text-secondary); }
.rd-battle-legend b { display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 17px; border-radius: 4px; color: #fff; font-size: 0.72rem; margin-right: 2px; }
.rd-battle-legend b.rd-side-rome { background: #96305F; }
.rd-battle-legend b.rd-side-enemy { background: #2F7A6B; }
.rd-battle-legend b.rd-side-allied { background: #b98a2c; }

/* year scrubber */
.rd-scrub {
    position: absolute;
    z-index: 5;
    left: 18px;
    right: 82px;   /* clear of the floating share button */
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px 6px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    box-shadow: 0 8px 24px -14px rgba(30, 15, 25, 0.5);
}

.rd-play { flex: none; width: 40px; height: 40px; border: none; border-radius: 50%; background: var(--era); color: #fff; font-size: 0.95rem; cursor: pointer; }
.rd-speed { flex: none; width: 40px; height: 28px; border: 1px solid var(--hairline); border-radius: 999px; background: var(--secondary-dark); font: inherit; font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); cursor: pointer; }
.rd-speed:hover { border-color: var(--era); color: var(--era); }
.rd-scrub-main { flex: 1; min-width: 0; }

/* timelapse captions */
.rd-ticker { position: absolute; z-index: 5; left: 50%; bottom: 144px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: min(560px, calc(100% - 36px)); }
.rd-ticker-item { display: flex; align-items: center; gap: 10px; max-width: 100%; padding: 7px 16px 7px 8px; border-radius: 999px; background: rgba(35, 25, 30, 0.88); color: #fff; font-size: 0.92rem; animation: rd-ticker-in 0.35s ease both; }
.rd-ticker-item i { flex: none; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-style: normal; font-weight: 700; background: #96305F; }
.rd-ticker-item.is-lost i { background: #6b6b6b; }
.rd-ticker-item.is-battle i { background: #b3261e; }
.rd-ticker-item.is-battle-win i { background: #2f7d4a; }
.rd-ticker-item.is-battle-loss i { background: #8c1c13; }

/* a battle fought in the current year or just before it */
.rd-bm-wrap { background: none; border: none; }
.rd-bm { position: absolute; transform: translate(-18px, -18px); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.rd-bm-icon { position: relative; flex: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #b3261e; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(30, 10, 10, 0.5); }
.rd-bm.is-old .rd-bm-icon { opacity: 0.75; transform: scale(0.8); }
.rd-bm-label { font-family: var(--font-display, Georgia, serif); font-size: 0.82rem; font-weight: 700; color: #6e100b; text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 5px #fff, 0 0 5px #fff; }
.rd-bm.is-new .rd-bm-icon::after { content: ''; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid #b3261e; animation: rd-bm-ring 1.4s ease-out infinite; }
/* a win: a green marker that pops up with a golden ring spreading outward */
.rd-bm--win .rd-bm-icon { background: #2f7d4a; }
.rd-bm--win .rd-bm-label { color: #1d5a33; }
.rd-bm--win.is-new .rd-bm-icon { animation: rd-bm-pop 0.7s cubic-bezier(0.2, 1.7, 0.4, 1) both; }
.rd-bm--win.is-new .rd-bm-icon::after { border-color: #d9a441; }
/* a defeat: a dark red marker that shakes, with rings closing in on it */
.rd-bm--loss .rd-bm-icon { background: #7d1a12; }
.rd-bm--loss .rd-bm-label { color: #5e0f09; }
.rd-bm--loss.is-new .rd-bm-icon { animation: rd-bm-shake 0.7s ease-in-out both; }
.rd-bm--loss.is-new .rd-bm-icon::after { border-color: #3a0a07; animation: rd-bm-collapse 1.6s ease-in infinite; }
@keyframes rd-bm-pop { 0% { transform: scale(0.2); } 100% { transform: scale(1); } }
@keyframes rd-bm-shake { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-5px) rotate(-6deg); } 35% { transform: translateX(5px) rotate(6deg); } 55% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes rd-bm-collapse { 0% { transform: scale(2); opacity: 0; } 30% { opacity: 0.9; } 100% { transform: scale(0.6); opacity: 0; } }
@keyframes rd-bm-ring { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(1.7); opacity: 0; } }
.rd-ticker-item.is-event i { background: #D9A441; color: #3a2a05; }
.rd-ticker-item span { min-width: 0; }
.rd-ticker-item small { flex: none; opacity: 0.75; font-variant-numeric: tabular-nums; }
@keyframes rd-ticker-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.rd-scrub-track { position: relative; height: 34px; }
.rd-bands { position: absolute; left: 0; right: 0; top: 13px; height: 8px; border-radius: 4px; overflow: hidden; }
.rd-band { position: absolute; top: 0; bottom: 0; opacity: 0.85; }
.rd-ticks { position: absolute; left: 0; right: 0; top: 0; height: 0; }

.rd-tick {
    position: absolute;
    top: 3px;
    width: 8px;
    height: 8px;
    margin-left: -4px;
    padding: 0;
    border: 1.5px solid #7a5a14;
    border-radius: 50%;
    background: #D9A441;
    cursor: pointer;
}

.rd-tick:hover { transform: scale(1.5); }

.rd-scrub input[type="range"] { position: absolute; left: 0; right: 0; top: 7px; width: 100%; height: 20px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
.rd-scrub input[type="range"]::-webkit-slider-runnable-track { height: 8px; background: transparent; }
.rd-scrub input[type="range"]::-moz-range-track { height: 8px; background: transparent; }
.rd-scrub input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -6px; border-radius: 50%; background: var(--era); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,0.45); cursor: grab; }
.rd-scrub input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--era); border: 3px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,0.45); cursor: grab; }
.rd-scrub input[type="range"]:focus-visible { outline: 2px solid var(--era); outline-offset: 4px; border-radius: 6px; }
.rd-scrub-ends { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--text-muted); }
.rd-year-out { flex: none; min-width: 86px; text-align: right; font-family: var(--font-display, Georgia, serif); font-size: 1.25rem; font-weight: 700; color: var(--era); font-variant-numeric: tabular-nums; }

/* drawer */
.rd-drawer {
    position: absolute;
    z-index: 7;
    top: 70px;
    right: 14px;
    max-height: calc(100% - 232px);
    width: 390px;
    max-width: calc(100% - 28px);
    display: flex;
    flex-direction: column;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 14px;
    box-shadow: 0 14px 34px -14px rgba(30, 15, 25, 0.55);
}

.rd-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 4px 18px; }
.rd-drawer-head h2 { margin: 0; font-size: 1.05rem; }
.rd-drawer-body { padding: 8px 18px 18px; overflow-y: auto; min-height: 0; }
.rd-pane h3 { margin: 14px 0 8px; font-size: 0.95rem; color: var(--text-primary); }
.rd-pane h3:first-child { margin-top: 4px; }
.rd-filter { margin-bottom: 10px; }

.rd-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* a name in a chat reply that opens the card and flies the map */
.rd-ref {
    padding: 0;
    border: none;
    border-bottom: 1.5px dotted var(--accent-blue);
    background: none;
    font: inherit;
    color: var(--accent-deep);
    cursor: pointer;
}

.rd-ref:hover { background: rgba(150, 48, 95, 0.1); }

/* facts */

.rd-fact-card { margin-top: 10px; padding: 16px 18px; background: var(--tertiary-dark); border-radius: 12px; }
.rd-fact-says { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rd-fact-leadin { font-size: 0.88rem; font-weight: 600; color: var(--accent-deep); }

.rd-fact-text {
    margin: 0;
    font-family: var(--font-display, Georgia, serif);
    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--text-primary);
}

.rd-fact-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.rd-fact-tags:empty { display: none; }
.rd-fact-sources { margin: 10px 0 0; font-size: 0.78rem; line-height: 1.5; color: #6b5a3c; }
.rd-fact-sources:empty { display: none; }
.rd-fact-sources a { color: #7a2f2f; text-decoration: underline; text-underline-offset: 2px; }

.rd-tag {
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--hairline);
    background: var(--secondary-dark);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

button.rd-tag { cursor: pointer; }
button.rd-tag:hover { border-color: var(--accent-blue); color: var(--accent-deep); }

.rd-fact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.rd-fact-count { margin-left: auto; font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.rd-btn {
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-radius: 999px;
    padding: 6px 14px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.rd-btn:hover:not(:disabled) { border-color: var(--accent-blue); color: var(--accent-deep); }
.rd-btn:disabled { opacity: 0.45; cursor: default; }
.rd-btn--primary { background: var(--era); border-color: var(--era); color: #fff; }
.rd-btn--primary:hover:not(:disabled) { background: var(--accent-deep); color: #fff; }

.rd-era:focus-visible, .rd-cat:focus-visible, .rd-btn:focus-visible, .rd-chip:focus-visible,
.rd-send:focus-visible, .rd-tag:focus-visible, .rd-event:focus-visible, .rd-person:focus-visible,
.rd-quiz-choice:focus-visible, .rd-back:focus-visible, .rd-tab:focus-visible, .rd-play:focus-visible,
.rd-tick:focus-visible, .rd-icon-btn:focus-visible, .rd-ref:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* events list */

.rd-timeline { list-style: none; margin: 0; padding: 0 0 0 26px; position: relative; display: flex; flex-direction: column; gap: 6px; }

.rd-timeline::before { content: ""; position: absolute; left: 11px; top: 4px; bottom: 4px; width: 2px; background: var(--hairline); }

.rd-event {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: none;
    font: inherit;
    text-align: left;
    cursor: pointer;
    color: var(--text-primary);
}

.rd-event::before { content: ""; position: absolute; left: -21px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--secondary-dark); border: 2px solid var(--accent-blue); }
.rd-event:hover { background: var(--tertiary-dark); }
.rd-event.is-active { background: rgba(150, 48, 95, 0.08); border-color: rgba(150, 48, 95, 0.3); }
.rd-event.is-active::before { background: var(--accent-blue); }
.rd-event-date { font-size: 0.76rem; font-weight: 700; color: var(--accent-deep); }
.rd-event-name { font-size: 0.92rem; font-weight: 600; }
.rd-why { color: var(--accent-deep); margin: 0 0 6px; line-height: 1.5; font-size: 0.9rem; }

/* people */

.rd-portrait { flex: none; width: 120px; height: 150px; border-radius: 8px; object-fit: cover; background: var(--secondary-dark); }

.rd-portrait-fallback {
    flex: none;
    width: 120px;
    height: 150px;
    border-radius: 8px;
    background: rgba(150, 48, 95, 0.12);
    color: var(--accent-deep);
    font-family: var(--font-display, Georgia, serif);
    font-size: 2.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rd-spot-name { font-size: 1.15rem; font-weight: 700; margin: 0; }
.rd-spot-meta { margin: 2px 0 8px; font-size: 0.84rem; color: var(--text-muted); }
.rd-spot-text { margin: 0 0 8px; line-height: 1.55; font-size: 0.93rem; }

.rd-people-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.rd-person {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 0 0 10px;
    border: 1px solid var(--hairline);
    border-radius: 12px;
    background: var(--secondary-dark);
    font: inherit;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    overflow: hidden;
}

.rd-person:hover { border-color: var(--accent-blue); }
.rd-person.is-active { border-color: var(--accent-blue); box-shadow: 0 0 0 2px rgba(150, 48, 95, 0.25); }
.rd-person .rd-portrait, .rd-person .rd-portrait-fallback { width: 100%; height: 120px; border-radius: 0; }
.rd-person .rd-portrait { object-position: top; }
.rd-person-name { padding: 6px 10px 0; font-weight: 700; font-size: 0.92rem; }
.rd-person-meta { padding: 0 10px; font-size: 0.76rem; color: var(--text-muted); }
.rd-person-role { padding: 2px 10px 0; font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }
.rd-empty { margin: 0; color: var(--text-muted); }

/* map pane */

.rd-layers { display: grid; gap: 6px; }
.rd-layer { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }
.rd-swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--hairline); }
.rd-route-list { display: flex; flex-wrap: wrap; gap: 8px; }

.rd-about { margin-top: 22px; }
.rd-about h2 { margin: 0 0 6px; font-size: 0.95rem; color: var(--text-secondary); }
.rd-about p { margin: 0; font-size: 0.82rem; line-height: 1.6; color: var(--text-muted); }
.rd-source { margin: 16px 0 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

/* quiz, on the stage */

.rd-quiz {
    position: absolute;
    z-index: 8;
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    width: min(540px, calc(100% - 36px));
    max-height: calc(100% - 300px);
    overflow-y: auto;
    padding: 16px 20px 18px;
    background: var(--secondary-dark);
    border: 2px solid var(--era);
    border-radius: 14px;
    box-shadow: 0 16px 40px -14px rgba(30, 15, 25, 0.6);
}

.rd-quiz h3 { margin: 0 0 8px; font-size: 1.05rem; }
.rd-quiz-question { margin: 0 0 12px; font-size: 1.05rem; line-height: 1.5; }
.rd-quiz-choices { display: grid; gap: 8px; }

.rd-quiz-choice { padding: 10px 14px; border: 1px solid var(--hairline); border-radius: 10px; background: var(--secondary-dark); font: inherit; text-align: left; color: var(--text-primary); cursor: pointer; }

.rd-quiz-choice:hover:not(:disabled) { border-color: var(--accent-blue); }
.rd-quiz-choice:disabled { cursor: default; }
.rd-quiz-choice.rd-correct { border-color: var(--accent-green); background: rgba(47, 122, 107, 0.12); }
.rd-quiz-choice.rd-incorrect { border-color: #b23a3a; background: rgba(178, 58, 58, 0.08); }
.rd-quiz-feedback { margin-top: 12px; line-height: 1.55; }
.rd-quiz-feedback:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
    .rd-typing span, .rd-route, .rd-pulse-ring, .rd-banner.is-on, .rd-ticker-item, .rd-bm.is-new .rd-bm-icon::after, .rd-bm.is-new .rd-bm-icon { animation: none; }
    .rd-prov { transition: none; }
}

/* ---------- small screens: stacked ---------- */

@media (min-width: 1001px) {
    .rd-app:has(.rd-guide:not([hidden])) .rd-focus { left: 434px; width: min(400px, calc(100% - 460px)); }
}

@media (max-width: 1000px) {
    .rd-stage { height: 100vh; height: 100dvh; min-height: 620px; }
    .rd-app { display: block; height: auto; overflow: visible; }
    .rd-app { position: relative; }
    .rd-guide { position: fixed; left: 10px; right: 10px; bottom: 140px; width: auto; height: min(70vh, 560px); height: min(70dvh, 560px); }
    .rd-dock { position: fixed; left: 10px; bottom: 140px; }
    .rd-top { padding-right: 14px; padding-left: 14px; grid-template-columns: minmax(0, 1fr); }
    .rd-tabs { grid-column: 1; grid-row: 5; flex-wrap: wrap; justify-content: flex-start; margin-top: 8px; }
    .rd-scrub { left: 10px; right: 10px; gap: 8px; padding: 8px 10px 4px; }
    .rd-scrub-eras .rd-era { padding: 2px 4px; font-size: 0.62rem; }
    .rd-scrub-eras .rd-era small { display: none; }
    .rd-ticker { bottom: 146px; }
    .rd-year-out { min-width: 70px; font-size: 1.05rem; }
    .rd-drawer { top: auto; left: 10px; right: 10px; bottom: 140px; width: auto; max-height: 55%; max-width: none; }
    .rd-focus { left: 10px; right: 10px; width: auto; bottom: 140px; max-height: 45%; }
    .rd-map .leaflet-top.leaflet-left { top: 228px; }
    body:has(.rd-app) .share-fab { display: none; }
}

@media (max-width: 600px) {
    .rd-fact-count { margin-left: 0; width: 100%; }
    .rd-people-grid { grid-template-columns: minmax(0, 1fr); }
}

.rd-nbkey { display: inline-flex; gap: 3px; }
.rd-nbkey .rd-swatch { margin: 0; }
.rd-tl-item.is-win .rd-tl-what { color: #1d5a33; }
.rd-tl-item.is-loss .rd-tl-what { color: #7d1a12; }

/* a picture of the ruler, with a coin where there is one */
.rd-tl-now-row { display: flex; gap: 12px; align-items: flex-start; }
.rd-tl-now-text { flex: 1; min-width: 0; }
.rd-tl-photo { flex: none; width: 96px; margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative; }
.rd-tl-pic { display: block; width: 96px; height: 116px; border-radius: 10px; overflow: hidden; border: 2px solid #fff; box-shadow: 0 2px 8px -2px rgba(30, 15, 25, 0.5); background: var(--tertiary-dark); }
.rd-tl-pic img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.rd-tl-coin { position: absolute; right: -8px; top: 78px; width: 46px; height: 46px; border-radius: 50%; overflow: hidden; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(30, 15, 25, 0.55); background: #e9dfc2; }
.rd-tl-coin img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rd-tl-explore { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rd-tl-explore .rd-btn { font-size: 0.82rem; text-align: left; }
.rd-tl-photo figcaption { font-size: 0.64rem; color: var(--text-muted); }

.rd-drawer-body { overflow-anchor: none; }   /* a picture loading in the Now card must not nudge the panel's scroll */

/* ---------- the guided tour card ---------- */

.rd-tour {
    position: absolute;
    z-index: 6;
    left: 100px;
    bottom: 144px;
    width: min(460px, calc(100% - 120px));
    padding: 16px 18px 14px;
    background: var(--secondary-dark);
    border: 1px solid var(--hairline);
    border-top: 4px solid var(--era);
    border-radius: 14px;
    box-shadow: 0 10px 28px -12px rgba(30, 15, 25, 0.5);
    animation: rd-ticker-in 0.35s ease both;
}
.rd-tour[hidden] { display: none; }
.rd-tour-count { margin: 0 0 2px; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.7; }
.rd-tour-title { margin: 0 0 6px; font-size: 1.25rem; }
.rd-tour-text { margin: 0 0 10px; font-size: 1rem; line-height: 1.5; }
.rd-tour-bar { height: 3px; border-radius: 2px; background: var(--hairline); overflow: hidden; margin-bottom: 10px; }
.rd-tour-bar i { display: block; height: 100%; width: 0; background: var(--era); }
.rd-tour-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 1000px) {
    .rd-tour { left: 10px; right: 10px; width: auto; bottom: 140px; }
}
@media (prefers-reduced-motion: reduce) { .rd-tour { animation: none; } }
.rd-app.is-touring .rd-dock-hint { display: none; }
.rd-tour-voice { margin-left: auto; } .rd-tour-voice[hidden] { display: none; }
.rd-tour { transition: opacity 0.3s; } .rd-tour.is-travelling { opacity: 0.55; }
