/* Terracotta Power Recliner – 3D viewer */
:root {
  --ink: #1f1b18;
  --ink-2: #5b534d;
  --ink-3: #8a817a;
  --line: rgba(31, 27, 24, 0.1);
  --paper: #f6f4f1;
  --accent: #c9553b;
  --accent-ink: #9e3d27;
  --glass: rgba(255, 255, 255, 0.72);
  --radius: 14px;
  --header-h: 60px;
  --font: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

button { font: inherit; color: inherit; }
a { color: var(--accent-ink); }

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 3vw, 36px);
  background: rgba(246, 244, 241, 0.86);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, #e57a5f, #b9452c);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.topnav { display: flex; gap: clamp(12px, 2.5vw, 28px); }
.topnav a {
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
}
.topnav a:hover { color: var(--ink); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 420px);
  min-height: calc(100vh - var(--header-h));
}

/* ---------- 3D stage ---------- */
.stage {
  position: relative;
  height: calc(100vh - var(--header-h));
  height: calc(100svh - var(--header-h));
  min-height: 460px;
  position: sticky;
  top: var(--header-h);
  overflow: hidden;
  container: stage / inline-size;
  background:
    radial-gradient(120% 80% at 50% 38%, #ffffff 0%, #f5f2ee 42%, #e4dfd9 78%, #d9d3cc 100%);
}
.stage::after {               /* soft floor horizon */
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 34%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(214, 207, 199, 0.35));
  pointer-events: none;
}

model-viewer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 64px;          /* frame the chair above the toolbar */
  width: 100%;
  height: auto;
  z-index: 1;
  background: transparent;
  --poster-color: transparent;
  --progress-bar-color: transparent;
  outline: none;
}
model-viewer:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }

.progress {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: min(220px, 50%);
  height: 3px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: rgba(31, 27, 24, 0.1);
  overflow: hidden;
  transition: opacity 0.4s ease;
}
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}
.progress.done { opacity: 0; }

.hint {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.hint.gone { opacity: 0; }

.load-error {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 12px 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--accent-ink);
}

.ar-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
.ar-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* controls */
.controls {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px);
}
.views,
.tools {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(40, 30, 20, 0.08);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
}
.views button,
.icon-btn {
  border: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.views button {
  padding: 8px 14px;
  font-size: 14px;
  color: var(--ink-2);
}
.views button:hover,
.icon-btn:hover { background: rgba(31, 27, 24, 0.06); color: var(--ink); }
.views button.active { background: var(--ink); color: #fff; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  color: var(--ink-2);
  font-size: 14px;
}
.icon-btn svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.icon-btn[aria-pressed="true"] { color: var(--accent-ink); background: rgba(201, 85, 59, 0.12); }
.icon-btn .i-exit { display: none; }
.icon-btn[aria-pressed="true"] .i-exit { display: block; }
.icon-btn[aria-pressed="true"] .i-enter { display: none; }

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

/* fullscreen (native and fallback) */
.stage:fullscreen { height: 100vh; min-height: 0; }
.stage:-webkit-full-screen { width: 100%; height: 100%; }
.stage.pseudo-fs {
  position: fixed;
  inset: 0;
  z-index: 100;
  height: 100%;
  height: 100dvh;
}
body.no-scroll { overflow: hidden; }

/* ---------- info panel ---------- */
.info {
  padding: clamp(28px, 4vw, 48px) clamp(20px, 3vw, 40px) 48px;
  background: #fff;
  border-left: 1px solid var(--line);
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 3vw, 36px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 650;
}
h2 {
  margin: 34px 0 12px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.tag {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: none;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f4e7e2;
  color: var(--accent-ink);
}
.lede { margin: 0; color: var(--ink-2); font-size: 15.5px; }

.swatch {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chip {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ee8a6f, #d9634a 55%, #a9452f);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  flex: none;
}
.swatch-name { margin: 0; font-weight: 600; font-size: 15px; }
.swatch-sub { margin: 0; color: var(--ink-3); font-size: 13px; }

.features {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.features li {
  position: relative;
  padding-left: 20px;
  color: var(--ink-2);
  font-size: 14.5px;
}
.features li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.specs {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}
.specs th,
.specs td {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.specs th { text-align: left; font-weight: 500; color: var(--ink-2); padding-right: 12px; }
.specs td { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.specs td span { color: var(--ink-3); font-weight: 400; }
.specs.compact td { font-weight: 500; font-size: 13.5px; }

.note {
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--ink-3);
}

.download {
  display: inline-flex;
  margin-top: 22px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid var(--ink);
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease, color 0.2s ease;
}
.download:hover { background: var(--ink); color: #fff; }

/* ---------- render + footer ---------- */
.render {
  padding: clamp(32px, 6vw, 80px) clamp(16px, 4vw, 48px);
  background: #ebe7e2;
}
.render figure { margin: 0 auto; max-width: 980px; }
.render img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 30px 60px rgba(60, 40, 25, 0.12);
}
.render figcaption { margin-top: 12px; font-size: 13px; color: var(--ink-3); text-align: center; }

.footer {
  padding: 26px clamp(16px, 4vw, 48px);
  font-size: 13px;
  color: var(--ink-3);
  text-align: center;
  border-top: 1px solid var(--line);
}
.footer p { margin: 0; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; min-height: 0; }
  .stage {
    position: relative;
    top: 0;
    height: 72vh;
    height: 72svh;
    min-height: 420px;
  }
  .info { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  :root { --header-h: 54px; }
  .topnav a[href="#render"] { display: none; }
}

/* the toolbar adapts to the width of the viewer itself (container query) */
@container stage (max-width: 720px) {
  .controls {
    flex-direction: column;
    gap: 8px;
    bottom: max(14px, env(safe-area-inset-bottom));
    width: min(520px, calc(100% - 24px));
  }
  .views, .tools { width: 100%; justify-content: space-between; }
  .views button { flex: 1; padding: 8px 6px; }
  .icon-btn { flex: 1; justify-content: center; padding: 0 6px; }
  model-viewer { bottom: 118px; }
}
@container stage (max-width: 520px) {
  .icon-btn .label { display: none; }
  .hint { top: 12px; font-size: 12px; }
  .ar-btn { top: auto; bottom: 12px; right: 50%; transform: translateX(50%); }
}
@container stage (max-width: 360px) {
  .views button { font-size: 13px; }
}
