/* Ship Clock web edition. Look follows the Ship Clock web dashboard (style.css)
   and the two palettes in theme.py: "bridge" (night watch) and "midnight". */
:root, html[data-theme="bridge"] {
  --bg: #0A0E0C;
  --panel: #080B0A;
  --card: #161B18;
  --card-hover: #172019;
  --border: #3A5C47;
  --text: #6BAF82;
  --muted: #6E9078;
  --time: #5CFF9B;
  --title: #5CFF9B;
  --accent-dim: #1F5C3A;
  --danger: #E53935;
  --utc: #3DDC84;
  --ship: #E53935;
  --city1: #5CFF9B;
  --city2: #3DDC84;
  --city3: #5CFF9B;
  --city4: #3DDC84;
  --land: #13241A;
  --land-edge: #3A5C47;
  --sea: #080B0A;
  --grid: #16261C;
  --on-accent: #080B0A;
  --font: "IBM 3270", Consolas, monospace; /* app font first; see README "Fonts" */
}
html[data-theme="midnight"] {
  --bg: #0b0f14;
  --panel: #10161e;
  --card: #161d27;
  --card-hover: #1e2733;
  --border: #2a3544;
  --text: #e8eef4;
  --muted: #8b9aab;
  --time: #e8eef4;
  --title: #e8eef4;
  --accent-dim: #3d4a5c;
  --danger: #ef9a9a;
  --utc: #4fc3f7;
  --ship: #ffb74d;
  --city1: #c5e1a5;
  --city2: #80cbc4;
  --city3: #ce93d8;
  --city4: #f48fb1;
  --land: #1b2533;
  --land-edge: #3d4a5c;
  --sea: #0b0f14;
  --grid: #18212c;
  --on-accent: #101010;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--time);
  font-family: var(--font);
}
body { display: flex; flex-direction: column; min-height: 100vh; padding: 10px; }
a { color: var(--title); }
button { font: inherit; }

/* header */
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--panel); padding: 10px 14px; margin-bottom: 8px;
}
.brand-wrap { display: flex; align-items: baseline; gap: 16px; }
.brand { letter-spacing: 0.18em; font-weight: 700; color: var(--title); }
.home { color: var(--muted); text-decoration: none; font-size: 12px; letter-spacing: 0.08em; }
.home:hover { color: var(--title); }
.status { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.status .sep { margin: 0 6px; }
#theme-btn, #kiosk-btn {
  color: var(--muted); background: none; border: 0; padding: 0; cursor: pointer; letter-spacing: inherit;
}
#theme-btn:hover, #kiosk-btn:hover { color: var(--title); }

/* dashboard */
.stage { display: flex; flex-direction: column; height: calc(100vh - 72px); min-height: 520px; }
.clocks {
  flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 1fr;
  gap: 8px; min-height: 80px;
}
.splitter { height: 8px; cursor: ns-resize; background: var(--border); flex: 0 0 8px; margin: 8px 0; touch-action: none; }
.splitter:hover { background: var(--title); }
.card {
  --digit: var(--time);
  background: var(--card);
  border-bottom: 3px solid var(--accent, var(--time));
  display: flex; flex-direction: column; min-height: 80px; padding: 8px 10px 6px;
  container-type: size; overflow: hidden;
}
.card:hover { background: var(--card-hover); }
.card .face { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.card .stack { display: flex; flex-direction: column; align-items: center; }
.card .name {
  text-align: center; color: var(--accent, var(--time));
  font-size: clamp(10px, 7cqh, 22px); font-weight: 700; letter-spacing: 0.08em;
}
.card .time {
  font-size: clamp(14px, min(40cqh, 15cqw), 480px); font-weight: 700; color: var(--digit);
  line-height: 1; padding-bottom: 2px; font-variant-numeric: tabular-nums; white-space: nowrap;
  letter-spacing: -0.02em; /* app digit pitch is ~0.80x digit height; 3270 is ~0.85x */
}
.card .meta { text-align: center; color: var(--muted); font-size: clamp(8px, 5cqh, 14px); }
.card .date {
  text-align: center; color: var(--digit); font-size: clamp(8px, 5.5cqh, 16px);
  padding-top: 2px; letter-spacing: 0.04em; line-height: 1.15;
}
.card .date.alert { color: var(--danger); }
.card.red { --digit: #E53935; }

/* position panel */
.gps {
  background: var(--panel); display: flex; flex-direction: column;
  padding: 10px 0 6px; font-size: var(--gps-size, 18px); font-weight: 700;
  height: var(--gps-height, 230px); flex: 0 0 var(--gps-height, 230px); min-height: 120px;
}
.gps-body {
  flex: 1 1 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch;
  gap: 8px; min-height: 0; padding: 0 8px;
}
.wx {
  min-width: 0; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere;
  line-height: 1.25; color: var(--time); padding: 0 4px 0 2px;
}
.wx .tag, .pos .tag { color: var(--title); letter-spacing: 0.08em; }
.wx .dim, .pos .dim { color: var(--muted); font-weight: 400; }
.wx .chip {
  display: inline-block; padding: 0 8px; margin-bottom: 4px; letter-spacing: 0.14em;
  background: var(--accent-dim); color: var(--time);
}
.wx .chip.underway { background: var(--ship); color: var(--on-accent); }
#globe {
  justify-self: center; align-self: center; height: 100%; width: auto; aspect-ratio: 1 / 1;
  max-width: 100%; min-height: 40px;
}
.gps-inner {
  display: flex; flex-direction: column; align-items: flex-end; text-align: right; min-width: 0;
  padding: 0 1ch 0 8px; line-height: 1.15; color: var(--time);
}
.pos { white-space: pre-line; margin-top: 6px; }
#compass { width: 100%; height: 44px; flex: 0 0 44px; }
.gps-links { margin-top: auto; align-self: flex-end; display: flex; gap: 8px; padding-top: 6px; }
.gbtn {
  background: var(--card); color: var(--danger); border: 1px solid var(--border);
  letter-spacing: 0.14em; padding: 4px 10px; text-decoration: none; font-size: 0.85em;
}
#chart-btn { color: #80CBC4; }
.gbtn:hover { color: var(--title); border-color: var(--title); }

/* voyage section */
.voyage-sec {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 8px; margin-top: 8px;
}
.vessel, .chart { background: var(--panel); margin: 0; padding: 12px 14px; }
.vessel img { display: block; width: 100%; height: auto; border: 1px solid var(--border); }
.vessel h1 { font-size: clamp(20px, 3vw, 32px); margin: 4px 0 6px; color: var(--title); letter-spacing: 0.04em; }
.kicker { color: var(--muted); letter-spacing: 0.15em; font-size: 12px; margin-top: 12px; }
.where { color: var(--text); margin: 0 0 10px; font-weight: 700; line-height: 1.4; }
.note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0; }
#map { display: block; width: 100%; height: auto; aspect-ratio: 16 / 10; background: var(--sea); border: 1px solid var(--border); }
.chart figcaption { color: var(--muted); font-size: 11px; margin-top: 6px; }
#map .land { fill: var(--land); stroke: var(--land-edge); stroke-width: 1; vector-effect: non-scaling-stroke; }
#map .grat { fill: none; stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
#map .route { fill: none; stroke: var(--ship); stroke-width: 2; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
#map .done { fill: none; stroke: var(--utc); stroke-width: 2; vector-effect: non-scaling-stroke; }
#map .lbl { fill: var(--time); font-family: var(--font); font-weight: 700; }
#map .glbl { fill: var(--muted); font-family: var(--font); }
#map .wp { fill: var(--panel); stroke: var(--utc); vector-effect: non-scaling-stroke; stroke-width: 2; }
#map .shipmark { fill: var(--ship); stroke: var(--panel); stroke-width: 1; vector-effect: non-scaling-stroke; }
#map .ring { fill: none; stroke: var(--ship); stroke-width: 2; vector-effect: non-scaling-stroke; animation: ping 2.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ping { 0% { opacity: 0.9; transform: scale(0.4); } 100% { opacity: 0; transform: scale(1.6); } }
@media (prefers-reduced-motion: reduce) { #map .ring { animation: none; } }

.foot {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  color: var(--muted); font-size: 11px; padding: 10px 4px 0; letter-spacing: 0.06em;
}

/* kiosk / full screen, blackout */
html.kiosk body, html:fullscreen body { padding: 0; }
html.kiosk .bar, html.kiosk .splitter, html.kiosk .voyage-sec, html.kiosk .foot,
html:fullscreen .bar, html:fullscreen .splitter, html:fullscreen .voyage-sec, html:fullscreen .foot { display: none !important; }
html.kiosk .stage, html:fullscreen .stage { height: 100vh; }
html.kiosk .gps, html:fullscreen .gps { margin-top: 8px; }
.blackout { position: fixed; inset: 0; z-index: 50; background: #000; cursor: none; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .clocks { grid-template-columns: repeat(2, 1fr); }
  .voyage-sec { grid-template-columns: 1fr; }
  .stage { height: auto; }
  .clocks { grid-auto-rows: 150px; }
}
@media (max-width: 640px) {
  .clocks { grid-template-columns: 1fr; grid-auto-rows: 130px; }
  .splitter { display: none; }
  .gps { height: auto; flex: 0 0 auto; }
  .gps-body { grid-template-columns: 1fr; }
  #globe { height: 220px; }
  .gps-inner { align-items: stretch; text-align: left; }
  .gps-links { align-self: flex-start; }
}
