/* The Airfoil Library (docs/plan_airfoil_library.md, UI-21/UI-22): the tool's
   world - grey drafting background, translucent rounded boxes - as a
   gallery. A control strip over a grid of airfoil boxes, a compare tray at
   the foot. Light only, like the tool. */

:root {
  --ink: #1d2a38;
  --ink-quiet: #4a5866;
  --accent: #2f6fe0;
  --accent-soft: rgba(47, 111, 224, 0.12);
  --bg: #cfd4da;
  --box: rgba(236, 239, 243, 0.88);
  --box-solid: #eceff3;
  --line: #b4bcc6;
  --foil-fill: #a4a8ae;
  --foil-edge: #14181d;
  --camber: #2f6fe0;
  --chord: #ffffff;
  --tline: #d0312d;
  --axis: rgba(29, 42, 56, 0.12);
  --c1: #e06a23;
  --c2: #1c8f9a;
  --c3: #c2335f;
  --c4: #6a46c4;
  --flag: #6b5b95;
  --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 12px;
  --gutter: 16px;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 160px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px var(--font-ui);
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- header and control strip ---- */

#al-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--box-solid);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top, 0px) max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
}
.al-crumbs { display: flex; align-items: center; gap: 8px; padding-block: 10px; flex-wrap: wrap; }
.al-brand { font-weight: 600; text-decoration: none; }
.al-sep { color: var(--ink-quiet); }
.al-spacer { flex: 1; }
#al-account { font-size: 13px; color: var(--ink-quiet); }

.al-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end; padding-block: 4px 12px; margin: 0; }
.al-ctl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.al-ctl label, .al-lbl { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-quiet); }
.al-hint { text-transform: none; letter-spacing: 0; }
.al-search input { width: 230px; max-width: 70vw; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.al-range { display: flex; align-items: center; gap: 6px; }
.al-range span { color: var(--ink-quiet); }
.al-num { width: 58px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-family: var(--font-num); font-size: 13px; }
.al-num.al-bad { border-color: var(--tline); }
select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.al-sort { display: flex; gap: 4px; }
.al-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.al-chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 13px; }
.al-chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.al-chip .al-n { font-family: var(--font-num); font-size: 12px; color: var(--ink-quiet); margin-left: 4px; }
.al-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.al-seg button { border: 0; background: transparent; padding: 6px 10px; cursor: pointer; }
.al-seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.al-btn { border: 1px solid var(--line); background: var(--box); border-radius: 8px; padding: 6px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
.al-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.al-dir { padding: 6px 9px; }
.al-filters-toggle { display: none; }
.al-admin { display: flex; flex-wrap: wrap; gap: 10px 18px; width: 100%; padding-top: 8px; border-top: 1px dashed var(--line); }
.al-wide { max-width: 100%; }

/* ---- the grid ---- */

main { padding: 14px max(var(--gutter), env(safe-area-inset-right, 0px)) 140px max(var(--gutter), env(safe-area-inset-left, 0px)); }
.al-summary { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; color: var(--ink-quiet); margin-bottom: 8px; }
#al-count strong { color: var(--ink); font-family: var(--font-num); }
.al-credit { margin: 0 0 12px; font-size: 12px; color: var(--ink-quiet); }
.al-credit a { color: var(--ink-quiet); }

.al-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(var(--card-w), 100%), 1fr)); }
.al-size-s { --card-w: 170px; }
.al-size-m { --card-w: 240px; }
.al-size-l { --card-w: 340px; }

.al-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--box);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.al-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); }
.al-card.al-picked { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.al-bar { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.al-name { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
/* The name's link covers the whole box: a click anywhere opens the airfoil,
   and the + stays above it. */
.al-name::after { content: ""; position: absolute; inset: 0; z-index: 2; }
.al-open-tool { position: relative; z-index: 3; font-size: 12px; color: var(--ink-quiet); }
.al-cmp { position: relative; z-index: 3; border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 1px 8px; cursor: pointer; font-size: 13px; }
.al-cmp[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.al-flags { display: flex; flex-wrap: wrap; gap: 4px; padding: 5px 10px 0; }
.al-flag { font-size: 11px; color: #fff; background: var(--flag); border-radius: 4px; padding: 0 5px; }
/* A duplicate's mark that names its match: a button, the same chip, over
   the name's link that covers the box (as the + button). */
button.al-flag { position: relative; z-index: 3; border: 0; font-family: inherit; line-height: inherit; cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.al-flag:hover { text-decoration: underline; }
/* The tags sit in their own strip above the section, so a thick airfoil is
   never under them. */
.al-fig { position: relative; padding-top: 20px; }
.al-tags { position: absolute; top: 4px; right: 8px; z-index: 3; display: flex; gap: 4px; }
.al-tag { font-size: 11px; color: var(--ink-quiet); background: var(--box-solid); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; white-space: nowrap; }
.al-tag.al-status { color: #fff; background: var(--flag); border-color: var(--flag); }
.al-scale { position: absolute; bottom: 4px; right: 8px; z-index: 3; font-family: var(--font-num); font-size: 11px; color: var(--ink-quiet); }
.al-foil { display: block; width: 100%; height: auto; aspect-ratio: 1.08 / 0.32; }
.al-nofit { margin-top: -20px; display: flex; align-items: center; justify-content: center; aspect-ratio: 1.08 / 0.32; color: var(--ink-quiet);
  background: repeating-linear-gradient(45deg, transparent 0 6px, rgba(29, 42, 56, 0.08) 6px 12px); }
.al-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; padding: 6px 10px 8px; font-variant-numeric: tabular-nums; }
.al-nums div { display: flex; align-items: baseline; gap: 5px; min-width: 0; white-space: nowrap; }
.al-nums span { font-size: 12px; color: var(--ink-quiet); }
.al-nums b { font-family: var(--font-num); font-weight: 500; font-size: 13px; }
.al-size-s .al-nums, .al-hide-nums .al-nums { display: none; }
.al-placeholder { min-height: 120px; opacity: 0.5; }
.al-empty { grid-column: 1 / -1; padding: 40px 0; text-align: center; color: var(--ink-quiet); }

.al-pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.al-pager button { min-width: 36px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--box); cursor: pointer; font-family: var(--font-num); }
.al-pager button[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.al-pager button:disabled { opacity: 0.4; cursor: default; }
.al-pager .al-gap { padding: 6px 2px; color: var(--ink-quiet); }

/* ---- the compare tray ---- */

.al-tray {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  background: var(--box-solid);
  border-top: 1px solid var(--line);
  padding: 10px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
}
.al-tray svg { flex: 1 1 320px; min-width: 0; max-width: 640px; height: auto; aspect-ratio: 1.08 / 0.32; }
.al-legend { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.al-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.al-acts { display: flex; gap: 8px; margin-left: auto; }

.al-toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(110px + env(safe-area-inset-bottom, 0px));
  z-index: 7;
  max-width: calc(100% - 32px);
  background: var(--ink);
  color: #fff;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 13px;
}

/* ---- phone: the search keeps its row, the rest folds behind Filters ---- */

@media (max-width: 720px) {
  /* Not sticky on a phone: open, the filters would cover the screen. */
  #al-header { position: static; }
  .al-tray svg { flex-basis: 100%; max-height: 72px; }
  .al-filters-toggle { display: inline-block; }
  .al-controls .al-more { display: none; }
  .al-controls.al-open .al-more { display: flex; }
  .al-search { flex: 1 1 0; }
  .al-search input { width: 100%; max-width: none; }
  .al-acts { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .al-card { transition: none; }
  .al-card:hover { transform: none; }
}
