/* ==========================================================
   Five Great Capes — Voyage Tracker
   Theme concept: dark mode = night chart-plotter / radar screen,
   light mode = aged paper nautical chart.
   ========================================================== */

/* Colors and fonts match svalruna.com (Midnight Navy / Warm Cream / amber; Clash Display + Satoshi) */
:root{
  --font-display: 'Clash Display', 'Satoshi', system-ui, sans-serif;
  --font-body: 'Satoshi', system-ui, -apple-system, sans-serif;
  --font-mono: 'Satoshi', system-ui, -apple-system, sans-serif;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 20px; --radius-full: 9999px;
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme='dark']{
  color-scheme: dark;
  --color-bg: #071422;
  --color-surface: #0f2438;
  --color-surface-2: #132b42;
  --color-surface-offset: #0c2033;
  --color-border: #1e3a54;
  --color-divider: #17304a;
  --color-text: #f2ecd9;
  --color-text-muted: #9fb3c4;
  --color-text-faint: #5d7488;
  --color-primary: #d8842a;
  --color-primary-hover: #eda24b;
  --color-primary-highlight: #3a2818;
  --color-success: #7fc79a;
  --color-warning: #eda24b;
  --color-error: #e5677a;
  --map-land: #0f2438; --map-water: #071422; --map-line: #1e3a54; --map-label: #9fb3c4;
  --shadow-sm: 0 1px 2px hsl(210 60% 3% / 0.5);
  --shadow-md: 0 6px 20px hsl(210 60% 3% / 0.55);
  --shadow-lg: 0 16px 40px hsl(210 60% 3% / 0.6);
}
[data-theme='light']{
  color-scheme: light;
  --color-bg: #eef3f6;
  --color-surface: #ffffff;
  --color-surface-2: #f5f8fa;
  --color-surface-offset: #e2ecf1;
  --color-border: #cfdce4;
  --color-divider: #dbe6ec;
  --color-text: #0d2233;
  --color-text-muted: #4c6577;
  --color-text-faint: #90a5b3;
  --color-primary: #b2661a;
  --color-primary-hover: #8f4e12;
  --color-primary-highlight: #fbe9ce;
  --color-success: #2f7d4f;
  --color-warning: #8f4e12;
  --color-error: #b8324a;
  --map-land: #f2ecd9; --map-water: #d3e2ea; --map-line: #bcd2de; --map-label: #4c6577;
  --shadow-sm: 0 1px 2px hsl(200 30% 70% / 0.4);
  --shadow-md: 0 6px 20px hsl(200 30% 70% / 0.45);
  --shadow-lg: 0 16px 40px hsl(200 30% 70% / 0.5);
}
/* ---------- Type scale ---------- */
:root{
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8125rem);
  --text-sm: clamp(0.8125rem, 0.78rem + 0.25vw, 0.9375rem);
  --text-base: clamp(0.9375rem, 0.9rem + 0.2vw, 1rem);
  --text-lg: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem);
  --c-reeves:#6b46c1; --c-socrates:#c2364f; --c-terhart:#0e7c86; --c-alruna:#b2661a;
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem; --space-4: 1rem; --space-16: 4rem;
}
[data-theme='dark']{ --c-reeves:#b49cf0; --c-socrates:#ef7088; --c-terhart:#4fc9cf; --c-alruna:#eda24b; }
[data-theme='light'] .c-r,[data-theme='light'] .c-s,[data-theme='light'] .c-t{}
html,body{height:100%}
body{font-family:var(--font-body);font-size:var(--text-sm);overflow:hidden;display:flex;flex-direction:column}
.mono{font-family:var(--font-body);font-variant-numeric:tabular-nums;font-feature-settings:'tnum'}
.app-header{display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.6rem 1rem;border-bottom:1px solid var(--color-border);background:var(--color-surface);flex:0 0 auto}
.brand{display:flex;align-items:center;gap:.7rem;min-width:0}
.brand-mark{width:34px;height:34px;color:var(--color-primary);flex:0 0 auto}
.brand-text{display:flex;flex-direction:column;min-width:0}
.brand-name{font-family:var(--font-display);font-weight:600;letter-spacing:.01em;word-spacing:.12em;font-size:var(--text-lg);line-height:1.1}
.brand-tag{color:var(--color-text-muted);font-size:var(--text-xs);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.header-actions{display:flex;gap:.5rem;align-items:center}
.seg{display:flex;border:1px solid var(--color-border);border-radius:var(--radius-full);overflow:hidden}
.seg button{border:0;background:transparent;padding:.3rem .7rem;font-size:var(--text-xs);font-weight:700;cursor:pointer;color:var(--color-text-muted)}
.seg button.on{background:var(--color-primary);color:var(--color-surface)}
.icon-btn{border:1px solid var(--color-border);background:transparent;border-radius:var(--radius-full);width:34px;height:34px;display:grid;place-items:center;cursor:pointer;color:var(--color-text)}
.layout{flex:1 1 auto;display:grid;grid-template-columns:400px 1fr;min-height:0}
.panel{overflow-y:auto;border-right:1px solid var(--color-border);background:var(--color-surface);padding:.5rem 1rem 2rem}
.block{padding:.9rem 0;border-bottom:1px solid var(--color-divider)}
.block:last-child{border-bottom:0}
.block-h{font-family:var(--font-display);font-weight:600;letter-spacing:.01em;word-spacing:.12em;font-size:var(--text-base);margin-bottom:.4rem}
.block-h-row{display:flex;justify-content:space-between;align-items:baseline;gap:.5rem}
.hint{color:var(--color-text-muted);font-size:var(--text-xs);margin-bottom:.6rem}
.hint-s{color:var(--color-text-muted);font-size:var(--text-xs);margin-top:.4rem}
.cards{display:flex;flex-direction:column;gap:.5rem}
.card{border:1px solid var(--color-border);border-left:4px solid var(--c);border-radius:var(--radius-md);padding:.55rem .7rem;background:var(--color-surface-2)}
.card.off{opacity:.5}
.card-top{display:flex;align-items:center;gap:.5rem}
.card-name{font-weight:700;background:none;border:0;padding:0;cursor:pointer;text-align:left;flex:1;font-size:var(--text-sm)}
.card-name small{display:block;font-weight:500;color:var(--color-text-muted);font-size:var(--text-xs)}
.card-meta{font-family:var(--font-body);font-variant-numeric:tabular-nums;font-size:11px;color:var(--color-text-muted);margin-top:.3rem;line-height:1.5}
.card-src{font-size:var(--text-xs);color:var(--color-text-muted);margin-top:.35rem;line-height:1.45}
.badge{display:inline-block;font-size:10px;font-weight:700;letter-spacing:.03em;text-transform:uppercase;padding:.05rem .4rem;border-radius:var(--radius-full);border:1px solid currentColor;margin-left:.3rem;vertical-align:1px}
.badge.est{color:var(--color-warning)} .badge.log{color:var(--color-success)}
.sw{position:relative;width:34px;height:20px;flex:0 0 auto}
.sw input{opacity:0;width:100%;height:100%;position:absolute;margin:0;cursor:pointer;z-index:1}
.sw span{position:absolute;inset:0;border-radius:20px;background:var(--color-surface-offset);border:1px solid var(--color-border);transition:var(--transition-interactive)}
.sw span::after{content:"";position:absolute;width:14px;height:14px;top:2px;left:2px;border-radius:50%;background:var(--color-text-muted);transition:var(--transition-interactive)}
.sw input:checked+span{background:var(--c)}
.sw input:checked+span::after{left:16px;background:#fff}
table{width:100%;border-collapse:collapse;font-size:var(--text-xs)}
th{text-align:left;font-weight:700;color:var(--color-text-muted);padding:.3rem .25rem;border-bottom:1px solid var(--color-border)}
td{padding:.35rem .25rem;border-bottom:1px solid var(--color-divider);vertical-align:top}
td.r,th.r{text-align:right}
td .mono,td.mono{font-size:11px}
.dot{display:inline-block;width:10px;height:10px;border-radius:50%;background:var(--c);vertical-align:-1px}
.c-r{color:var(--c-reeves)} .c-s{color:var(--c-socrates)} .c-t{color:var(--c-terhart)}
.capes td{font-family:var(--font-body);font-variant-numeric:tabular-nums;font-size:11px}
.capes td:first-child{font-family:var(--font-body);font-weight:600;font-size:var(--text-xs)}
.capes a{color:inherit;text-decoration:underline dotted}
.capes .est{color:var(--color-warning)}
.passed{background:var(--color-primary-highlight)}
.table-wrap{overflow-x:auto}
.notes,.sources{list-style:none;display:flex;flex-direction:column;gap:.45rem;font-size:var(--text-xs);color:var(--color-text-muted)}
.notes li{padding-left:.8rem;border-left:3px solid var(--c,var(--color-border))}
.notes b{color:var(--color-text)}
.sources a{color:var(--color-primary);word-break:break-word}
.map-wrap{position:relative;min-height:0}
#map{position:absolute;inset:0}
.map-tools{position:absolute;top:.75rem;left:.75rem;display:flex;gap:.4rem;z-index:2}
.chip{border:1px solid var(--color-border);background:var(--color-surface);color:var(--color-text);border-radius:var(--radius-full);padding:.35rem .8rem;font-size:var(--text-xs);font-weight:700;cursor:pointer;box-shadow:var(--shadow-sm)}
.chip:hover{border-color:var(--color-primary)}
.timeline{position:absolute;left:.75rem;right:.75rem;bottom:2.1rem;z-index:2;display:flex;gap:.7rem;align-items:center;background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-lg);padding:.55rem .8rem;box-shadow:var(--shadow-md)}
.play{width:40px;height:40px;border-radius:50%;border:0;background:var(--color-primary);color:var(--color-surface);display:grid;place-items:center;cursor:pointer;flex:0 0 auto}
.play .i-pause{display:none} .play.on .i-pause{display:block} .play.on .i-play{display:none}
.tl-body{flex:1;min-width:0}
.tl-top{display:flex;justify-content:space-between;font-size:var(--text-xs);gap:.5rem}
.tl-top b{font-size:var(--text-sm)}
input[type=range]{width:100%;accent-color:var(--color-primary);margin:.2rem 0 0}
.tl-ticks{position:relative;height:12px;font-family:var(--font-body);font-variant-numeric:tabular-nums;font-size:10px;color:var(--color-text-muted)}
.tl-ticks span{position:absolute;transform:translateX(-50%)}
.maplibregl-popup-content{background:var(--color-surface);color:var(--color-text);border-radius:var(--radius-md);box-shadow:var(--shadow-md);font-family:var(--font-body);font-size:var(--text-xs);padding:.6rem .75rem;max-width:260px}
.maplibregl-popup-tip{border-top-color:var(--color-surface)!important;border-bottom-color:var(--color-surface)!important}
.maplibregl-popup-content h4{font-family:var(--font-display);font-size:var(--text-sm);margin-bottom:.2rem}
.maplibregl-popup-content a{color:var(--color-primary)}
.maplibregl-popup-close-button{color:var(--color-text-muted)}
@media (max-width:860px){
  body{overflow:auto;height:auto}
  .layout{display:flex;flex-direction:column}
  .map-wrap{order:-1;height:62vh;min-height:420px;flex:0 0 auto}
  .panel{border-right:0;overflow:visible}
  .brand-tag{display:none}
  .timeline{bottom:2.2rem;left:.5rem;right:.5rem;padding:.45rem .6rem}
}
.card.focused{box-shadow:0 0 0 2px var(--c);background:var(--color-surface)}
@media (max-width:860px){
  .map-wrap{height:68vh;min-height:440px}
  .timeline{gap:.5rem;padding:.35rem .55rem;bottom:2rem}
  .play{width:34px;height:34px}
  .tl-ticks{display:none}
  .map-tools{top:.5rem;left:.5rem}
}

.play{color:var(--color-text-inverse,#071422)}
.seg button.on{color:#071422}
[data-theme="light"] .seg button.on,[data-theme="light"] .play{color:#fff}
.maplibregl-ctrl-group{background:var(--color-surface)!important;border:1px solid var(--color-border);box-shadow:var(--shadow-sm)!important}
.maplibregl-ctrl-group button+button{border-top-color:var(--color-border)!important}
[data-theme='dark'] .maplibregl-ctrl-group button .maplibregl-ctrl-icon{filter:invert(.92) sepia(.15)}
.maplibregl-ctrl-attrib{background:color-mix(in srgb,var(--color-surface) 85%,transparent)!important;color:var(--color-text-muted)}
.maplibregl-ctrl-attrib a{color:var(--color-text-muted)!important}
[data-theme='dark'] .maplibregl-ctrl-attrib-button{filter:invert(.9)}
/* svalruna.com integration */
a.brand{color:inherit;text-decoration:none}
.brand-seal{width:40px;height:40px;flex:0 0 auto;object-fit:contain}
[data-theme='light'] .seal-dark,[data-theme='dark'] .seal-light{display:none}
.home-link{font-size:var(--text-xs);font-weight:700;color:var(--color-text);text-decoration:none;border:1px solid var(--color-border);border-radius:var(--radius-full);padding:.35rem .8rem;white-space:nowrap}
.home-link:hover{border-color:var(--color-primary);color:var(--color-primary)}
@media (max-width:520px){ .brand-seal{width:32px;height:32px} .brand-name{font-size:1rem} .home-link{padding:.3rem .55rem} .app-header{gap:.5rem;padding:.5rem .6rem} }
.brand-name{white-space:nowrap}
.brand{min-width:0;overflow:hidden}
@media (max-width:520px){ .home-txt{display:none} .home-link{padding:.3rem .7rem;font-size:1rem;line-height:1.2} }

/* Embedded inside svalruna.com */
.embed .brand,.embed .home-link,.embed #theme-toggle{display:none}
.embed .app-header{justify-content:flex-end;padding:.4rem .75rem}
@media (max-width:860px){ .embed body{overflow:visible} .embed .map-wrap{height:460px;min-height:0} }
