/* marsruut.css — Route Weather Tool styles */

:root {
  --bg:           #0f1117;
  --bg2:          #181c27;
  --bg3:          #1e2335;
  --bg4:          #242840;
  --text:         #e8eaf0;
  --text-muted:   #8892a4;
  --accent:       #60a5fa;
  --accent-hover: #93c5fd;
  --border:       #2a2f3e;
  --green:        #34d399;
  --yellow:       #fbbf24;
  --red:          #f87171;
  --blue-light:   #93c5fd;
  --font:         system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius:       10px;
  --shadow:       0 2px 12px rgba(0,0,0,0.45);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
}
.logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.logo:hover { color: var(--accent); }
.site-header nav { display: flex; align-items: center; gap: 20px; }
.site-header nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
}
.site-header nav a:hover { color: var(--accent); }
.site-header nav a.active { color: var(--text); }

/* ── Page wrapper ─────────────────────────────────────────────────────────────── */

.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.page-hero {
  margin-bottom: 28px;
}
.page-hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.page-hero .subhead {
  color: var(--text-muted);
  font-size: 0.95rem;
  max-width: 600px;
  line-height: 1.6;
}

/* ── Drop zone ────────────────────────────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(96, 165, 250, 0.05);
}
.drop-zone.accepted {
  border-color: var(--green);
  background: rgba(52, 211, 153, 0.04);
}
.drop-zone.error {
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.04);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.drop-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--text-muted);
  transition: color 0.2s;
}
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon { color: var(--accent); }
.drop-zone.accepted .drop-icon { color: var(--green); }
.drop-zone.error .drop-icon { color: var(--red); }
.drop-label {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.drop-sublabel {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.5;
}
.drop-filename {
  margin-top: 10px;
  font-size: 0.825rem;
  color: var(--accent);
  font-weight: 500;
}
.drop-error {
  margin-top: 10px;
  font-size: 0.825rem;
  color: var(--red);
}

/* ── Link import ─────────────────────────────────────────────────────────────── */

.import-link-wrap {
  margin-top: 12px;
}
.import-link-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.import-link-row {
  display: flex;
  gap: 8px;
}
.import-url-input {
  flex: 1;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 14px;
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.import-url-input:focus { border-color: var(--accent); }
.import-url-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.btn-import {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}
.btn-import:hover  { border-color: var(--accent); background: var(--bg3); }
.btn-import:disabled { opacity: 0.5; cursor: not-allowed; }
.import-error {
  display: none;
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--red);
  line-height: 1.4;
}
.import-error.visible { display: block; }

/* ── Controls panel ───────────────────────────────────────────────────────────── */

.controls-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  display: none;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.controls-panel.visible { display: flex; }

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 160px;
}
.ctrl-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.ctrl-group select,
.ctrl-group input[type="date"],
.ctrl-group input[type="number"] {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.875rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.ctrl-group select:focus,
.ctrl-group input:focus {
  border-color: var(--accent);
}
.ctrl-time-row {
  display: flex;
  gap: 8px;
}
.ctrl-time-row select { flex: 1; }

.btn-analyze {
  background: var(--accent);
  color: #0f1117;
  border: none;
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s;
  align-self: flex-end;
  height: 40px;
  min-width: 140px;
}
.btn-analyze:hover { background: var(--accent-hover); }
.btn-analyze:active { transform: scale(0.97); }
.btn-analyze:disabled {
  background: var(--bg4);
  color: var(--text-muted);
  cursor: not-allowed;
}
.btn-analyze.loading { position: relative; color: transparent; }
.btn-analyze.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px; height: 18px;
  border: 2px solid rgba(15,17,23,0.3);
  border-top-color: #0f1117;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Results section ──────────────────────────────────────────────────────────── */

.results { margin-top: 24px; }
.results.hidden { display: none; }

/* ── Map container ────────────────────────────────────────────────────────────── */

.map-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 0;
}
#route-map {
  width: 100%;
  height: 500px;
  background: var(--bg3);
}

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 10;
}
.map-toggle-btn {
  background: rgba(15,17,23,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.map-toggle-btn.active,
.map-toggle-btn:hover { color: var(--text); background: rgba(15,17,23,0.95); }
.map-toggle-btn.active { color: var(--accent); }

.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(15,17,23,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 8px 12px;
  z-index: 10;
  font-size: 0.75rem;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.legend-row:last-child { margin-bottom: 0; }
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-fullweather-link {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(15,17,23,0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  z-index: 10;
  transition: color 0.15s;
}
.map-fullweather-link:hover { color: var(--accent); }

/* ── Elevation strip ─────────────────────────────────────────────────────────── */

.elevation-wrap {
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  position: relative;
  background: var(--bg2);
  margin-bottom: 24px;
}
#elevation-canvas {
  display: block;
  width: 100%;
  height: 120px;
  cursor: crosshair;
}
.elevation-tooltip {
  position: absolute;
  background: rgba(15,17,23,0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.78rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 20;
  display: none;
}
.elevation-tooltip.visible { display: block; }

/* ── Summary cards ────────────────────────────────────────────────────────────── */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.summary-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.summary-card .card-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}
.summary-card .card-value {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.summary-card .card-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.card-value.wind-head { color: var(--red); }
.card-value.wind-tail { color: var(--green); }
.card-value.wind-cross { color: var(--yellow); }
.card-value.rain-warn { color: var(--blue-light); }

/* ── Detail table ─────────────────────────────────────────────────────────────── */

.detail-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 24px;
}
.detail-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s;
}
.detail-toggle:hover { background: var(--bg3); }
.detail-toggle .toggle-icon {
  width: 16px; height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.detail-toggle.open .toggle-icon { transform: rotate(180deg); }
.detail-table-wrap {
  display: none;
  overflow-x: auto;
}
.detail-table-wrap.open { display: block; }
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.detail-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.detail-table td {
  padding: 7px 12px;
  border-bottom: 1px solid rgba(42,47,62,0.5);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--text-muted);
}
.detail-table tr:last-child td { border-bottom: none; }
.detail-table tr:hover td { background: var(--bg3); }
.detail-table td.wind-impact { font-weight: 600; }
.detail-table td.wind-head { color: var(--red); }
.detail-table td.wind-tail { color: var(--green); }
.detail-table td.wind-cross { color: var(--yellow); }
.detail-table td.wind-calm { color: var(--text-muted); }

/* ── Surface card ─────────────────────────────────────────────────────────────── */

.surface-card {
  grid-column: 1 / -1;  /* spans full width of summary grid */
}
.surf-bar {
  display: flex;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  margin: 6px 0 8px;
  gap: 1px;
}
.surf-seg {
  transition: width 0.4s ease;
}
.surf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.surf-item {
  display: flex;
  align-items: center;
  gap: 5px;
}
.surf-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.surf-cell {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  white-space: nowrap;
}
.surf-cell .surf-dot {
  width: 8px;
  height: 8px;
}

/* ── Share section ────────────────────────────────────────────────────────────── */

.share-section {
  display: none;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.share-section.visible { display: flex; }
.btn-share {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.btn-share:hover {
  border-color: var(--accent);
  background: var(--bg3);
}
.btn-share:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-share.loading { color: transparent; }
.btn-share.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.share-url-wrap {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1;
  min-width: 200px;
}
.share-url-wrap.visible { display: flex; }
.share-url {
  flex: 1;
  font-size: 0.82rem;
  color: var(--accent);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-copy {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.78rem;
  transition: color 0.15s;
  white-space: nowrap;
}
.btn-copy:hover { color: var(--text); }
.btn-copy.copied { color: var(--green); }
.share-ttl-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: none;
}
.share-ttl-note.visible { display: inline; }

/* ── Loading overlay ──────────────────────────────────────────────────────────── */

.loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(15,17,23,0.7);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.loading-overlay.visible { display: flex; }
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Share banner (for loaded shared routes) ─────────────────────────────────── */

.shared-banner {
  background: rgba(96,165,250,0.08);
  border: 1px solid rgba(96,165,250,0.25);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  display: none;
}
.shared-banner.visible { display: block; }

/* ── ol overrides ─────────────────────────────────────────────────────────────── */

.ol-viewport { border-radius: 0; }
.ol-attribution { display: none; }

/* ── Responsive ───────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  #route-map { height: min(60vh, 380px); }

  .summary-grid { grid-template-columns: repeat(2, 1fr); }

  .controls-panel { gap: 12px; }
  .ctrl-group { min-width: 120px; }

  .page-hero h1 { font-size: 1.4rem; }

  .map-legend { display: none; }

  .detail-section { display: block; }

  .import-link-row { flex-direction: column; }
  .btn-import { align-self: flex-start; }
}

@media (max-width: 400px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .page-wrap { padding: 20px 12px 48px; }
}
