/* Site styles — uses tokens from tokens.css only. See DESIGN.md. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.nav-add { height: 36px; padding: 0 var(--space-3); margin-left: var(--space-1); }
.nav-add .icon { width: 16px; height: 16px; stroke-width: 2; }
.footer-links { display: flex; gap: var(--space-4); }
h1, h2, h3 { margin: 0; font-weight: var(--weight-semibold); letter-spacing: var(--tracking-heading); }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 2px; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.placeholder { outline: 1px dashed var(--warning); outline-offset: 2px; }

.skip-link { position: absolute; left: var(--space-4); top: -100px; z-index: 20; background: var(--primary); color: var(--on-primary); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); }
.skip-link:focus { top: var(--space-3); }

.container { width: 100%; max-width: var(--content-max); margin: 0 auto; padding: 0 var(--gutter); }

/* Nav */
.nav { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--border); }
.nav .container { height: var(--nav-height); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.brand { display: flex; align-items: center; gap: var(--space-2); color: var(--text); font-weight: var(--weight-semibold); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--primary); color: var(--on-primary); display: grid; place-items: center; }
.brand-mark .icon { width: 18px; height: 18px; stroke-width: 2; }
.nav-links { display: flex; align-items: center; gap: var(--space-1); }
.nav-links a { color: var(--text-muted); font-size: var(--text-sm); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--text); background: var(--surface-2); text-decoration: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-height); padding: 0 var(--space-4);
  font: var(--weight-medium) var(--text-sm)/1 var(--font-sans);
  border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-quiet { background: transparent; color: var(--text-muted); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-icon { width: var(--control-height); padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.4; pointer-events: none; }

/* Hero */
.hero { padding: var(--space-7) 0 var(--section-gap); }
.hero .container { display: grid; gap: var(--space-6); align-items: center; }
.eyebrow { font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--lh-xs); letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); }
.hero h1 { font-size: var(--text-2xl); line-height: var(--lh-2xl); margin: var(--space-3) 0 var(--space-4); }
.hero .lead { font-size: var(--text-lg); line-height: var(--lh-lg); color: var(--text-muted); max-width: 40ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-6); }
.hero-stage { aspect-ratio: 1 / 1; }
@media (min-width: 900px) {
  .hero { padding-top: var(--space-8); }
  .hero .container { grid-template-columns: 1fr 1fr; gap: var(--space-8); }
  .hero h1 { font-size: var(--text-3xl); line-height: var(--lh-3xl); }
  .hero-stage { aspect-ratio: 4 / 3.4; }
}

/* Stage (3D viewer container) */
.stage { position: relative; background: var(--stage); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.stage model-viewer { width: 100%; height: 100%; background: var(--stage); --poster-color: transparent; --progress-bar-color: var(--primary); }
.stage-caption { position: absolute; left: var(--space-3); bottom: var(--space-3); display: flex; align-items: center; gap: var(--space-2); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: var(--space-1) var(--space-3); font-size: var(--text-sm); color: var(--text); }
.stage-caption:hover { text-decoration: none; border-color: var(--border-strong); }
.stage:fullscreen { border-radius: 0; border: 0; }
.stage > img, .stage > video, .stage-content img, .stage-content video { width: 100%; height: 100%; object-fit: contain; display: block; background: var(--stage); }
.hero-stage > img, .hero-stage > video { object-fit: cover; }
.stage-content { position: absolute; inset: 0; }
.stage-content model-viewer { width: 100%; height: 100%; }
.stage-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; background: var(--surface); border-color: var(--border); color: var(--text); opacity: 0.9; }
.stage-nav:hover { opacity: 1; border-color: var(--border-strong); }
.stage-nav.prev { left: var(--space-3); }
.stage-nav.next { right: var(--space-3); }
.stage-counter { position: absolute; left: var(--space-3); top: var(--space-3); font-size: var(--text-xs); line-height: 1; padding: var(--space-1) var(--space-2); border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border); }
.stage-caption-text { font-size: var(--text-sm); margin-top: var(--space-2); }
.stage-caption-text[hidden] { display: none; }

/* Media thumbnails */
.thumbs { display: flex; gap: var(--space-2); overflow-x: auto; padding: var(--space-3) 2px 4px; scrollbar-width: thin; }
.thumb { position: relative; flex: none; width: 88px; aspect-ratio: 4 / 3; padding: 0; border-radius: var(--radius-sm); overflow: hidden; cursor: pointer; background: var(--stage); border: 1px solid var(--border); color: var(--text-muted); }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.thumb:hover { border-color: var(--border-strong); }
.thumb[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.thumb-kind { position: absolute; right: 4px; bottom: 4px; width: 20px; height: 20px; display: grid; place-items: center; border-radius: var(--radius-pill); background: var(--surface); color: var(--text); }
.thumb-kind .icon { width: 12px; height: 12px; stroke-width: 2; }
.thumb:not(:has(img, video)) .thumb-kind { inset: 0; margin: auto; width: 32px; height: 32px; background: transparent; }
.thumb:not(:has(img, video)) .thumb-kind .icon { width: 22px; height: 22px; stroke-width: 1.5; }

.downloads { display: flex; flex-direction: column; gap: var(--space-2); }
.downloads .btn { justify-content: flex-start; }
.dl-size { font-size: var(--text-xs); opacity: 0.75; }
.description { display: flex; flex-direction: column; gap: var(--space-3); }

/* Sections */
.section { padding-bottom: var(--section-gap); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-5); }
.section-head h2 { font-size: var(--text-xl); line-height: var(--lh-xl); }

/* Toolbar: filters + search */
.toolbar { display: flex; flex-direction: column; gap: var(--space-3); margin-bottom: var(--space-5); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.chip-label { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); letter-spacing: var(--tracking-label); text-transform: uppercase; margin-right: var(--space-1); min-width: 72px; }
.chip {
  height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  font: var(--weight-medium) var(--text-xs)/1 var(--font-mono); cursor: pointer;
}
.chip:hover { border-color: var(--border-strong); }
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.toolbar-side { display: flex; gap: var(--space-2); width: 100%; max-width: 440px; }
.search { position: relative; flex: 1; min-width: 0; }
.select {
  height: var(--control-height); padding: 0 var(--space-6) 0 var(--space-3); flex: none;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239A9DA4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: var(--text-sm) var(--font-sans); appearance: none; cursor: pointer;
}
.select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.search .icon { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); color: var(--text-muted); width: 18px; height: 18px; }
.input {
  width: 100%; height: var(--control-height); padding: 0 var(--space-3) 0 calc(var(--space-3) + 26px);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: var(--text-sm) var(--font-sans);
}
.input::placeholder { color: var(--text-muted); }
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
@media (min-width: 900px) {
  .toolbar { flex-direction: row; justify-content: space-between; align-items: start; }
  .toolbar-filters { display: flex; flex-direction: column; gap: var(--space-3); }
}

/* Grid + cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: var(--space-4); list-style: none; margin: 0; padding: 0; }
@media (max-width: 559px) { .grid { grid-template-columns: 1fr; } }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; color: var(--text); transition: border-color var(--duration) var(--ease); height: 100%; }
.card:hover { border-color: var(--border-strong); text-decoration: none; }
.card-media { aspect-ratio: 4 / 3; background: var(--stage); position: relative; }
.card-media img, .card-media model-viewer { width: 100%; height: 100%; object-fit: cover; background: var(--stage); --poster-color: transparent; pointer-events: none; }
.card-media img.card-alt { position: absolute; inset: 0; opacity: 0; transition: opacity var(--duration) var(--ease); }
.card:hover .card-alt, .card:focus-visible .card-alt { opacity: 1; }
.card-media video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.card-empty { width: 100%; height: 100%; display: grid; place-items: center; color: var(--text-muted); }
.card-empty .icon { width: 40px; height: 40px; stroke-width: 1; }
.media-badges { position: absolute; left: var(--space-2); bottom: var(--space-2); display: flex; gap: var(--space-1); }
.media-badge { display: inline-flex; align-items: center; gap: 4px; font: var(--weight-medium) var(--text-xs)/1 var(--font-mono); padding: 4px var(--space-2); border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.media-badge .icon { width: 12px; height: 12px; stroke-width: 2; }
.chip-count { margin-left: 6px; opacity: 0.6; }
.chip { display: inline-flex; align-items: center; }
.card-body { padding: var(--space-3) var(--space-4) var(--space-4); display: flex; flex-direction: column; gap: var(--space-1); }
.card-title { font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: var(--weight-medium); }
.stats { font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-muted); }

.empty { border: 1px dashed var(--border-strong); border-radius: var(--radius-md); padding: var(--space-7) var(--space-5); text-align: left; display: flex; flex-direction: column; gap: var(--space-2); }
.empty code, .notice code { font-family: var(--font-mono); font-size: var(--text-sm); background: var(--surface-2); padding: 1px var(--space-1); border-radius: 4px; }
.notice { border: 1px solid var(--error); color: var(--text); border-radius: var(--radius-md); padding: var(--space-4) var(--space-5); }

/* About */
.about { display: grid; gap: var(--space-6); border-top: 1px solid var(--border); padding-top: var(--space-7); }
.about p { max-width: var(--prose-max); color: var(--text-muted); }
.about h2 { font-size: var(--text-xl); line-height: var(--lh-xl); margin-bottom: var(--space-4); }
.tag-list { display: flex; flex-wrap: wrap; gap: var(--space-2); list-style: none; margin: var(--space-4) 0 0; padding: 0; }
.tag { font: var(--text-xs)/1 var(--font-mono); padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-pill); color: var(--text-muted); }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.link-list a { display: inline-flex; gap: var(--space-2); align-items: center; }
@media (min-width: 900px) { .about { grid-template-columns: 2fr 1fr; gap: var(--space-8); } }

/* Footer */
.footer { border-top: 1px solid var(--border); padding: var(--space-5) 0; color: var(--text-muted); font-size: var(--text-sm); }
.footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); }

/* Model page */
.crumbs { padding: var(--space-5) 0 var(--space-4); }
.model-layout { display: grid; gap: var(--space-5); padding-bottom: var(--section-gap); }
.model-layout > * { min-width: 0; }
.viewer { aspect-ratio: 1 / 1; }
@media (min-width: 600px) and (max-width: 899px) { .viewer { aspect-ratio: 4 / 3; } }
@media (max-width: 599px) { .viewer-hint { display: none; } .stage-nav { width: 36px; height: 36px; } }
.viewer-hint[hidden], .viewer-tools .btn[hidden] { display: none; }
.viewer-tools { position: absolute; left: var(--space-3); bottom: var(--space-3); display: flex; gap: var(--space-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-1); }
.viewer-tools .btn { height: 36px; width: 36px; }
.viewer-tools .btn[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }
.viewer-hint { position: absolute; right: var(--space-3); top: var(--space-3); font: var(--text-xs)/1 var(--font-mono); color: var(--text-muted); }
.panel { display: flex; flex-direction: column; gap: var(--space-5); }
.panel h1 { font-size: var(--text-xl); line-height: var(--lh-xl); }
.panel .description { color: var(--text-muted); max-width: var(--prose-max); }
.specs { display: grid; grid-template-columns: auto 1fr; margin: 0; border-top: 1px solid var(--border); }
.specs dt, .specs dd { margin: 0; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.specs dt { color: var(--text-muted); padding-right: var(--space-5); }
.specs dd { font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--lh-sm); text-align: right; overflow-wrap: anywhere; }
.panel-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.pager { display: flex; justify-content: space-between; gap: var(--space-3); border-top: 1px solid var(--border); padding-top: var(--space-4); }
.pager .btn { min-width: 0; max-width: calc(50% - var(--space-2)); padding: 0 var(--space-2); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.stage model-viewer:focus-visible { outline-offset: -2px; border-radius: var(--radius-md); }
@media (min-width: 900px) {
  .model-layout { grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-6); align-items: start; }
  .viewer { aspect-ratio: 16 / 10; }
  .panel { position: sticky; top: calc(var(--nav-height) + var(--space-5)); }
}
