/* Maddlink — the shell: stage, header, mode selector, search, tools, footer, prototype pill, notes, filters panel.
   Layout tiers (EXPERIENCE §9): phone < 768 · tablet 768–1127 · desktop ≥ 1128 · wide ≥ 1440. */

/* ---------------------------------------------------------------- the stage: the map never leaves */
html, body { height: 100%; }
body { overflow: hidden; overscroll-behavior: none; }
.stage { position: fixed; inset: 0; z-index: var(--z-map); background: var(--paper); }
.map { position: absolute; inset: 0; }
.map:focus-visible { outline-offset: -3px; }

main {
  position: fixed; left: 0; right: 0; top: var(--header-h); bottom: 0; z-index: var(--z-panel);
  pointer-events: none;
}
main > * { pointer-events: auto; }
main:focus { outline: none; }
.flight { position: fixed; inset: 0; z-index: var(--z-flight); pointer-events: none; overflow: hidden; }

/* ---------------------------------------------------------------- header */
.site-header {
  position: fixed; left: 0; right: 0; top: 0; z-index: var(--z-header); height: var(--header-h);
  box-shadow: 0 1px 0 var(--line); transition: transform 0.55s var(--ease-out);
}
/* the glass lives on a pseudo-element: a backdrop-filter on the header itself would become the containing block of
   its fixed children (the mode dock on tablets and phones would stick to the header instead of the screen) */
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: color-mix(in oklab, var(--paper) 88%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.2); backdrop-filter: blur(16px) saturate(1.2);
}
.is-scrolled .site-header::before { background: color-mix(in oklab, var(--paper) 96%, transparent); }
.header-folded .site-header { transform: translateY(-100%); }
.header-folded main { top: 0; } /* the content rises with the header (shell.fold carries it over 0.55 s) */
.header-row { height: 100%; display: flex; align-items: center; gap: 14px; padding: 0 var(--gutter); }
.brand { display: inline-flex; align-items: center; height: var(--tap); padding: 0 6px; margin-left: -6px; border-radius: var(--r-sm); color: var(--ink); flex: none; }
.brand-wordmark { height: 26px; width: auto; }
.brand-symbol { display: none; height: 34px; width: 34px; }
.brand:hover .logo-arc { stroke: var(--cyan); }

/* search: a cyan magnifier (D33) that unfolds into a white pill, the magnifier at its end; then its suggestion
   panel (MOTION §4) */
.search { position: relative; flex: none; min-width: 0; }
.search-pill {
  display: flex; align-items: center; gap: 4px; width: 48px; height: 48px; padding: 2px; border-radius: var(--r-pill);
  background: transparent; box-shadow: none;
  transition: width 0.55s var(--ease-out), padding 0.55s var(--ease-out), box-shadow 0.35s var(--ease-out), background-color 0.35s;
}
.search.is-open { flex: 0 1 400px; }
.search.is-open .search-pill { width: 100%; padding: 2px 2px 2px 20px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1); }
.search.is-open .search-pill:focus-within { box-shadow: inset 0 0 0 1.5px var(--cyan), 0 0 0 4px var(--cyan-soft), var(--shadow-2); }
.search-go {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin-left: auto; border-radius: 50%;
  background: var(--cyan); color: var(--on-cyan); box-shadow: var(--shadow-1); transition: transform 0.4s var(--ease-out), box-shadow 0.35s;
}
.search-go .icon { width: 20px; height: 20px; }
.search-go:hover { transform: scale(1.06); box-shadow: 0 0 0 5px var(--cyan-soft), var(--shadow-1); }
.search-go:active { transform: scale(0.95); }
.search-input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none;
  font-size: var(--step-0); font-weight: 550; color: var(--ink); text-overflow: ellipsis;
}
.search:not(.is-open) :is(.search-input, .search-clear) { width: 0; flex: 0 0 0; padding: 0; opacity: 0; visibility: hidden; }
.search-input::placeholder { color: var(--ink-muted); font-weight: 500; opacity: 1; }
.search-input:focus-visible { outline: none; } /* the pill shows the focus (one ring, not two) */
.search-input::-webkit-search-cancel-button { display: none; }
.search-clear { width: var(--tap); height: var(--tap); }
.search-panel {
  position: absolute; left: 0; top: calc(100% + 10px); width: max(100%, 520px); max-height: min(70vh, 640px); overflow: auto;
  padding: 10px; border-radius: var(--r-lg); background: var(--card); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-2);
  z-index: var(--z-menu); overscroll-behavior: contain;
}

/* the mode selector: animated icon labels, one sliding pill (premium-motion-website standard) */
.modes { position: relative; display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: var(--r-pill); background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.modes-pill {
  position: absolute; left: 0; top: 4px; height: calc(100% - 8px); width: 0; border-radius: var(--r-pill);
  background: var(--raised); box-shadow: inset 0 0 0 1.5px var(--cyan-deep); opacity: 0; pointer-events: none;
}
.mode-tab {
  position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--tap); min-width: var(--tap); padding: 0 13px 0 11px;
  border-radius: var(--r-pill); color: var(--ink-muted); font-size: var(--step--1); font-weight: 650; white-space: nowrap;
  transition: color 0.35s var(--ease-out);
}
.mode-tab:hover { color: var(--ink); }
.mode-tab[aria-current] { color: var(--ink); }
.mode-tab[aria-current] .mode-icon { color: var(--cyan-deep); }
.mode-tab[aria-disabled="true"] { color: color-mix(in oklab, var(--ink-muted) 70%, var(--paper)); pointer-events: none; }
.mode-icon { display: inline-grid; place-items: center; width: 20px; height: 20px; }
.mode-icon .icon { width: 19px; height: 19px; }
.modes--header { margin-left: auto; }

.header-tools { display: flex; align-items: center; gap: 4px; flex: none; }
.fav-link { position: relative; }
.fav-count {
  position: absolute; right: 2px; top: 3px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: var(--r-pill);
  background: var(--cyan); color: var(--on-cyan); font-size: 11px; font-weight: 750; line-height: 19px; text-align: center;
}
.lang-switch {
  display: inline-flex; align-items: center; justify-content: center; gap: 3px; height: var(--tap); min-width: var(--tap); padding: 0 12px; border-radius: var(--r-pill);
  font-size: var(--step--1); font-weight: 700; letter-spacing: 0.04em; color: var(--ink-muted); transition: background-color 0.3s, color 0.3s;
}
.lang-switch:hover { background: var(--raised); color: var(--ink); }
.lang-current { color: var(--ink); }
.lang-sep { color: var(--line-strong); }
.motion-toggle .mt-play { display: none; }
.is-paused .motion-toggle .mt-pause { display: none; }
.is-paused .motion-toggle .mt-play { display: block; }
.motion-toggle[aria-pressed="true"] { color: var(--cyan-deep); }

/* ---------------------------------------------------------------- footer (inside each scrolling panel) */
.site-footer {
  container-type: inline-size;
  margin-top: 56px; padding: 32px 0 calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--ink-muted);
  font-size: var(--step--1);
}
.footer-rule { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); color: var(--ink); font-size: var(--step-1); line-height: 1.3; max-width: 34ch; margin-bottom: 26px; }
.footer-cols { display: grid; gap: 22px; grid-template-columns: 1fr; }
@container (min-width: 520px) { .footer-cols { grid-template-columns: 1fr 1.6fr 1fr; } }
.site-footer ul { display: grid; gap: 2px; }
.site-footer a { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); min-width: var(--tap); color: var(--ink-soft); transition: color 0.3s; }
.site-footer a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--cyan); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.footer-head { color: var(--ink); font-weight: 650; margin-bottom: 6px; }
.footer-universes ul { grid-template-columns: 1fr; }
@container (min-width: 380px) { .footer-universes ul { grid-template-columns: 1fr 1fr; column-gap: 14px; } }
.footer-uicon { display: inline-grid; width: 14px; height: 14px; color: var(--cyan-deep); }
.footer-uicon .uicon { width: 14px; height: 14px; }
.footer-contact { margin-top: 10px; display: grid; gap: 2px; }
.footer-label { color: var(--ink); font-weight: 650; }
.footer-responsibility { margin-top: 26px; max-width: 62ch; }
.footer-domain { margin-top: 18px; display: inline-flex; align-items: center; gap: 10px; color: var(--ink-soft); font-weight: 650; letter-spacing: 0.01em; }
.footer-symbol { width: 26px; height: 26px; }

/* ---------------------------------------------------------------- the prototype pill (always visible) */
.proto-pill {
  position: fixed; left: calc(var(--list-w) + 16px); bottom: 16px; z-index: var(--z-header); display: inline-flex; align-items: center; gap: 9px;
  height: 36px; padding: 0 8px 0 14px; border-radius: var(--r-pill); background: var(--glass); color: var(--ink-soft);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-1);
  font-size: 12px; font-weight: 650; letter-spacing: 0.02em; white-space: nowrap; transition: color 0.3s, box-shadow 0.3s;
}
.proto-pill:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-muted), var(--shadow-1); }
.proto-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px var(--cyan-glow); }
.proto-notes { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--raised); }
.proto-notes .icon { width: 14px; height: 14px; }

/* ---------------------------------------------------------------- notes drawer (prototype tools) */
.notes {
  position: fixed; right: 12px; top: 12px; bottom: 12px; z-index: var(--z-notes); width: min(420px, calc(100vw - 24px));
  overflow-y: auto; overscroll-behavior: contain; padding: 18px 20px 24px; border-radius: var(--r-lg);
  background: var(--card); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-2); font-size: var(--step--1);
}
.notes[hidden] { display: none; }
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.notes h2 { font-size: var(--step-2); }
.notes h3 { font-size: var(--step-0); margin-bottom: 4px; }
.notes-intro { color: var(--ink-soft); margin-bottom: 18px; }
.notes-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.notes-block legend, .notes-label { display: block; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
/* legends inside the block, not in its border line */
.notes-block legend, .fp-group legend { float: left; width: 100%; }
.notes-block legend + *, .fp-group legend + * { clear: both; }
.notes-small { margin-top: 8px; color: var(--ink-muted); font-size: 12px; }
.notes-select {
  width: 100%; height: 44px; padding: 0 12px; border-radius: var(--r-sm); background: var(--paper); color: var(--ink);
  border: 1px solid var(--line-strong); font-weight: 600;
}
.notes-actions { display: grid; gap: 10px; justify-items: start; }
.journal { margin-top: 10px; display: grid; gap: 6px; max-height: 280px; overflow-y: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; }
.journal li { padding: 8px 10px; border-radius: var(--r-xs); background: var(--paper); color: var(--ink-soft); word-break: break-word; }
.journal b { color: var(--cyan-deep); font-weight: 600; }
.journal-empty { color: var(--ink-muted); }

/* ---------------------------------------------------------------- filters panel */
.filters-panel {
  position: fixed; left: 16px; top: calc(var(--header-h) + 16px); z-index: var(--z-menu); width: min(440px, calc(100vw - 32px));
  max-height: calc(100dvh - var(--header-h) - 32px); overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 20px 20px; border-radius: var(--r-lg); background: var(--card); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-2);
}
.filters-panel[hidden] { display: none; }
.fp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.fp-head h2 { font-size: var(--step-2); }
.fp-group { margin-top: 16px; }
.fp-group legend { font-weight: 700; margin-bottom: 10px; }
.fp-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.fp-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- tiers */
@media (max-width: 1279px) and (min-width: 1128px) {
  .search.is-open { flex-basis: 300px; }
}
@media (max-width: 1127px) {
  /* tablet and phone: the mode selector becomes a floating dock at the bottom (it holds the « Carte » button) */
  .modes--header {
    position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: var(--z-sheet); margin: 0; transform: translateX(-50%);
    background: var(--glass); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); box-shadow: inset 0 0 0 1px var(--line-strong), var(--shadow-2);
  }
  .search { margin-right: auto; }
  .search.is-open { flex: 1 1 auto; max-width: 520px; }
  /* the pill hangs from the header's lower edge, centred, in the content's top margin: in the bottom corner it sat on
     the first card's arrow at 1024 px, and over the universe bar of a phone held sideways, stacked on the dock */
  .proto-pill { left: 50%; bottom: auto; top: calc(var(--header-h) - 4px); transform: translateX(-50%); height: 24px; padding: 0 10px; font-size: 11px; gap: 7px; }
  .proto-notes { display: none; }
  /* the header folds on the way down (phone, tablet): the pill hanging from it leaves with it, all the way (the
     content rises to the top of the screen), and comes back with it */
  .proto-pill { transition: transform 0.55s var(--ease-out), color 0.3s, box-shadow 0.3s; }
  .header-folded .proto-pill { transform: translate(-50%, calc(-1 * var(--header-h) - 28px)); }
  /* the search panel unfolds right under the header: the pill steps aside while it is open */
  .search-open .proto-pill { opacity: 0; pointer-events: none; transition: opacity 0.2s; }
}
@media (max-width: 767px) {
  .header-row { gap: 8px; padding: 0 10px 0 12px; }
  .brand-wordmark { display: none; }
  .brand-symbol { display: block; }
  .search-pill { width: 44px; height: 44px; }
  .search-go { width: 40px; height: 40px; }
  .search.is-open .search-pill { padding-left: 14px; }
  .search-input { font-size: 16px; } /* 16 px: iOS does not zoom into the field */
  .search-panel { position: fixed; left: 8px; right: 8px; top: calc(var(--header-h) + 6px); width: auto; max-height: calc(100dvh - var(--header-h) - 20px); }
  .lang-switch { padding: 0 8px; }
  .lang-current, .lang-sep { display: none; }
  .mode-tab { flex-direction: column; gap: 2px; height: 52px; padding: 0 9px; font-size: 11px; }
  .modes { padding: 4px; }
  .filters-panel { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 80dvh; }
  .notes { left: 8px; right: 8px; top: 8px; bottom: 8px; width: auto; }
}
@media (max-width: 359px) {
  .header-row { gap: 4px; padding: 0 6px 0 8px; }
  .header-tools { gap: 0; }
  .brand-symbol { width: 30px; height: 30px; }
  .lang-switch { padding: 0 6px; }
  .search.is-open .search-pill { padding-left: 10px; }
  .mode-tab { padding: 0 6px; }
}

/* ---------------------------------------------------------------- search suggestions */
.sg-group + .sg-group { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.sg-head { padding: 6px 12px 4px; color: var(--ink-muted); font-size: 11.5px; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.sg-item { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 6px 12px; border-radius: var(--r-sm); cursor: pointer; transition: background-color 0.2s; }
.sg-item[aria-selected="true"], .sg-item:hover { background: var(--raised); }
.sg-item[aria-selected="true"] { box-shadow: inset 0 0 0 1.5px var(--cyan-deep); }
.sg-uicon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); flex: none; }
.sg-uicon .uicon { width: 15px; height: 15px; }
.sg-item > .icon { width: 36px; height: 36px; padding: 8px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-soft); }
.sg-mini { width: 36px; height: 36px; font-size: 0.75rem; }
.sg-text { display: grid; min-width: 0; }
.sg-label { color: var(--ink); font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-sub { color: var(--ink-muted); font-size: var(--step--1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-empty { padding: 14px 12px; color: var(--ink-soft); }
.sg-example { padding: 10px 12px 12px; color: var(--ink-muted); font-size: var(--step--1); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
/* mode Carte on a desktop: the list is a band at the bottom, the pill goes up to the free corner */
@media (min-width: 1128px) {
  html[data-mode="map"] .proto-pill { left: 16px; bottom: auto; top: calc(var(--header-h) + 16px); }
  html[data-mode="map"] .site-header + .stage .map-area-search { top: calc(var(--header-h) + 16px); }
}
