/* Mobile-first, no framework, no web fonts. The whole stylesheet is a few KB
   and the system font stack costs zero bytes over the wire. */

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --border: #e2ded8;
  --text: #1c1a17;
  --muted: #6b6459;
  --accent: #9a5b2c;
  --accent-soft: #f3e9e0;
  --danger: #a02f22;
  --radius: 10px;
  --max: 62rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #1f1e18;
    --border: #34322a;
    --text: #ece8e0;
    --muted: #9a9287;
    --accent: #d99a63;
    --accent-soft: #2b2419;
    --danger: #e07a6b;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

main {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.5rem 1.1rem 4rem;
}

/* ---------- chrome ---------- */

header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
}
.brand span { color: var(--accent); }

header.site nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

footer.site {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.1rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}
footer.site p { margin: 0; }

.inline { display: inline; margin: 0; }

button.link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}
button.link.danger { color: var(--danger); }

/* ---------- home ---------- */

.intro h1 {
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  margin: 0.5rem 0 0.4rem;
}
.intro p { color: var(--muted); margin: 0 0 1.75rem; max-width: 42rem; }

.grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }

.card-art {
  aspect-ratio: 4 / 3;
  background: var(--accent-soft);
  color: var(--accent);
  overflow: hidden;
}
.card-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-placeholder { display: grid; place-items: center; height: 100%; }
.card-placeholder svg { width: 34%; height: auto; opacity: 0.65; }

.card-body { padding: 0.85rem 1rem 1rem; }
.card-body h2 { margin: 0 0 0.15rem; font-size: 1.02rem; }
.card-body p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.empty { color: var(--muted); }

/* ---------- model page ---------- */

.back { font-size: 0.88rem; margin: 0 0 0.5rem; }
.back a { text-decoration: none; }

.model h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}

model-viewer {
  width: 100%;
  /* Tall enough to be usable one-handed on a phone without pushing the specs
     entirely below the fold. */
  height: min(70vh, 32rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  --poster-color: transparent;
}

.mv-progress {
  display: block;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.2s;
}

.ar-button {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  margin: 0.6rem 0 2rem;
}

.description h2, .specs h2 {
  font-size: 1.05rem;
  margin: 0 0 0.6rem;
}
.description p { margin: 0 0 2rem; max-width: 42rem; }

.specs dl {
  margin: 0;
  border-top: 1px solid var(--border);
}
.specs dl > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.specs dt { color: var(--muted); font-size: 0.88rem; }
.specs dd { margin: 0; font-size: 0.88rem; text-align: right; }

/* ---------- forms ---------- */

.login {
  max-width: 22rem;
  margin: 3rem auto;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.login h1 { font-size: 1.3rem; margin: 0; }

label { display: block; font-size: 0.9rem; font-weight: 550; }

input[type="text"], input[type="password"], textarea {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
  /* 16px minimum stops iOS Safari zooming in when the field is focused. */
  font-size: 16px;
}

input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
}

button[type="submit"] {
  padding: 0.65rem 1.2rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button[type="submit"]:hover { filter: brightness(1.08); }

/* ---------- admin ---------- */

h1 { font-size: 1.6rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; margin-top: 2.5rem; }

.flash, .error {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 1rem 0;
}
.flash { background: var(--accent-soft); color: var(--text); border: 1px solid var(--border); }
.error { background: #fdecea; color: #7d2318; border: 1px solid #f2c5be; }

@media (prefers-color-scheme: dark) {
  .error { background: #2e1a17; color: #f0a99c; border-color: #573028; }
}

.log { margin: 1rem 0; font-size: 0.85rem; }
.log summary { cursor: pointer; color: var(--muted); }
.log pre {
  overflow-x: auto;
  padding: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.78rem;
  line-height: 1.5;
}

table.models {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  display: block;
  overflow-x: auto;
}
table.models th, table.models td {
  text-align: left;
  padding: 0.6rem 0.7rem 0.6rem 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.models th { color: var(--muted); font-weight: 550; }
td.actions { display: flex; gap: 0.9rem; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}
.pill.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.guide {
  border-left: 3px solid var(--accent);
  padding: 0.1rem 0 0.1rem 0.9rem;
  margin: 1rem 0 1.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.guide p { margin: 0.6rem 0; }

.upload { display: flex; flex-direction: column; gap: 1.1rem; max-width: 40rem; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.2rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
}
legend { font-size: 0.9rem; font-weight: 600; padding: 0 0.4rem; }

label.file { font-weight: 400; }
.fname { display: block; font-weight: 600; font-size: 0.92rem; }
.fhint { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 0.2rem; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--accent-soft);
  padding: 0.05em 0.35em;
  border-radius: 4px;
}

.req, .rec, .opt {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  vertical-align: 0.1em;
}
.req { background: var(--accent); color: #fff; }
.rec { background: var(--accent-soft); color: var(--accent); }
.opt { background: transparent; color: var(--muted); border: 1px solid var(--border); }

label.check { font-weight: 400; display: flex; gap: 0.5rem; align-items: center; }
label.check input { margin: 0; }

.note {
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0;
  padding: 0.8rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ---------- poster / viewer ---------- */

.poster-button {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1.3rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.25);
}

model-viewer[reveal="interaction"] { cursor: pointer; }

/* ---------- render gallery ---------- */

.gallery h2, .turntable h2 { font-size: 1.05rem; margin: 2rem 0 0.7rem; }

.strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.6rem;
}

.shot {
  display: block;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  line-height: 0;
}
.shot img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
.shot:hover { border-color: var(--accent); }

/* CSS-only lightbox: :target means no JavaScript, which keeps the
   Content-Security-Policy locked to script-src 'self' with nothing inline. */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(0 0 0 / 0.9);
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.lightbox:target { display: flex; }
.lightbox img {
  max-width: 100%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 6px;
}
.lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: 1rem;
  font-size: 2.4rem;
  line-height: 1;
  color: #fff;
  text-decoration: none;
  padding: 0.3rem 0.7rem;
}

.turntable video {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}
.turntable .hint { text-align: left; margin-top: 0.4rem; }

/* ---------- job progress ---------- */

.job { max-width: 40rem; }
.working { display: flex; align-items: center; gap: 0.6rem; font-size: 0.95rem; }

.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--border); }
}

/* ---------- admin extras ---------- */

.warn {
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin: 1rem 0;
  background: #fff6e5;
  border: 1px solid #f0d9a8;
  color: #6b4c11;
}
@media (prefers-color-scheme: dark) {
  .warn { background: #2b2415; border-color: #55451f; color: #e8c98a; }
}

details.edit { margin-top: 0.4rem; }
details.edit summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.82rem;
}

.editform {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0.7rem 0 1rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 26rem;
  white-space: normal;
}
.editform button[type="submit"] { align-self: flex-start; padding: 0.4rem 0.9rem; font-size: 0.88rem; }

select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
}

table.models td:first-child { white-space: normal; min-width: 16rem; }
