/* ==========================================================================
   Website library — catalogue chrome.
   Deliberately neutral: the templates supply the colour, this page shouldn't.
   ========================================================================== */

:root {
  --bg:        #f4f4f2;
  --surface:   #ffffff;
  --surface-2: #fafaf9;
  --ink:       #16161a;
  --ink-2:     #3d3d44;
  --muted:     #797983;
  --muted-2:   #a3a3ac;
  --line:      #e3e3df;
  --line-2:    #d2d2cd;
  --accent:    #2f6d5b;
  --accent-2:  #e8f0ed;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --r: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 24, .05), 0 8px 26px rgba(20, 20, 24, .05);
  --shadow-lg: 0 24px 70px rgba(20, 20, 24, .18);
  --ease: cubic-bezier(.22, .75, .3, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #131316;
    --surface:   #1b1b1f;
    --surface-2: #202025;
    --ink:       #f2f2f0;
    --ink-2:     #c9c9c6;
    --muted:     #8d8d95;
    --muted-2:   #6a6a72;
    --line:      #2b2b31;
    --line-2:    #3a3a41;
    --accent:    #6fbfa5;
    --accent-2:  #1e2f2a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 26px rgba(0,0,0,.3);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, .55);
  }
}

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

body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul { list-style: none; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.shell {
  width: 100%;
  max-width: 1560px;
  margin-inline: auto;
  padding-inline: clamp(18px, 3vw, 40px);
}

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

.top__row {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding-block: 16px;
}

.mark {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-right: auto;
}

.mark__glyph {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  flex: none;
}

.mark__glyph svg { width: 17px; height: 17px; }

.mark h1 {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
  line-height: 1.2;
}

.mark p {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
  letter-spacing: .02em;
}

/* search */
.search {
  position: relative;
  flex: 1 1 260px;
  max-width: 380px;
}

.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  translate: 0 -50%;
  width: 15px;
  height: 15px;
  color: var(--muted-2);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 10px 40px 10px 36px;
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.search input::placeholder { color: var(--muted-2); }

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.search kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  translate: 0 -50%;
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--muted-2);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
}

.search input:focus ~ kbd { opacity: 0; }

/* density toggle */
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 8px;
}

.seg button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  border-radius: 5px;
  color: var(--muted);
  transition: background .2s var(--ease), color .2s var(--ease);
}

.seg button svg { width: 15px; height: 15px; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--accent-2); color: var(--accent); }

/* filter chips */
.chips {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  padding-bottom: 16px;
}

.chip {
  padding: 5px 12px;
  font-size: .8rem;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  transition: background .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}

.chip:hover { border-color: var(--muted-2); }

.chip[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.chips__count {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--muted);
  margin-left: auto;
}

/* ------------------------------------------------------------------ grid */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: clamp(18px, 2vw, 28px);
  padding-block: 28px 60px;
}

@media (max-width: 1180px) { .grid { grid-template-columns: repeat(min(var(--cols, 3), 2), minmax(0, 1fr)); } }
@media (max-width: 720px)  { .grid { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------ card */
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
  opacity: 0;
  translate: 0 14px;
  transition: opacity .5s var(--ease), translate .5s var(--ease),
              border-color .25s var(--ease), box-shadow .25s var(--ease);
}

.card.is-in { opacity: 1; translate: 0; }

.card:hover {
  border-color: var(--line-2);
  box-shadow: 0 2px 4px rgba(20,20,24,.05), 0 16px 40px rgba(20,20,24,.09);
}

/* live preview -------------------------------------------------------- */
.shot {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  display: block;
  width: 100%;
}

.shot__frame {
  position: absolute;
  top: 0;
  left: 0;
  width: 1440px;
  height: 1080px;
  border: 0;
  transform-origin: 0 0;
  pointer-events: none;
  background: #fff;
  opacity: 0;
  transition: opacity .6s var(--ease);
}

.shot__frame.is-ready { opacity: 1; }

/* placeholder shown until the frame paints */
.shot__stub {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 10px;
  background: var(--surface-2);
  transition: opacity .5s var(--ease);
}

.shot__stub.is-gone { opacity: 0; }

.shot__stub span {
  font-family: var(--mono);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.shot__spin {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-2);
  border-top-color: var(--muted);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { rotate: 360deg; } }

/* hover veil with the two actions */
.shot__veil {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: color-mix(in srgb, var(--ink) 62%, transparent);
  opacity: 0;
  transition: opacity .28s var(--ease);
}

.shot:hover .shot__veil,
.shot:focus-visible .shot__veil { opacity: 1; }

.shot__act {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  font-size: .84rem;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border-radius: 7px;
  translate: 0 8px;
  transition: translate .3s var(--ease), background .2s var(--ease);
}

.shot:hover .shot__act { translate: 0; }
.shot__act:nth-child(2) { transition-delay: .04s; }
.shot__act:hover { background: #ececeb; }
.shot__act svg { width: 14px; height: 14px; }

.shot__pages {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: .68rem;
  color: #fff;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  border-radius: 5px;
  backdrop-filter: blur(4px);
}

/* card body ----------------------------------------------------------- */
.card__body { padding: 16px 17px 17px; display: flex; flex-direction: column; gap: 11px; flex: 1; }

.card__head { display: flex; align-items: baseline; gap: 10px; }

.card__head h2 {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}

.card__folder {
  font-family: var(--mono);
  font-size: .7rem;
  color: var(--muted-2);
  margin-left: auto;
  white-space: nowrap;
}

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

.card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  row-gap: 9px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.swatches { display: flex; gap: 4px; }

.swatches i {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
}

.card__links { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

.plink {
  padding: 3px 9px;
  font-size: .74rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  transition: color .18s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
}

.plink:hover { color: var(--ink); border-color: var(--muted-2); background: var(--surface-2); }

/* empty state */
.empty {
  grid-column: 1 / -1;
  padding: 70px 20px;
  text-align: center;
  color: var(--muted);
}

.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: 6px; font-weight: 600; }

/* ----------------------------------------------------------------- modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  grid-template-rows: auto 1fr;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s var(--ease), visibility .3s;
}

.modal.is-on { opacity: 1; visibility: visible; }

.modal__bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 13px clamp(14px, 2vw, 22px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.modal__title { font-weight: 600; color: var(--ink); }

.modal__sub {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--muted);
}

.modal__stage {
  display: grid;
  place-items: start center;
  overflow: auto;
  padding: clamp(14px, 2vw, 26px);
}

.modal__device {
  width: min(var(--w, 1440px), 100%);
  height: 100%;
  min-height: 420px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  transition: width .35s var(--ease);
}

.modal__device iframe { width: 100%; height: 100%; border: 0; display: block; }

.modal__x {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: var(--muted);
  border: 1px solid var(--line-2);
  transition: background .2s var(--ease), color .2s var(--ease);
}

.modal__x:hover { background: var(--surface-2); color: var(--ink); }
.modal__x svg { width: 16px; height: 16px; }

.modal__open {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--bg);
  background: var(--ink);
  border-radius: 7px;
  transition: opacity .2s var(--ease);
}

.modal__open:hover { opacity: .85; }
.modal__open svg { width: 14px; height: 14px; }

.modal__right { display: flex; align-items: center; gap: 10px; margin-left: auto; }

@media (max-width: 620px) {
  .modal__sub, .modal__open span { display: none; }
}

/* ---------------------------------------------------------------- footer */
.foot {
  padding: 22px 0 40px;
  border-top: 1px solid var(--line);
  font-size: .82rem;
  color: var(--muted-2);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.foot code {
  font-family: var(--mono);
  font-size: .78rem;
  padding: 2px 7px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
  .card { opacity: 1 !important; translate: none !important; }
}
