/* ADAM Lab widgets — shared base for the sheet-driven widgets
   (publications, patents, awards, members, projects, talks, gallery).
   Palette/fonts come from tokens.css (= hero animation). Each Sites page
   gets its own layout file on top of this (see widgets/<name>/). */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

/* Hosted inside adam-lab pages: document shell (html/body) is owned by css/site.css.
   Widget chrome below targets .ax-* / panel roots only. */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.ax-root {
  container-type: inline-size;
  container-name: ax;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(10px, 2.4vw, 24px) clamp(10px, 2.6vw, 28px) clamp(16px, 3vw, 32px);
}

/* ---------- toolbar ---------- */
.ax-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px 0;
  margin-bottom: 6px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.ax-bar .ax-grow { flex: 1 1 auto; }
/* Narrow embeds keep the bar sticky but compact: chip rows scroll sideways
   on one line instead of wrapping, so the bar stays ~1–2 rows tall. */
@container ax (max-width: 600px) {
  .ax-bar { padding: 6px 0; gap: 6px; margin-bottom: 4px; }
  .ax-bar .ax-chips { flex: 1 1 auto; }
}

.ax-chips {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 1px;
}
.ax-chips::-webkit-scrollbar { display: none; }

.ax-chip {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s var(--ease), color 0.15s var(--ease), background 0.15s var(--ease);
}
.ax-chip:hover { border-color: var(--navy); color: var(--navy); }
.ax-chip[aria-pressed="true"] {
  border-color: var(--navy);
  color: var(--navy);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--navy);
}
.ax-chip .n {
  font-size: 10px;
  color: var(--ink-dim);
  font-weight: 500;
}
.ax-chip[aria-pressed="true"] .n { color: var(--navy); }
.ax-chip .ko { font-family: var(--font-body); text-transform: none; letter-spacing: 0; font-size: 12px; }

.ax-search {
  position: relative;
  flex: 1 1 220px;
  min-width: 160px;
  max-width: 360px;
}
.ax-search input {
  width: 100%;
  height: 32px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 30px 0 32px;
  font: 13px var(--font-body);
  color: var(--ink);
  border-radius: 0;
  outline: none;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.ax-search input::placeholder { color: var(--ink-faint); }
.ax-search input:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(16, 43, 134, 0.08); }
.ax-search svg {
  position: absolute; left: 10px; top: 50%; width: 14px; height: 14px;
  transform: translateY(-50%); color: var(--ink-faint); pointer-events: none;
}
.ax-search .ax-clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border: 0; background: none; cursor: pointer;
  color: var(--ink-faint); font-size: 16px; line-height: 1;
}
.ax-search .ax-clear:hover { color: var(--navy); }

.ax-select {
  height: 32px;
  border: 1px solid var(--line);
  background: #fff;
  font: 12px var(--font-mono);
  color: var(--ink-dim);
  padding: 0 26px 0 10px;
  border-radius: 0;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-faint) 50%), linear-gradient(135deg, var(--ink-faint) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
  cursor: pointer;
}
.ax-select:focus { border-color: var(--navy); outline: none; }

/* ---------- type ---------- */
.ax-kicker {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--navy);
}
.ax-mono { font-family: var(--font-mono); }
.ax-dim { color: var(--ink-dim); }
.ax-faint { color: var(--ink-faint); }

.au-pi { color: var(--ink); font-weight: 700; }

/* ---------- small parts ---------- */
.ax-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 4px 7px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  background: #fff;
  white-space: nowrap;
}
.ax-badge.award { border-color: var(--accent); color: var(--accent-ink); background: #fff8ec; }
.ax-badge.award::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.ax-badge.navy { border-color: var(--navy); color: var(--navy); }
.ax-badge.solid { background: var(--navy); border-color: var(--navy); color: #fff; }
.ax-badge.dash { border-style: dashed; color: var(--blue); border-color: var(--blue); }
.ax-badge.ko { font-family: var(--font-body); letter-spacing: 0; font-size: 11px; }

.ax-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--navy);
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px 7px;
  line-height: 1;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
.ax-link:hover { border-color: var(--navy); background: #f6f8ff; }
.ax-link::after { content: "↗"; font-size: 10px; }

.ax-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

/* ---------- states ---------- */
.adam-state {
  margin: 24px 0;
  padding: 18px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink-dim);
  font-size: 13px;
  text-align: center;
}
.ax-skel {
  height: 64px;
  margin: 10px 0;
  border: 1px solid var(--line-soft);
  background: linear-gradient(90deg, #fff 0%, #f6f7fb 50%, #fff 100%);
  background-size: 200% 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .ax-skel { animation: ax-shimmer 1.2s linear infinite; }
  .ax-in { animation: ax-in 0.4s var(--ease) both; }
}
@keyframes ax-shimmer { to { background-position: -200% 0; } }
@keyframes ax-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

mark { background: #ffe9c4; color: inherit; padding: 0 1px; }

/* ---------- short iframes ----------
   Google Sites scales an embed's height with its width, so on a phone a
   widget may get only ~250–400px. The document scrolls inside the iframe;
   keep the sticky bar to one or two thin rows and drop decorative heads
   (histogram, sparkline, big totals) so the list is visible at once. */
@media (max-height: 520px) {
  .ax-root { padding-top: 4px; padding-bottom: 12px; }
  .ax-bar { padding: 5px 0; gap: 6px; margin-bottom: 4px; }
  .ax-chip { padding: 6px 8px; }
  .ax-search { min-width: 120px; }
  .ax-search input, .ax-select { height: 30px; }
}

/* ---------- phone embeds (html.ax-pe, set by sheet-loader.js) ----------
   Google Sites keeps the desktop box's aspect ratio on phones, so a list
   widget gets ~355×200–350px. pe mode: decorative heads hidden (per widget),
   ONE sticky bar row — chip groups become native selects (.ax-pe-sel), search
   (+ secondary filters marked .ax-pe-more) folds behind the magnifier, and an
   "open in a new tab" button (.ax-pe-open) is always at the right. The list
   ends with a full-width "new tab, full screen" link (.ax-pe-end). */
.ax-pe-sel, .ax-pe-icon, .ax-pe-open, .ax-pe-end, .ax-fullhead { display: none; }

html.ax-pe { background-size: 10vw 10vw; }
html.ax-pe body { font-size: 13px; }
html.ax-pe .ax-root { padding: 0 10px 10px; }
html.ax-pe .ax-bar {
  flex-wrap: nowrap;
  gap: 6px;
  padding: 6px 0;
  margin: 0 0 2px;
  background: rgba(255, 255, 255, 0.96);
}
html.ax-pe .ax-bar > .ax-chips,
html.ax-pe .ax-bar > .ax-count,
html.ax-pe .ax-bar > .ax-grow,
html.ax-pe .ax-bar > .ax-search,
html.ax-pe .ax-bar > .pj-sep { display: none; }
html.ax-pe .ax-bar > * { flex: 0 0 auto; order: 0; }
html.ax-pe .ax-bar > .ax-select { display: block; flex: 1 1 0; min-width: 0; max-width: 180px; height: 30px; text-overflow: ellipsis; }
html.ax-pe .ax-bar > .ax-select[hidden] { display: none; }
html.ax-pe .ax-bar:not(.pe-search) > .ax-pe-more { display: none; }
html.ax-pe .ax-bar > .ax-select { font: 500 12.5px var(--font-body); color: var(--ink); }
html.ax-pe .ax-bar > .ax-chip { padding: 0 8px; height: 30px; }
html.ax-pe .ax-pe-icon,
html.ax-pe .ax-pe-open {
  display: inline-grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
}
html.ax-pe .ax-pe-icon { position: relative; }
html.ax-pe .ax-pe-icon.on::after { content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
html.ax-pe .ax-pe-icon[aria-expanded="true"] { border-color: var(--navy); box-shadow: inset 0 0 0 1px var(--navy); }
html.ax-pe .ax-pe-open { margin-left: auto; border-color: var(--navy); }
html.ax-pe .ax-pe-open:hover, html.ax-pe .ax-pe-open:focus-visible { background: var(--navy); color: #fff; }
html.ax-pe .ax-pe-open.floating {
  position: fixed; top: 6px; right: 6px; z-index: 30;
  width: 26px; height: 26px; background: rgba(255, 255, 255, 0.94);
}
/* magnifier open: search (and .ax-pe-more filters) on a second row */
html.ax-pe .ax-bar.pe-search { flex-wrap: wrap; }
html.ax-pe .ax-bar.pe-search::before { content: ""; order: 49; flex: 0 0 100%; height: 0; }   /* line break before the search row */
html.ax-pe .ax-search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
html.ax-pe .ax-bar.pe-search > .ax-search { display: block; order: 50; flex: 1 1 150px; min-width: 0; max-width: none; }
html.ax-pe .ax-bar.pe-search > .ax-search input { height: 30px; }
html.ax-pe .ax-bar.pe-search > .ax-pe-more { display: block; order: 51; flex: 0 1 auto; max-width: 40%; }
html.ax-pe .ax-bar.pe-search > .ax-chip.ax-pe-more { display: inline-flex; }

html.ax-pe .ax-pe-end {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 14px 0 2px;
  padding: 10px;
  border: 1px dashed var(--navy);
  background: rgba(255, 255, 255, 0.94);
  color: var(--navy);
  font: 600 12.5px var(--font-body);
  text-decoration: none;
}
html.ax-pe .ax-pe-end .ar { font-family: var(--font-mono); }
html.ax-pe.ax-pe-fits .ax-pe-end { display: none; }
.ax-pe-mark { display: none; }
html.ax-pe .ax-pe-mark { display: block; height: 0; }
html.ax-pe .ax-pe-end:hover { background: #f6f8ff; }
html.ax-pe .adam-state { margin: 10px 0; padding: 12px; }
html.ax-pe .ax-skel { height: 48px !important; margin: 6px 0; }

/* "more below" fade at the bottom edge of the iframe */
html.ax-pe body::after {
  content: "";
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 18px;
  background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
html.ax-pe.ax-pe-below body::after { opacity: 1; }

/* ?full=1 — the new-tab view: page title strip, normal (non-pe) layout */
html.ax-full .ax-fullhead {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 4px 0 10px;
  margin-bottom: 4px;
  border-bottom: 2px solid var(--navy);
}
html.ax-full .ax-fullhead .t { font-size: 18px; font-weight: 700; color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
