/* Meteoadriatic viewer — instrument-panel chrome around the map.
   Palette: cool paper grays, ink #14242f, one Adriatic-blue accent. */

:root {
  --bg:        #eceff1;
  --panel:     #ffffff;
  --ink:       #14242f;
  --muted:     #5d6b78;
  --line:      #c9d2d9;
  --accent:    #0d5c80;
  --accent-hi: #0a4a68;
  --fresh:     #2e7d32;
  --aging:     #b26a00;
  --stale:     #b3261e;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mono { font-family: var(--mono); }
button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
button:focus-visible, .ribbon:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 46px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.brand { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.brand-mark {
  font-family: var(--mono);
  font-size: 17px;
  letter-spacing: -0.5px;
}
.brand-mark b { color: var(--accent); font-weight: 500; }
.model-name {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.runinfo { display: flex; align-items: center; gap: 10px; }
.runinfo .mono { font-size: 12.5px; color: var(--muted); }
.run-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
}
.run-dot.fresh { background: var(--fresh); }
.run-dot.aging { background: var(--aging); }
.run-dot.stale { background: var(--stale); }
.lang-toggle {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }
.auth-btn {
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}
.auth-btn:hover { background: var(--accent-hi); }
.auth-btn.signed { background: none; border: 1px solid var(--line); color: var(--muted); font-weight: 400; }
.auth-btn.signed:hover { border-color: var(--stale); color: var(--stale); }
.premium-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 1px;
  padding: 3px 7px;
  border-radius: 3px;
  color: #7a5a00;
  background: #f6e7b0;
  border: 1px solid #e3cd7e;
}

/* ---- layout ---- */
.layout { display: flex; flex: 1; min-height: 0; }

/* ---- sidebar ---- */
.sidebar {
  width: 222px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px 0 30px;
}
.sidebar-close, .sidebar-open { display: none; }
.group-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding: 14px 16px 5px;
}
.product-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 13.5px;
  padding: 5px 16px;
  border-left: 3px solid transparent;
}
.product-btn:hover { background: #f2f5f7; }
.product-btn.active {
  border-left-color: var(--accent);
  background: #e8f0f5;
  font-weight: 500;
  color: var(--accent-hi);
}

/* ---- stage column ---- */
.stage-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sectorbar {
  display: flex;
  gap: 4px;
  padding: 8px 12px 4px;
  overflow-x: auto;
  flex: none;
  scrollbar-width: none;
}
.sector-btn {
  font-size: 12.5px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}
.sector-btn:hover { border-color: var(--accent); color: var(--accent); }
.sector-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.sector-gap { width: 10px; flex: none; }

/* ---- stage ---- */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
}
#mapImage {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 1px 4px rgba(20, 36, 47, 0.18);
  background: #fff;
  user-select: none;
}
.stage-msg {
  position: absolute;
  font-size: 14px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 22px;
}

/* ---- controls ---- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 12px;
  flex: none;
}
.transport { display: flex; gap: 2px; }
.transport button {
  min-width: 34px;
  height: 30px;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
}
.transport button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.transport button:disabled { opacity: 0.35; cursor: default; }
.transport button.playing { background: var(--accent); border-color: var(--accent); color: #fff; }
.transport .speed { font-size: 12px; }
.readout {
  font-size: 13px;
  color: var(--ink);
  white-space: nowrap;
}
.readout b { color: var(--accent); font-weight: 500; }

/* ---- time ribbon (signature) ---- */
.ribbon {
  position: relative;
  height: 56px;
  margin: 2px 12px 10px;
  flex: none;
  cursor: crosshair;
  touch-action: none;
}
#ribbonCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 5px;
}
.ribbon-cursor {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  pointer-events: none;
  transition: left 60ms linear;
}
@media (prefers-reduced-motion: reduce) {
  .ribbon-cursor { transition: none; }
}

/* ---- paywall panel ---- */
.paywall {
  position: absolute;
  max-width: 340px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px 30px;
  box-shadow: 0 4px 24px rgba(20, 36, 47, 0.15);
}
.paywall-lock { font-size: 26px; margin-bottom: 6px; }
.paywall h3 { margin: 0 0 6px; font-size: 16px; }
.paywall p { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); line-height: 1.45; }
.paywall-cta {
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 20px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
}
.paywall-cta:hover { background: var(--accent-hi); }

/* premium lock badge in sidebar (only when enforcement is on) */
.product-btn.locked::after {
  content: "🔒";
  font-size: 10px;
  margin-left: 6px;
  opacity: 0.55;
}

/* ---- sign-in dialog ---- */
.signin {
  width: min(92vw, 340px);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 26px 28px 20px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--sans);
}
.signin::backdrop { background: rgba(20, 36, 47, 0.45); }
.dialog-close {
  position: absolute;
  top: 8px; right: 12px;
  font-size: 20px;
  color: var(--muted);
}
.signin-brand {
  font-family: var(--mono);
  font-size: 18px;
  text-align: center;
  margin-bottom: 18px;
}
.signin-brand b { color: var(--accent); font-weight: 500; }
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
.google-btn:hover { border-color: var(--accent); }
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
  margin: 14px 0;
}
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
#emailForm { display: flex; flex-direction: column; gap: 8px; }
#emailForm input {
  font: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--ink);
}
#emailForm input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.form-err { font-size: 12.5px; color: var(--stale); }
.submit-btn {
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
}
.submit-btn:hover { background: var(--accent-hi); }
.signin-links {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
}
.signin-links a { color: var(--accent); text-decoration: none; }
.signin-links a:hover { text-decoration: underline; }

/* ---- mobile ---- */
@media (max-width: 820px) {
  .sidebar {
    position: fixed;
    z-index: 30;
    top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 4px 0 18px rgba(20, 36, 47, 0.25);
  }
  .sidebar.open { transform: translateX(0); }
  @media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
  }
  .sidebar-close {
    display: block;
    position: absolute;
    top: 4px; right: 8px;
    font-size: 22px;
    color: var(--muted);
  }
  .sidebar-open {
    display: block;
    position: absolute;
    z-index: 20;
    top: 10px; left: 14px;
    width: 38px; height: 38px;
    font-size: 17px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
  }
  .model-name { display: none; }
  .controls { flex-direction: column; gap: 4px; }
  .readout { font-size: 12px; }
}
