/* =========================================================================
   Magical Item Vault

   Replaces Bootstrap 5 from jsDelivr, a Google Fonts stylesheet, and the
   old css/style.css. That combination cost three extra DNS lookups and
   TLS handshakes before first paint, shipped roughly 200 KB of CSS to
   use perhaps 5% of it, and still left the real problems unsolved: text
   was pure #fff on a mid-tone gradient (failing contrast in places),
   every grid image was forced to a fixed 250x250 box (stretching any
   photo that was not square), and the viewport meta blocked pinch-zoom.

   Everything here is self-hosted, which is what lets bootstrap.php send
   a strict Content-Security-Policy with no exceptions.

   Organisation:
     1. Tokens
     2. Reset and base
     3. Layout primitives
     4. Masthead and navigation
     5. Buttons
     6. Forms and disclosures
     7. Notices and flashes
     8. Page furniture
     9. Grids, tiles and cards
    10. Detail view
    11. Pagination and step navigation
    12. Auth and landing
    13. Footer
    14. Motion and print
   ====================================================================== */

/* -------------------------------------------------------------------------
   1. Tokens
   ---------------------------------------------------------------------- */

@font-face {
  font-family: "Bonheur Royale";
  src: url("/assets/fonts/BonheurRoyale.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand palette, carried over from the original design. */
  --navy-900: #04202f;
  --navy-800: #062c43;
  --navy-700: #0a3a55;
  --navy-600: #1b4965;
  --cyan-300: #8ecae6;
  --teal-500: #219ebc;
  --amber-400: #ffb703;
  --orange-500: #fb8500;

  /* Semantic surfaces. Dark is the default: it is kinder to photographs,
     which are the entire point of this application. */
  --bg: var(--navy-800);
  --bg-sunk: var(--navy-900);
  --surface: rgba(255, 255, 255, .055);
  --surface-hover: rgba(255, 255, 255, .09);
  --surface-solid: #0d3148;
  --border: rgba(142, 202, 230, .2);
  --border-strong: rgba(142, 202, 230, .36);

  /* Text. Deliberately not pure white: #e8f1f7 on --bg clears 13:1,
     and the muted tone still clears 7:1, so both pass AAA for body text
     where the old pure-white-on-gradient did not reliably pass AA. */
  --text: #e8f1f7;
  --text-muted: #a9c4d6;
  --text-faint: #7fa0b5;

  --accent: var(--amber-400);
  --accent-hover: var(--orange-500);
  --accent-ink: #08212f;
  --focus: var(--cyan-300);

  --danger: #ff8080;
  --danger-bg: rgba(255, 92, 92, .13);
  --danger-border: rgba(255, 128, 128, .42);
  --success: #7ee0b0;
  --success-bg: rgba(60, 200, 140, .13);
  --success-border: rgba(126, 224, 176, .4);
  --info-bg: rgba(142, 202, 230, .12);

  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 16px;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -8px rgba(0, 0, 0, .45);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, .3), 0 16px 36px -12px rgba(0, 0, 0, .55);

  --shell: 76rem;
  --gap: 1.25rem;

  --font: 400 1rem/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Bonheur Royale", "Brush Script MT", cursive;

  color-scheme: dark light;
}

/* A light rendering for anyone whose system asks for one. The palette
   keeps the same hues so the product still looks like itself. */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f8fb;
    --bg-sunk: #e6eff5;
    --surface: #ffffff;
    --surface-hover: #f7fbfd;
    --surface-solid: #ffffff;
    --border: rgba(10, 58, 85, .16);
    --border-strong: rgba(10, 58, 85, .3);

    --text: #09293b;
    --text-muted: #4a6b80;
    --text-faint: #6b8699;

    --accent: #c8780a;
    --accent-hover: #a65f00;
    --accent-ink: #ffffff;
    --focus: #1b6c8f;

    --danger: #b3261e;
    --danger-bg: #fdeceb;
    --danger-border: #f0b3af;
    --success: #0f6b4a;
    --success-bg: #e6f6ef;
    --success-border: #a8d9c4;
    --info-bg: #e8f2f8;

    --shadow: 0 1px 2px rgba(9, 41, 59, .08), 0 8px 20px -10px rgba(9, 41, 59, .18);
    --shadow-lift: 0 2px 6px rgba(9, 41, 59, .1), 0 16px 32px -12px rgba(9, 41, 59, .22);
  }
}

/* -------------------------------------------------------------------------
   2. Reset and base
   ---------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: var(--font);
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(70rem 40rem at 12% -12%, rgba(33, 158, 188, .16), transparent 70%),
    radial-gradient(60rem 36rem at 92% 4%, rgba(255, 183, 3, .09), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -.012em;
  font-weight: 600;
}

p { margin: 0; }

img { max-width: 100%; display: block; }

a { color: var(--cyan-300); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--text); }

@media (prefers-color-scheme: light) {
  a { color: #1b6c8f; }
  a:hover { color: #09293b; }
}

/* One visible, consistent focus ring everywhere. The old design relied
   on Bootstrap's default, which several custom rules overrode. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: 0; left: 50%;
  transform: translate(-50%, -110%);
  z-index: 100;
  padding: .7rem 1.2rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  text-decoration: none;
  transition: transform .15s ease;
}
.skip-link:focus { transform: translate(-50%, 0); }

/* -------------------------------------------------------------------------
   3. Layout primitives
   ---------------------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

main.shell {
  flex: 1 0 auto;
  padding-block: clamp(1.5rem, 4vw, 2.75rem);
}

.section { margin-top: clamp(2rem, 5vw, 3rem); }

.section__head {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.section__title { font-size: 1.15rem; }

.section__action { font-size: .9rem; }

/* -------------------------------------------------------------------------
   4. Masthead and navigation
   ---------------------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-sunk) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

/* Fallback for engines without color-mix(). */
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .masthead { background: var(--bg-sunk); }
}

.masthead__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4rem;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin-right: auto;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.brand__mark { display: grid; place-items: center; color: var(--accent); }

.brand__text {
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1;
  /* The display face sits high in its em box. */
  padding-top: .18em;
}

.nav-toggle {
  display: none;
  width: 2.75rem; height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.nav-toggle__bars,
.nav-toggle__bars::before,
.nav-toggle__bars::after {
  display: block;
  width: 17px; height: 2px;
  margin-inline: auto;
  background: currentColor;
  border-radius: 2px;
  content: "";
}
.nav-toggle__bars { position: relative; }
.nav-toggle__bars::before { position: absolute; top: -6px; }
.nav-toggle__bars::after  { position: absolute; top: 6px; }

.nav {
  display: flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}

.nav__link {
  padding: .5rem .8rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .94rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav__link:hover { background: var(--surface-hover); color: var(--text); }
.nav__link.is-current { color: var(--text); background: var(--surface); }

.nav__link--button {
  border: 0;
  background: none;
  font: inherit;
  font-size: .94rem;
  font-weight: 500;
  cursor: pointer;
}

.nav__signout { margin: 0; }

.nav__search {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .2rem .2rem .7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.nav__search:focus-within { border-color: var(--border-strong); }

.nav__search-input {
  width: 9.5rem;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  padding: .35rem 0;
}
.nav__search-input::placeholder { color: var(--text-faint); }
.nav__search-input:focus { outline: none; }
.nav__search-input:focus-visible { outline: none; }

.nav__search-btn {
  display: grid;
  place-items: center;
  width: 2rem; height: 2rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
}
.nav__search-btn:hover { background: var(--surface-hover); color: var(--text); }

@media (max-width: 46rem) {
  .nav-toggle { display: grid; place-items: center; }

  .nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: .25rem;
    padding-bottom: .9rem;
  }
  .nav.is-open { display: flex; }

  /* Without JavaScript the toggle cannot open anything, so show the
     links rather than hiding navigation behind a dead button. */
  .no-js .nav { display: flex; }
  .no-js .nav-toggle { display: none; }

  .nav--guest { display: flex; width: auto; flex-direction: row; padding: 0; }

  .nav__search { order: -1; margin-bottom: .4rem; }
  .nav__search-input { width: 100%; }
  .nav__link { padding: .7rem .8rem; }
}

/* -------------------------------------------------------------------------
   5. Buttons
   ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .62rem 1.15rem;
  min-height: 2.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .94rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .14s ease, border-color .14s ease, transform .14s ease;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:hover { background: var(--accent-hover); color: var(--accent-ink); }

.btn--ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }

.btn--danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn--danger:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--accent-ink);
}
@media (prefers-color-scheme: light) {
  .btn--danger:hover { color: #fff; }
}

.btn--sm { padding: .42rem .8rem; min-height: 2.15rem; font-size: .86rem; }
.btn--lg { padding: .85rem 1.7rem; min-height: 3rem; font-size: 1.02rem; }
.btn--full { width: 100%; }

.btn[disabled], .btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

/* -------------------------------------------------------------------------
   6. Forms and disclosures
   ---------------------------------------------------------------------- */

.form { display: grid; gap: 1.1rem; }

.form--tight { gap: .8rem; }

.form--panel,
.form--inline {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 3vw, 1.6rem);
}

.form--panel { max-width: 40rem; }

.form__footer {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
}

.form__warning {
  padding: .7rem .9rem;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .9rem;
}

.field { display: grid; gap: .4rem; }

.field__label {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}

.field__optional { font-weight: 400; color: var(--text-faint); }

.field__input {
  width: 100%;
  padding: .66rem .8rem;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: .96rem;
}
@media (prefers-color-scheme: light) {
  .field__input { background: #fff; }
}

.field__input::placeholder { color: var(--text-faint); }

.field__input:hover { border-color: var(--border-strong); }

.field__input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--focus);
}

.field__input--area { resize: vertical; min-height: 4.5rem; }

.field__input--file { padding: .5rem; cursor: pointer; }
.field__input--file::file-selector-button {
  margin-right: .7rem;
  padding: .45rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
}

.field__hint { font-size: .84rem; color: var(--text-muted); }

.field__reveal { display: flex; gap: .4rem; }
.field__reveal .field__input { flex: 1 1 auto; }

.field__reveal-btn {
  flex: 0 0 auto;
  padding: 0 .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.field__reveal-btn:hover { background: var(--surface-hover); color: var(--text); }

select.field__input {
  appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.05rem) 1.15rem, calc(100% - .75rem) 1.15rem;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.preview { margin-top: .6rem; }
.preview__img {
  width: 100%;
  max-width: 14rem;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-sunk);
}

/* Disclosures replace the Bootstrap modals, which depended on the
   Bootstrap JS bundle being loaded (twice) and were unreachable without
   JavaScript. <details> needs no script at all. */
.disclosure { display: inline-block; }

.disclosure__summary { list-style: none; }
.disclosure__summary::-webkit-details-marker { display: none; }
.disclosure__summary::marker { content: ""; }

.disclosure__body {
  margin-top: .8rem;
  padding: clamp(1rem, 2.5vw, 1.3rem);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: left;
}

.disclosure[open] > .disclosure__body { animation: reveal .16s ease both; }

.disclosure--compact,
.disclosure--danger { display: block; }

.disclosure--compact .disclosure__body { min-width: min(20rem, 100%); }

.disclosure--danger .disclosure__body { border-color: var(--danger-border); }

@keyframes reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------------------
   7. Notices and flashes
   ---------------------------------------------------------------------- */

.notice {
  display: grid;
  gap: .35rem;
  padding: .9rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--info-bg);
  font-size: .94rem;
}

.notice--error { background: var(--danger-bg); border-color: var(--danger-border); }
.notice--info  { background: var(--info-bg); }
.notice__detail { color: var(--text-muted); font-size: .88rem; }

.notice code {
  padding: .1rem .35rem;
  border-radius: 4px;
  background: var(--bg-sunk);
  font-size: .9em;
}

.flashes { display: grid; gap: .6rem; padding-top: 1rem; }

.flash {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.flash__icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 1.5rem; height: 1.5rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 700;
}

.flash__text { flex: 1 1 auto; font-size: .94rem; }

.flash--success { background: var(--success-bg); border-color: var(--success-border); }
.flash--success .flash__icon { background: var(--success); color: var(--accent-ink); }

.flash--error { background: var(--danger-bg); border-color: var(--danger-border); }
.flash--error .flash__icon { background: var(--danger); color: var(--accent-ink); }

.flash--info .flash__icon { background: var(--cyan-300); color: var(--accent-ink); }

.flash__dismiss {
  flex: 0 0 auto;
  width: 1.9rem; height: 1.9rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.flash__dismiss:hover { background: var(--surface-hover); color: var(--text); }

/* -------------------------------------------------------------------------
   8. Page furniture
   ---------------------------------------------------------------------- */

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1.6rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 3rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0;
}

.page-lede { margin-top: .3rem; color: var(--text-muted); }

.page-meta { margin-top: .3rem; font-size: .88rem; color: var(--text-faint); }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  margin-bottom: 1rem;
  font-size: .88rem;
  color: var(--text-faint);
}
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--gap);
}

.stat {
  padding: 1.1rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat__value {
  display: block;
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  display: block;
  margin-top: .15rem;
  font-size: .85rem;
  color: var(--text-muted);
}

.empty {
  display: grid;
  gap: .8rem;
  justify-items: start;
  max-width: 34rem;
  margin-top: 1.5rem;
  padding: clamp(1.4rem, 4vw, 2.2rem);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty--page { margin-inline: auto; justify-items: center; text-align: center; }

.empty__title { font-size: 1.2rem; }
.empty__text { color: var(--text-muted); }
.empty__actions { display: flex; gap: .6rem; flex-wrap: wrap; }

.collection-strip {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .5rem .45rem .9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: .9rem;
  text-decoration: none;
}
.chip:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }

.chip__count {
  padding: .1rem .5rem;
  background: var(--bg-sunk);
  border-radius: 999px;
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.search-box {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.search-box__input {
  flex: 1 1 16rem;
  padding: .7rem .9rem;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
}
@media (prefers-color-scheme: light) { .search-box__input { background: #fff; } }
.search-box__input::placeholder { color: var(--text-faint); }

/* -------------------------------------------------------------------------
   9. Grids, tiles and cards
   ---------------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
  gap: var(--gap);
}

@media (max-width: 34rem) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; }
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.tile:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}
.tile:focus-within { border-color: var(--focus); }

.tile__link {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

/* A fixed square frame with object-fit: cover. The old markup set
   width: 250px; height: 250px directly on the <img>, which distorted
   every photo that was not square. Reserving the box here also means
   nothing reflows as lazy-loaded images arrive. */
.tile__frame {
  display: block;
  aspect-ratio: 1;
  background: var(--bg-sunk);
  overflow: hidden;
}

.tile__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}
.tile:hover .tile__img { transform: scale(1.035); }

.tile__body { display: grid; gap: .22rem; padding: .8rem .9rem 1rem; }

.tile__name {
  font-size: .97rem;
  font-weight: 600;
  /* Two lines maximum, so tiles stay the same height in a row. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile__meta { font-size: .8rem; color: var(--accent); }

.tile__desc {
  font-size: .85rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
  gap: var(--gap);
  margin: 1.5rem 0 0;
  padding: 0;
  list-style: none;
}

.card {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card:hover { border-color: var(--border-strong); }

.card__cover { display: block; aspect-ratio: 16 / 10; background: var(--bg-sunk); }
.card__img { width: 100%; height: 100%; object-fit: cover; }
.card__img--blank {
  display: block;
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(135deg,
      rgba(142, 202, 230, .07) 0 10px,
      transparent 10px 20px);
}

.card__body { display: grid; gap: .35rem; align-content: start; padding: 1rem 1.1rem 1.15rem; }

.card__title { font-size: 1.05rem; }
.card__title a { color: var(--text); text-decoration: none; }
.card__title a:hover { text-decoration: underline; }

.card__count { font-size: .84rem; color: var(--accent); font-variant-numeric: tabular-nums; }

.card__desc { font-size: .88rem; color: var(--text-muted); }

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .65rem;
}

/* -------------------------------------------------------------------------
   10. Detail view
   ---------------------------------------------------------------------- */

.detail {
  display: grid;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: start;
}

@media (max-width: 54rem) {
  .detail { grid-template-columns: minmax(0, 1fr); }
}

.detail__media { display: grid; gap: .6rem; }

.detail__figure {
  display: block;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.detail__figure:hover { border-color: var(--border-strong); }

.detail__img {
  width: 100%;
  height: auto;
  /* Tall and wide photographs both need to fit without cropping here,
     so the detail view contains rather than covers. */
  max-height: min(70vh, 40rem);
  object-fit: contain;
}

.detail__media-note { font-size: .85rem; color: var(--text-muted); }

.detail__info { display: grid; gap: .7rem; align-content: start; }

.detail__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 400;
  line-height: 1.05;
}

.detail__where { font-size: .9rem; color: var(--text-muted); }

.detail__desc { display: grid; gap: .7rem; margin-top: .4rem; color: var(--text); }
.detail__desc--empty { color: var(--text-faint); font-style: italic; }

.detail__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.detail__actions .disclosure { display: block; width: 100%; }
.detail__actions .disclosure__summary { display: inline-flex; }

/* -------------------------------------------------------------------------
   11. Pagination and step navigation
   ---------------------------------------------------------------------- */

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  justify-content: center;
  margin-top: clamp(1.8rem, 4vw, 2.6rem);
}

.pager__pages {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
  margin: 0 .4rem;
  padding: 0;
  list-style: none;
}

.pager__step,
.pager__page {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: .4rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 600;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.pager__step:hover,
.pager__page:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }

.pager__page.is-current {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.pager__step.is-disabled { opacity: .4; }
.pager__step.is-disabled:hover { background: var(--surface); border-color: var(--border); }

.pager__gap { padding: 0 .2rem; color: var(--text-faint); }

@media (max-width: 34rem) {
  .pager__pages { order: 1; width: 100%; justify-content: center; margin: .5rem 0 0; }
}

.step-nav {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-top: clamp(2rem, 5vw, 3rem);
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

.step-nav__link {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  max-width: 48%;
  padding: .55rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .9rem;
  text-decoration: none;
}
.step-nav__link:hover { background: var(--surface-hover); color: var(--text); }
.step-nav__link--next { margin-left: auto; text-align: right; }

.step-nav__dir { flex: 0 0 auto; color: var(--accent); }

.step-nav__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------------------
   12. Auth and landing
   ---------------------------------------------------------------------- */

.auth { display: grid; place-items: center; padding-block: clamp(1rem, 6vh, 4rem); }

.auth__card {
  width: 100%;
  max-width: 25rem;
  padding: clamp(1.5rem, 5vw, 2.4rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth__title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1.05;
}

.auth__lede { margin: .3rem 0 1.5rem; color: var(--text-muted); font-size: .94rem; }

.auth__card .notice { margin-bottom: 1.2rem; }

.auth__alt { margin-top: 1.3rem; font-size: .9rem; color: var(--text-muted); text-align: center; }

.landing { max-width: 48rem; margin-inline: auto; text-align: center; padding-block: clamp(1rem, 6vh, 3.5rem); }

.landing__title {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 11vw, 5rem);
  font-weight: 400;
  line-height: 1;
}

.landing__lede {
  max-width: 34rem;
  margin: 1.1rem auto 0;
  color: var(--text-muted);
  font-size: 1.06rem;
}

.landing__actions { display: flex; justify-content: center; gap: .7rem; margin-top: 1.8rem; flex-wrap: wrap; }

.landing__points {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--gap);
  margin: clamp(2.5rem, 7vw, 4rem) 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.landing__points li {
  padding: 1.2rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.landing__points h2 { font-size: 1rem; margin-bottom: .35rem; }
.landing__points p { font-size: .9rem; color: var(--text-muted); }

/* -------------------------------------------------------------------------
   13. Footer
   ---------------------------------------------------------------------- */

.footer {
  flex: 0 0 auto;
  margin-top: clamp(2.5rem, 7vw, 4.5rem);
  padding-block: 1.6rem;
  border-top: 1px solid var(--border);
  background: var(--bg-sunk);
}

.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  font-size: .86rem;
}

.footer__muted { color: var(--text-faint); }

/* -------------------------------------------------------------------------
   14. Motion and print
   ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .tile:hover { transform: none; }
  .tile:hover .tile__img { transform: none; }
}

@media (forced-colors: active) {
  .tile, .card, .stat, .btn, .field__input { border: 1px solid CanvasText; }
  .pager__page.is-current { forced-color-adjust: none; }
}

@media print {
  .masthead, .footer, .pager, .step-nav, .detail__actions,
  .skip-link, .flashes, .disclosure { display: none !important; }

  body { background: #fff; color: #000; }
  .detail { grid-template-columns: 1fr; }
}
