/*
  Muse design system — Mendy's workshop
  One stylesheet for every page on muse.shmuky.dev.
  Tokens first, then base, layout, components, utilities, print.
*/

/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;

  --bg: #14110e;
  --surface: #1c1814;
  --surface-2: #25201a;
  --border: #3a3129;
  --border-strong: #54473a;

  --text: #f4ede4;
  --text-muted: #b9ac9b;
  --text-faint: #8f8272;

  --accent: #f5a524;
  --accent-strong: #ffbd4a;
  --accent-ink: #1b1207;
  --accent-soft: rgba(245, 165, 36, 0.12);
  --accent-line: rgba(245, 165, 36, 0.35);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Hebrew", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  --measure: 42rem;
  --wide: 68rem;
  --gutter: 1rem;

  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -18px rgba(0, 0, 0, 0.8);
}

@media (min-width: 40rem) {
  :root { --gutter: 1.5rem; }
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(60rem 30rem at 85% -10%, rgba(245, 165, 36, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main { flex: 1 0 auto; }

h1, h2, h3, h4 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 6vw, 2.75rem); font-weight: 750; }
h2 { font-size: clamp(1.35rem, 4vw, 1.7rem); font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 650; }

p { margin: 0 0 var(--space-4); }

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
a:hover { color: var(--accent); }

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

img, svg, video { max-width: 100%; }
img { height: auto; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.08em 0.38em;
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-4);
  overflow-x: auto;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-7) 0;
}

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

[lang="he"] { font-family: var(--font-sans); }

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: calc(var(--wide) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.container-narrow {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--space-7); }
.section + .section { padding-top: 0; }

.skip-link {
  position: absolute;
  inset-inline-start: var(--space-4);
  top: -3rem;
  z-index: 10;
  background: var(--accent);
  color: var(--accent-ink);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  font-weight: 650;
  text-decoration: none;
}
.skip-link:focus { top: var(--space-4); color: var(--accent-ink); }

/* ---------- Icons ---------- */
.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-lg { width: 1.5rem; height: 1.5rem; }

/* ---------- Site header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(20, 17, 14, 0.85);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 3.5rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  flex: none;
}
.brand-sub {
  display: block;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.2;
}
.brand-name { display: block; line-height: 1.2; }

.bsd {
  font-size: 0.8rem;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ---------- Site footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: var(--space-8);
  padding-block: var(--space-6);
  color: var(--text-muted);
  font-size: 0.925rem;
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  justify-content: space-between;
  align-items: center;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent-strong); }
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 650;
  font-size: 0.975rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* ---------- Page actions (PDF / share) ---------- */
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: calc(-1 * var(--space-2)) 0 var(--space-6);
}
.btn-sm { min-height: 2.75rem; padding: 0.5rem 0.95rem; font-size: 0.9rem; }
.btn-icon { width: 2.75rem; padding: 0; flex: none; }
.btn-icon .icon { width: 1.2rem; height: 1.2rem; }
/* Phones: the text buttons share the row evenly; the icon button keeps its size. */
@media (max-width: 35.99rem) {
  .page-actions > .btn:not(.btn-icon) { flex: 1 1 0; min-width: 0; padding-inline: 0.6rem; }
  .wide-only { display: none; }
}
.action-status {
  grid-column: 1 / -1;
  flex-basis: 100%;
  margin: 0;
  min-height: 1.4em;
  font-size: 0.875rem;
  color: var(--accent-strong);
}
.action-status:empty { display: none; }
[data-js-only] { display: none; }
.js [data-js-only] { display: inline-flex; }

/* ---------- Back link ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 550;
  font-size: 0.95rem;
}
.back-link:hover { color: var(--accent-strong); }

/* ---------- Page header (artifact pages) ---------- */
.page-header { padding-block: var(--space-5) var(--space-6); }
.eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-strong);
}
.eyebrow .dot { color: var(--text-faint); }
.eyebrow time { color: var(--text-muted); }
.lede {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 38rem;
}

/* ---------- Prose ---------- */
.prose > * + * { margin-top: var(--space-4); }
.prose h2 { margin-top: var(--space-7); }
.prose h3 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-inline-start: 1.3rem; }
.prose li + li { margin-top: var(--space-2); }
.prose li::marker { color: var(--accent); }
.prose p, .prose ul, .prose ol { margin-bottom: 0; }

/* ---------- Callout ---------- */
.callout {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
}
.callout .icon { color: var(--accent-strong); margin-top: 0.2em; }
.callout p { margin: 0; }
.callout p + p { margin-top: var(--space-2); }

/* ---------- Card ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.card:hover { border-color: var(--accent-line); }
.card:focus-within { border-color: var(--accent); }
.card p { margin: 0; color: var(--text-muted); }

/* ---------- Tag / badge ---------- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--accent-strong);
}

/* ---------- Gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 40rem) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 64rem) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
}
.gallery > li { display: flex; }
.gallery .card { width: 100%; }

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 0.85rem;
  color: var(--text-faint);
}
.card-title { margin: 0; font-size: 1.2rem; }
.card-title a {
  color: var(--text);
  text-decoration: none;
}
/* Whole card is clickable through the title link. */
.card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}
.card-title a:focus-visible { outline: none; }
.card-title a:focus-visible::after { outline: 2px solid var(--accent-strong); outline-offset: 3px; }
.card-open {
  margin-top: auto;
  padding-top: var(--space-2);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--accent-strong);
}
.card:hover .card-open .icon { transform: translateX(3px); }
.card-open .icon { transition: transform 0.15s ease; }

/* ---------- Filter (pure CSS, uses :has) ---------- */
.gallery-head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.gallery-head h2 { margin: 0; }
.filter {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  min-inline-size: 0;
}
.filter input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.filter label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.filter label:hover { color: var(--text); }
.filter input:checked + label { background: var(--accent); color: var(--accent-ink); }
.filter input:focus-visible + label { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.filter .count {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.gallery-section:has(#show-page:checked) .gallery > li:not([data-type="page"]),
.gallery-section:has(#show-file:checked) .gallery > li:not([data-type="file"]) {
  display: none;
}

.empty {
  display: none;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-6) var(--space-4);
}
.gallery-section:has(#show-page:checked):not(:has(.gallery > li[data-type="page"])) .empty-page,
.gallery-section:has(#show-file:checked):not(:has(.gallery > li[data-type="file"])) .empty-file {
  display: block;
}

/* ---------- Hero ---------- */
.hero { padding-block: var(--space-7) var(--space-6); }
.hero h1 { max-width: 20ch; }
.hero .lede { margin-bottom: 0; }
.hero-he {
  display: inline-block;
  margin-bottom: var(--space-3);
  color: var(--accent-strong);
  font-weight: 600;
}

/* ---------- About ---------- */
.about {
  display: grid;
  gap: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
}
@media (min-width: 48rem) {
  .about { grid-template-columns: 14rem 1fr; padding: var(--space-6); }
}
.about h2 { margin: 0; }
.about p { color: var(--text-muted); }
.about p:last-child { margin-bottom: 0; }

/* ---------- Download panel (file artifacts) ---------- */
.download-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
}
.file-name {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.file-name strong { display: block; overflow-wrap: anywhere; }
.file-name span { display: block; font-size: 0.875rem; color: var(--text-muted); }
.file-name .icon { color: var(--accent-strong); }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.975rem;
}
th, td {
  text-align: start;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: 0; }
th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--surface);
  font-weight: 650;
}

/* ---------- Form controls ---------- */
.field { display: grid; gap: var(--space-2); }
.field label { font-weight: 600; font-size: 0.95rem; }
.field-hint { font-size: 0.875rem; color: var(--text-muted); margin: 0; }
textarea, input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
}
textarea { min-height: 9rem; resize: vertical; line-height: 1.5; }
textarea:focus, input[type="text"]:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Utilities ---------- */
.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;
}
.muted { color: var(--text-muted); }
.print-only { display: none; }
.stack > * + * { margin-top: var(--space-4); }

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

/* ---------- Print ---------- */
@media print {
  :root {
    color-scheme: light;
    --bg: #fff;
    --surface: #fff;
    --surface-2: #f5f1ea;
    --border: #d9d1c5;
    --border-strong: #bfb4a4;
    --text: #1b1612;
    --text-muted: #4d443a;
    --text-faint: #6b6155;
    --accent: #9a5b00;
    --accent-strong: #9a5b00;
    --accent-soft: #fbf3e4;
    --accent-line: #e7c98f;
    --shadow: none;
  }
  body { background: #fff; font-size: 11pt; min-height: 0; display: block; }
  .site-header, .site-footer, .back-link, .skip-link, .no-print { display: none !important; }
  .print-only { display: block; }
  a { color: inherit; }
  .card, .callout, .table-wrap { break-inside: avoid; }
}
