/* Layout: one-screen cockpit column. ND display unit on top (square, ARC mode),
   waypoint card fills the rest and scrolls, EFIS-style pushbuttons pinned below. */

@font-face { font-family: "B612"; font-weight: 400; font-display: swap; src: url("/assets/fonts/b612-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "B612"; font-weight: 700; font-display: swap; src: url("/assets/fonts/b612-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "B612 Mono"; font-weight: 400; font-display: swap; src: url("/assets/fonts/b612-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "B612 Mono"; font-weight: 700; font-display: swap; src: url("/assets/fonts/b612-mono-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  --panel: #23282c;      /* cockpit panel grey */
  --panel-hi: #31373c;
  --bezel: #121517;
  --screen: #000;
  --nd-white: #f1f3f2;
  --nd-green: #3fe36b;
  --nd-cyan: #3fd8f2;
  --nd-yellow: #ffe23a;
  --nd-magenta: #ff4fe6;
  --text: #e6eae8;
  --text-dim: #9aa5a2;
  --font-display: "B612", "Segoe UI", system-ui, sans-serif;
  --font-mono: "B612 Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--panel);
  color: var(--text);
  font: 14px/1.4 var(--font-display);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  -webkit-text-size-adjust: 100%;
}
html.js body { overflow: hidden; }
html:not(.js) .app { display: none; }
html.js .fallback { display: none; }
[hidden] { display: none !important; }

.app {
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding-block: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em;
  color: var(--text-dim); text-transform: uppercase;
}
.topbar > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar strong { color: var(--text); font-weight: 700; }
.chip {
  border: 1px solid var(--nd-cyan); color: var(--nd-cyan);
  padding: 2px 6px; border-radius: 3px; font-size: 10px; white-space: nowrap;
}

/* Display unit */
.du {
  align-self: center;
  width: min(100%, 56vh);
  width: min(100%, 56dvh);
  aspect-ratio: 1;
  max-width: 100%;
  background: var(--bezel);
  border-radius: 10px;
  padding: 6px;
  box-shadow: inset 0 0 0 1px #000, 0 1px 0 var(--panel-hi);
  flex-shrink: 0;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.du svg { display: block; width: 100%; height: 100%; background: var(--screen); border-radius: 4px; }
.nd text { font-family: var(--font-mono); }

/* Waypoint card */
.card {
  flex: 1; min-height: 0; overflow-y: auto;
  background: var(--bezel);
  border-radius: 8px;
  padding: 14px 16px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.card-meta {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 13px; letter-spacing: .06em;
}
.wpt { color: var(--nd-green); font-weight: 700; font-size: 15px; }
.date { color: var(--nd-cyan); }
.seq { margin-left: auto; color: var(--text-dim); font-size: 11px; }
.card h2 {
  margin: 0; font-size: 21px; line-height: 1.25; font-weight: 700;
  color: var(--nd-white); text-wrap: balance;
}
.card img {
  width: 100%; max-height: 160px; object-fit: cover; border-radius: 4px; display: block;
}
.tag {
  align-self: flex-start;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em;
  color: var(--nd-magenta); border: 1px solid var(--nd-magenta);
  padding: 2px 6px; border-radius: 3px;
}
.card p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--text); max-width: 62ch; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 4px; }
.more { color: var(--nd-cyan); font-size: 14px; }
.share {
  background: none; border: 1px solid var(--text-dim); color: var(--text); border-radius: 4px;
  font: 700 11px var(--font-mono); letter-spacing: .1em; padding: 8px 10px; cursor: pointer;
}
.share-note { font: 11px var(--font-mono); color: var(--nd-green); letter-spacing: .08em; }
.transit {
  font-family: var(--font-mono); color: var(--nd-green); font-size: 14px; letter-spacing: .06em;
  display: flex; flex-direction: column; gap: 6px;
}
.transit .big { font-size: 22px; color: var(--nd-white); }
.transit .dim { color: var(--text-dim); font-size: 12px; }
.cta {
  display: inline-block;
  font: 700 14px var(--font-display); letter-spacing: .04em; text-decoration: none;
  background: var(--nd-green); color: #04140a; border-radius: 6px;
  padding: 12px 16px;
}
.fade-in { animation: fade .35s ease-out; }
@keyframes fade { from { opacity: .2; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* EFIS-style pushbuttons */
.controls { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; flex-shrink: 0; }
.pb {
  min-height: 52px; padding: 6px 14px;
  background: linear-gradient(#3a4146, #2b3034);
  border: 1px solid #0d0f10; border-radius: 6px;
  box-shadow: inset 0 1px 0 #4a5257, 0 2px 0 #0d0f10;
  color: var(--text); cursor: pointer;
  font: 700 13px var(--font-mono); letter-spacing: .1em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  -webkit-tap-highlight-color: transparent;
}
.pb::after { content: ""; width: 26px; height: 3px; border-radius: 2px; background: #11161a; }
.pb.lit::after { background: var(--nd-green); box-shadow: 0 0 6px var(--nd-green); }
.pb:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 1px 0 #4a5257, 0 1px 0 #0d0f10; }
.pb:disabled { color: #5d666a; cursor: default; }
.pb:focus-visible, .cta:focus-visible, .row:focus-visible, .close:focus-visible, .share:focus-visible, .more:focus-visible {
  outline: 2px solid var(--nd-cyan); outline-offset: 2px;
}

/* MCDU F-PLN overlay */
.fpln {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0, 0, 0, .6);
  display: flex; align-items: flex-end; justify-content: center;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.mcdu {
  width: 100%; max-width: 520px; max-height: 80%;
  background: var(--screen); border: 6px solid var(--bezel); border-radius: 10px;
  display: flex; flex-direction: column;
  font-family: var(--font-mono);
}
.mcdu-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; color: var(--nd-white); font-size: 15px; letter-spacing: .1em;
}
.close {
  background: none; border: 1px solid var(--text-dim); color: var(--text); border-radius: 4px;
  font: 700 12px var(--font-mono); letter-spacing: .1em; padding: 8px 10px; cursor: pointer;
}
.cols, .row {
  display: grid; grid-template-columns: 4.5em 1fr 4.2em; gap: 10px; align-items: baseline;
  padding: 0 12px;
}
.cols { color: var(--nd-white); font-size: 11px; letter-spacing: .1em; padding-bottom: 4px; }
.cols .r { text-align: right; }
.rows { overflow-y: auto; padding-bottom: 8px; }
.row {
  width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  font: 14px var(--font-mono); color: var(--nd-green); padding-block: 10px;
  border-top: 1px solid #111;
}
.row .t { color: var(--text); font-family: var(--font-display); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .y { text-align: right; color: var(--nd-green); }
.row.from { color: var(--nd-white); }
.row.from .y::before { content: "FROM "; color: var(--nd-white); font-size: 10px; }
.row.key .id { color: var(--nd-magenta); }
.hint { padding: 6px 12px 12px; color: var(--nd-cyan); font-size: 11px; letter-spacing: .08em; }

/* No-JS fallback */
.fallback { max-width: 62ch; margin: 0 auto; padding-block: 24px; line-height: 1.55; }
.fallback h1 { font-size: 22px; color: var(--nd-white); }
.fallback ol { padding-left: 1.2em; display: grid; gap: 18px; }
.fallback h2 { font-size: 17px; margin: 0 0 4px; color: var(--nd-white); }
.fallback time { font-family: var(--font-mono); color: var(--nd-cyan); font-size: 13px; }
.fallback a { color: var(--nd-cyan); }

@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } }
