@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════════════════════
   KAPNOFLYER — app.css
   Dark Mode · Aviation Blue · Space Grotesk + JetBrains Mono
═══════════════════════════════════════════════════════ */

:root {
  --bg-base:      #070b12;
  --bg-surface:   #0b1520;
  --bg-header:    #060910;
  --bg-row-hover: #0e1e30;
  --accent:       #38bdf8;
  --accent-hi:    #7dd3fc;
  --accent-dim:   rgba(56,189,248,0.09);
  --border:       #172a40;
  --border-hi:    #264a6c;
  --text-1:       #e2e8f0;
  --text-2:       #94a3b8;
  --text-3:       #3d5570;
  --green:        #34d399;
  --font-ui:      'Space Grotesk', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-1);
  font-family: var(--font-ui);
  min-height: 100vh;
}

/* ═══════════════════════════════
   MOBILE WALL
═══════════════════════════════ */
.mobile-wall {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(ellipse 80% 55% at 50% 15%, #0c2040 0%, var(--bg-base) 70%);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 2rem;
  text-align: center;
}
.mw-icon  { font-size: 3.5rem; line-height: 1; }
.mw-title { font-size: 1.5rem; font-weight: 700; color: var(--accent); line-height: 1.3; }
.mw-sub   { color: var(--text-2); font-size: 0.93rem; line-height: 1.65; max-width: 290px; }
.mw-hint  {
  display: flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--border-hi); border-radius: 8px;
  padding: 0.65rem 1.1rem; font-size: 0.82rem;
  color: var(--accent-hi); background: var(--accent-dim);
}

@keyframes rotate-hint {
  0%   { transform: rotate(0deg); }
  30%  { transform: rotate(90deg); }
  60%  { transform: rotate(90deg); }
  100% { transform: rotate(0deg); }
}
.mw-rotate-icon {
  font-size: 3.5rem; line-height: 1;
  display: inline-block;
  animation: rotate-hint 2.5s ease-in-out infinite;
}

/* Portrait → show rotate wall, hide app */
@media (max-width: 1099px) and (orientation: portrait) {
  .mobile-wall { display: flex; }
  .desktop-app { display: none !important; }
}

/* Landscape on mobile → hide wall, show scaled-down app */
@media (max-width: 1099px) and (orientation: landscape) {
  .mobile-wall { display: none !important; }
  .desktop-app { display: flex !important; }

  /* Header: not sticky, scrolls with page, no MSFS logo */
  .app-header { position: static !important; box-shadow: none; }
  .app-header-start { display: none !important; }
  .app-header-inner { padding: 0.25rem 0.5rem; gap: 0.5rem; }
  .app-header-search-wrap { max-width: none; }
  .logo-kpn { height: 26px; }
  .header-search { font-size: 0.75rem; padding: 0.25rem 0.5rem 0.25rem 1.8rem; }

  /* Table */
  #avioaneTable { font-size: 0.75rem; width: auto !important; min-width: 0 !important; table-layout: auto !important; }
  #avioaneTable thead th { font-size: 0.68rem; padding: 0.35rem 0.3rem; width: auto !important; min-width: 0 !important; max-width: none !important; }
  #avioaneTable tbody td { padding: 0.15rem 0.3rem; font-size: 0.75rem; width: auto !important; min-width: 0 !important; max-width: none !important; }
  #avioaneTable td:nth-child(2) { font-size: 0.75rem; min-width: 100px !important; }

  /* Hide: Year(3), AP(4), T/O(8), Stall(9), Cruise(11) */
  #avioaneTable th:nth-child(3),
  #avioaneTable td:nth-child(3),
  #avioaneTable th:nth-child(4),
  #avioaneTable td:nth-child(4),
  #avioaneTable th:nth-child(8),
  #avioaneTable td:nth-child(8),
  #avioaneTable th:nth-child(9),
  #avioaneTable td:nth-child(9),
  #avioaneTable th:nth-child(11),
  #avioaneTable td:nth-child(11) { display: none; }

  /* Images small */
  .thumb { height: 43px !important; width: auto !important; }

  /* Badges */
  .badge { font-size: 0.65rem; padding: 2px 5px; }

  /* Filters */
  select.flt { font-size: 0.68rem; max-width: 72px; padding: 2px 3px; }
  .filter-lbl { font-size: 0.68rem; }
  .filter-cell { gap: 2px; }
  .sort-btn { font-size: 0.6rem; }

  /* Meta + wrap */
  .table-meta { font-size: 0.7rem; padding: 0.2rem 0.2rem 0.3rem; }
  .table-wrap  { padding: 0.3rem; }
}

/* Header + table + row counter share one width (intrinsic table width), centered on page */
.desktop-app {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}
.main-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: max-content;
  max-width: 100%;
  min-width: 0;
}

/* ═══════════════════════════════
   HEADER
═══════════════════════════════ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 500;
  border-bottom: 1px solid var(--border);
  background: var(--bg-header);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}
/* Same width as .main-column (driven by table) */
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.55rem 1rem;
  box-sizing: border-box;
}
.app-header-start,
.app-header-end {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.app-header-search-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
  max-width: 520px;
  margin: 0 auto;
}
.header-search {
  width: 100%;
  background: #04080f;
  color: var(--text-1);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  padding: 0.5rem 0.85rem 0.5rem 2.35rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='5.5'/%3E%3Cpath d='M12.5 12.5L16 16'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.65rem 50%;
  background-size: 18px 18px;
}
.header-search::placeholder { color: var(--text-3); }
.header-search:hover { border-color: rgba(56, 189, 248, 0.45); }
.header-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
/* Clear (WebKit) – keep readable */
.header-search::-webkit-search-cancel-button {
  filter: invert(0.65);
  cursor: pointer;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.logo-msfs { height: 55px; cursor: pointer; display: block; }
.logo-kpn  { height: 50px; display: block; }

/* Lead above table — SERP-friendly summary text for crawlers and users */
.intro-lead {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.45rem;
  padding: 0.35rem 1rem 0;
  text-align: center;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--text-2);
}

/* ═══════════════════════════════
   TABLE WRAPPER + META
═══════════════════════════════ */
.table-wrap {
  padding: 1.1rem 1rem 0.5rem;
  width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-meta {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-3);
  text-align: right;
  padding: 0.35rem 0.25rem 0.6rem;
  letter-spacing: 0.04em;
  width: 100%;
  box-sizing: border-box;
}

/* ═══════════════════════════════
   TABLE
═══════════════════════════════ */
#avioaneTable {
  /* Intrinsic width; .main-column matches this width so header/meta align */
  width: max-content;
  border-collapse: collapse;
  font-family: var(--font-ui);
  font-size: 1.05rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* thead */
#avioaneTable thead tr {
  background: linear-gradient(160deg, #091c34 0%, #0b2340 100%);
  border-bottom: 2px solid var(--accent);
}
#avioaneTable thead th {
  padding: 0.7rem 0.6rem;
  color: var(--accent-hi);
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: middle;
  white-space: nowrap;
}

/* tbody rows */
#avioaneTable tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
#avioaneTable tbody tr:last-child { border-bottom: none; }
#avioaneTable tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
#avioaneTable tbody tr:hover { background: var(--bg-row-hover); }

#avioaneTable tbody td {
  padding: 0.5rem 0.6rem;
  vertical-align: middle;
}

/* Column specifics */
/* 1 — row # */
#avioaneTable td:nth-child(1) {
  text-align: center; width: 38px;
  color: var(--text-3);
  font-family: var(--font-mono); font-size: 0.95rem;
}
/* 2 — Aircraft name */
#avioaneTable td:nth-child(2) { font-weight: 600; min-width: 200px; font-size: 1.08rem; }
/* 3 — Year */
#avioaneTable td:nth-child(3) {
  text-align: center;
  font-family: var(--font-mono); font-size: 1rem; color: var(--text-2);
}
/* 4 — AP */
#avioaneTable td:nth-child(4) { text-align: center; }
/* 5 — Type */
#avioaneTable td:nth-child(5) { text-align: center; font-size: 1rem; color: var(--text-2); }
/* 6,7 — images: no horizontal padding between them so they sit flush */
#avioaneTable td:nth-child(6) { text-align: center; padding: 0.3rem 0 0.3rem 0.6rem; }
#avioaneTable td:nth-child(7) { text-align: center; padding: 0.3rem 0.6rem 0.3rem 0; }
/* 8,9,10,11 — speeds */
#avioaneTable td:nth-child(8),
#avioaneTable td:nth-child(9),
#avioaneTable td:nth-child(10),
#avioaneTable td:nth-child(11) {
  text-align: center;
  font-family: var(--font-mono); font-size: 1.05rem; color: var(--accent-hi);
}
/* dim dash/empty speeds */
#avioaneTable td:nth-child(8):empty,
#avioaneTable td:nth-child(9):empty,
#avioaneTable td:nth-child(10):empty,
#avioaneTable td:nth-child(11):empty { opacity: 0.25; }

/* 12 — Edition */
#avioaneTable td:nth-child(12) { text-align: center; }

/* ═══════════════════════════════
   SORT BUTTONS
═══════════════════════════════ */
.col-h {
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.col-h-left { justify-content: flex-start; }
.sort-btns  { display: flex; flex-direction: column; gap: 0; }
.sort-btn {
  background: none; border: none;
  color: var(--text-3); cursor: pointer;
  font-size: 0.78rem; line-height: 1;
  padding: 1px 2px;
  transition: color 0.12s;
}
.sort-btn:hover { color: var(--accent); }

/* ═══════════════════════════════
   FILTER HEADER CELLS
═══════════════════════════════ */
.filter-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.filter-lbl  {
  font-size: 0.95rem; color: var(--accent-hi);
  text-transform: uppercase; letter-spacing: 0.06em;
}
select.flt {
  background: #04080f; color: var(--text-1);
  border: 1px solid var(--border-hi); border-radius: 4px;
  padding: 3px 6px; font-size: 0.9rem; font-family: var(--font-ui);
  outline: none; cursor: pointer; max-width: 110px;
}
select.flt:hover, select.flt:focus { border-color: var(--accent); }
/* Fix option background in dark mode */
select.flt option { background: #0a1525; }

/* ═══════════════════════════════
   AP INDICATOR
═══════════════════════════════ */
.ap-yes {
  color: var(--green);
  text-shadow: 0 0 7px rgba(52,211,153,0.65);
  font-size: 1rem;
}
.ap-no { color: var(--text-3); font-size: 1.1rem; }

/* ═══════════════════════════════
   THUMBNAIL
═══════════════════════════════ */
/* Exterior thumbs (col 7) — white bg so transparent PNGs are visible */
#avioaneTable td:nth-child(7) .thumb {
  background: #ffffff;
  padding: 2px;
  border-radius: 3px;
}

/* Anchor must be block so the img cell doesn't collapse */
a.lightbox-trigger {
  display: block;
  line-height: 0;     /* remove inline-gap below img */
}

.thumb {
  height: 170px; width: auto;
  border-radius: 3px; display: block;
  cursor: zoom-in;
  transition: opacity 0.13s, transform 0.13s;
  border: 1px solid var(--border);
}
.thumb:hover { opacity: 0.82; transform: scale(1.06); border-color: var(--accent); }

/* ═══════════════════════════════
   EDITION BADGES
═══════════════════════════════ */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 4px;
  font-size: 0.88rem; font-weight: 600; font-family: var(--font-mono);
  white-space: nowrap; letter-spacing: 0.02em;
}
.b-std  { background:#0e2030; color:#7dd3fc; border:1px solid #1b3a55; }
.b-dlx  { background:#180f2e; color:#a78bfa; border:1px solid #2c1d50; }
.b-prm  { background:#0a2018; color:#4ade80; border:1px solid #163628; }
.b-su7  { background:#221208; color:#fb923c; border:1px solid #3a200e; }
.b-su11 { background:#1e1600; color:#fbbf24; border:1px solid #342600; }
.b-tg   { background:#1c0808; color:#f87171; border:1px solid #381214; }
.b-frd  { background:#081818; color:#22d3ee; border:1px solid #0c2828; }

/* ═══════════════════════════════
   LIGHTBOX
═══════════════════════════════ */
#lightbox-container {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(3,6,14,0.93);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex-direction: column; align-items: center; justify-content: center;
  gap: 0.7rem;
}
#lightbox-container.lb-open { display: flex; }

#lightbox-image {
  max-width: 90vw; max-height: 78vh;
  border-radius: 5px; object-fit: contain;
  box-shadow: 0 0 80px rgba(56,189,248,0.10);
  cursor: zoom-in;
  transition: transform 0.22s ease;
}
#lightbox-image.lb-zoomed { transform: scale(2.2); cursor: zoom-out; }

/* Exterior images: white card behind the PNG so aviation colours show */
#lightbox-container.lb-exterior #lightbox-image {
  background: #ffffff;
  padding: 18px 28px;
  border-radius: 8px;
  box-shadow: 0 0 80px rgba(255,255,255,0.08);
}

#lightbox-title {
  color: var(--accent-hi); font-family: var(--font-ui);
  font-weight: 600; font-size: 1.25rem; letter-spacing: 0.04em;
  text-align: center; padding: 0 3rem;
}

.lb-close {
  position: absolute; top: 0.9rem; right: 1.1rem; z-index: 2;
  background: rgba(56,189,248,0.05); border: 1px solid var(--border-hi);
  border-radius: 6px; color: var(--text-2);
  font-size: 1.6rem; line-height: 1;
  width: 42px; height: 42px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.13s, color 0.13s;
}
.lb-close:hover { background: rgba(56,189,248,0.18); color: var(--accent); }

.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  background: rgba(56,189,248,0.05); border: 1px solid var(--border-hi);
  border-radius: 6px; color: var(--text-2);
  font-size: 2.6rem; line-height: 1;
  width: 52px; height: 80px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.13s, color 0.13s; user-select: none;
}
.lb-nav:hover { background: rgba(56,189,248,0.18); color: var(--accent); }
#lightbox-previous { left: 0.7rem; }
#lightbox-next     { right: 0.7rem; }

/* ═══════════════════════════════
   FOOTER
═══════════════════════════════ */
.app-footer {
  align-self: stretch;
  width: 100%;
  text-align: center; padding: 1.2rem 1rem; margin-top: 0.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-3); font-size: 0.9rem; font-family: var(--font-mono);
  box-sizing: border-box;
}
