/* Splash Templates gallery */

:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #eff0f6;
  --text: #15161c;
  --text-muted: #555a6b;
  --border: #e1e3ec;
  --border-strong: #c9ccd9;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-text: #ffffff;
  --accent-soft: #ecebfd;
  --accent-soft-text: #3b33c4;
  --focus: #4f46e5;
  --shadow: 0 1px 2px rgb(20 22 40 / 0.05), 0 4px 16px rgb(20 22 40 / 0.06);
  --shadow-lg: 0 2px 4px rgb(20 22 40 / 0.06), 0 12px 32px rgb(20 22 40 / 0.1);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f14;
    --surface: #17181f;
    --surface-2: #20222b;
    --text: #ecedf3;
    --text-muted: #a2a6b6;
    --border: #2a2c37;
    --border-strong: #3a3d4b;
    --accent: #8b85ff;
    --accent-hover: #a29dff;
    --accent-text: #0e0f14;
    --accent-soft: #252445;
    --accent-soft-text: #c3c0ff;
    --focus: #a29dff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / 0.35), 0 12px 32px rgb(0 0 0 / 0.4);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e0f14;
  --surface: #17181f;
  --surface-2: #20222b;
  --text: #ecedf3;
  --text-muted: #a2a6b6;
  --border: #2a2c37;
  --border-strong: #3a3d4b;
  --accent: #8b85ff;
  --accent-hover: #a29dff;
  --accent-text: #0e0f14;
  --accent-soft: #252445;
  --accent-soft-text: #c3c0ff;
  --focus: #a29dff;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 4px 16px rgb(0 0 0 / 0.25);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / 0.35), 0 12px 32px rgb(0 0 0 / 0.4);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

main { flex: 1; outline: none; }

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

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }

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

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.5em; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); font-weight: 750; }
h2 { font-size: 1.25rem; font-weight: 650; }

code { font-family: var(--mono); font-size: 0.9em; }

.container { width: min(1200px, 100% - 32px); margin-inline: auto; }

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

.skip-link {
  position: absolute;
  left: 16px; top: -100px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--accent-text); }

/* Header & footer */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
  font-weight: 700; letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand-mark { width: 30px; height: 30px; color: var(--accent); }
.brand-mark path { fill: var(--bg); }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 550;
  font-size: 0.95rem;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--text); }

.theme-toggle {
  display: grid; place-items: center;
  width: 40px; height: 40px; margin-left: 4px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle[data-current="dark"] .icon-sun { display: block; }
.theme-toggle[data-current="dark"] .icon-moon { display: none; }

@media (max-width: 520px) {
  .brand span { display: none; }
}

.site-footer { margin-top: 80px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.9rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-block: 28px; }
.footer-inner p { margin: 0; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }

/* Buttons, tags, chips */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 0.95rem; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, transform 0.15s;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-text); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-lg { min-height: 48px; padding: 10px 20px; font-size: 1rem; }
.btn-meta { font-weight: 500; opacity: 0.8; font-size: 0.9em; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  font-size: 0.8rem; font-weight: 600;
  text-decoration: none;
}
a.tag:hover { color: var(--accent-soft-text); text-decoration: underline; }

/* Home */

.hero { padding-block: 56px 32px; }
.hero > * { max-width: 760px; }
.lede { font-size: 1.15rem; color: var(--text-muted); margin: 0 0 1em; }

/* Filter bar: [search][category] on one row, style chips on the row below.
   Each field wrapper is the positioning context for its decorations (icon,
   "/" hint, chevron), which are taken out of flow and centred vertically, so
   they never become separate flex items or wrap below the control. */
.filters { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.filters[hidden] { display: none; }
.filter-row { display: flex; align-items: stretch; gap: 12px; }

.search, .select { position: relative; height: 44px; min-width: 0; }
.search { flex: 1 1 320px; max-width: 420px; }
.select { flex: 0 1 260px; }

.search > input, .select > select {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none; /* Safari's native search/select styling ignores padding */
}
.search > input { padding: 0 44px 0 42px; }          /* clears the icon (left) and "/" hint (right) */
.select > select { padding: 0 42px 0 14px; cursor: pointer; text-overflow: ellipsis; } /* clears the chevron */
.search > input::placeholder { color: var(--text-muted); opacity: 1; }
.search > input::-webkit-search-decoration { -webkit-appearance: none; }
.search > input::-webkit-search-cancel-button { cursor: pointer; }
.search > input:focus-visible, .select > select:focus-visible { outline-offset: 0; border-color: var(--focus); }

.search-icon, .search-hint, .select-chevron {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;   /* clicks go straight to the control underneath */
  color: var(--text-muted);
}
.search-icon { left: 14px; width: 18px; height: 18px; }
.search-hint {
  right: 10px;
  padding: 0 7px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font: 0.8rem/1.6 var(--mono);
}
.search > input:focus ~ .search-hint, .search > input:not(:placeholder-shown) ~ .search-hint { display: none; }
.select-chevron { right: 14px; width: 16px; height: 16px; }

@media (max-width: 640px) {
  .filter-row { flex-direction: column; }
  .search, .select { flex: none; width: 100%; max-width: none; }
  .search-hint { display: none; } /* no "/" shortcut on touch devices */
  .search > input { padding-right: 14px; }
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 0.9rem; font-weight: 550;
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-count { font-size: 0.8em; opacity: 0.65; }

.result-count { min-height: 1.6em; margin: 0 0 16px; color: var(--text-muted); font-size: 0.9rem; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 24px;
  list-style: none; margin: 0; padding: 0;
}

.card {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.card:hover { box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.card:focus-within { border-color: var(--focus); }
.card[hidden] { display: none; }

.card-media { aspect-ratio: 16 / 10; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.card:hover .card-media img { transform: scale(1.025); }

.card-body { display: flex; flex-direction: column; gap: 10px; flex: 1; padding: 18px 20px 20px; }
.card-title { margin: 0; font-size: 1.1rem; }
.card-link { color: var(--text); text-decoration: none; }
.card-link:hover { color: var(--text); }
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 0; }
.card-link:focus-visible { outline: none; }
.card:has(.card-link:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.card-desc { margin: 0; color: var(--text-muted); font-size: 0.95rem; }
.card-actions { display: flex; gap: 10px; margin-top: auto; padding-top: 6px; }
.card-actions .btn { position: relative; z-index: 1; flex: 1; }

.empty { padding: 48px 16px; text-align: center; color: var(--text-muted); }
.empty[hidden] { display: none; }

/* Detail */

.detail { padding-top: 24px; }
.breadcrumb { margin-bottom: 24px; font-size: 0.95rem; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }

.detail-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.detail-intro { flex: 1 1 420px; max-width: 720px; }
.detail-intro .lede { margin-bottom: 16px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.preview-title { margin: 0; font-size: 0.95rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0; }

.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.segmented[hidden] { display: none; }
.segmented button {
  min-height: 34px; padding: 4px 14px;
  border: 0; border-radius: 7px;
  background: transparent; color: var(--text-muted);
  font: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.preview-stage {
  display: flex; justify-content: center;
  padding: 16px;
  background:
    radial-gradient(circle at 1px 1px, var(--border-strong) 1px, transparent 0) 0 0 / 18px 18px,
    var(--surface-2);
}
.preview-frame {
  width: 100%;
  max-width: 100%;
  height: min(78vh, 820px);
  min-height: 420px;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow-lg);
  transition: width 0.3s ease;
}
.preview-frame[data-width="tablet"] { width: 768px; }
.preview-frame[data-width="mobile"] { width: 375px; height: min(78vh, 740px); }
.preview-frame iframe { display: block; width: 100%; height: 100%; border: 0; }

.detail-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 32px; margin-top: 40px; }
.meta { display: grid; gap: 0; margin: 0; }
.meta div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meta dt { color: var(--text-muted); }
.meta dd { margin: 0; font-weight: 600; text-align: right; }
.file-list { margin: 0; padding: 0; list-style: none; }
.file-list li { padding: 8px 0; border-bottom: 1px solid var(--border); }

/* Prose */

.prose { max-width: 720px; padding-top: 56px; }
.prose h2 { margin-top: 2em; }
.prose p, .prose li { color: var(--text); }
.prose ul { padding-left: 1.25em; }
.prose li + li { margin-top: 4px; }
.not-found { padding-block: 96px 24px; }

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

/* "New" badge, added by new-badge.js (cards and detail pages) */
.card-media { position: relative; }
.badge-new {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 1;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
}

.chips { align-items: center; }
.chips-label { margin-right: 4px; color: var(--text-muted); font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.card-category, .detail-category {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-category { margin-bottom: -6px; }
.detail-category { margin-bottom: 8px; }
.detail-category a { text-decoration: none; }
.detail-category a:hover { text-decoration: underline; }

.load-more { display: flex; justify-content: center; margin-top: 32px; }
.load-more[hidden] { display: none; }
.detail-category { display: flex; align-items: center; gap: 10px; }
.detail-category .badge-new { position: static; box-shadow: none; letter-spacing: 0.06em; }
