/* How — a picture-encyclopedia look: cream paper, ink lines, a few bold colours. */
:root {
  --paper: #fbf4e4;
  --paper-2: #f3e9d2;
  --ink: #1d2433;
  --ink-2: #4a5263;
  --muted: #7d8494;
  --line: #d9cdb2;
  --red: #e4572e;
  --red-dark: #c9431c;
  --teal: #1f8a8a;
  --mustard: #e8b43a;
  --navy: #2b4c7e;
  --shadow: 0 10px 30px -14px rgba(29, 36, 51, .35);
  --radius: 18px;
  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #171a22;
    --paper-2: #1f232e;
    --ink: #f1e9d8;
    --ink-2: #c9c1b0;
    --muted: #8d8a82;
    --line: #363b48;
    --red: #ff7a52;
    --red-dark: #e6602f;
    --mustard: #f0c35a;
    --teal: #3fb3b3;
    --navy: #6f9bd6;
    --shadow: 0 10px 30px -14px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  background-image: radial-gradient(circle at 1px 1px, rgba(29,36,51,.06) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: min(100% - 32px, 980px); margin: 0 auto; padding-bottom: 40px; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---- header ---- */
.top {
  width: min(100% - 32px, 980px); margin: 0 auto; padding: 14px 0 6px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -.01em; }
.brand-name em { font-style: italic; color: var(--red); }
.brand-q { color: var(--teal); font-weight: 900; }
.auth { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.signed { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.signed .dot { width: 8px; height: 8px; border-radius: 50%; background: #27a86c; box-shadow: 0 0 0 3px rgba(39,168,108,.2); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 999px; border: 2px solid var(--ink); padding: 12px 20px;
  font-weight: 800; background: transparent; transition: transform .08s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 6px 0 -2px var(--red-dark); }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { border-color: var(--line); background: var(--paper-2); }
.btn-sm { padding: 8px 14px; font-size: 14px; }
.link { background: none; border: 0; padding: 0; color: var(--navy); text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.link:hover { color: var(--red); }

/* ---- hero ---- */
.hero { padding: 28px 0 10px; text-align: center; }
.hero-title {
  font-family: var(--font-display); font-weight: 900; font-size: clamp(38px, 8vw, 72px);
  line-height: 1.02; letter-spacing: -.02em; margin: 0 0 12px;
}
.hero-it {
  position: relative; display: inline-block; color: var(--red); font-style: italic; padding: 0 .12em;
}
.hero-it::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: .06em; height: .18em;
  background: var(--mustard); z-index: -1; border-radius: 3px; transform: rotate(-1.5deg);
}
.hero-sub { max-width: 560px; margin: 0 auto 26px; color: var(--ink-2); font-size: 18px; }
.result:not([hidden]) ~ * .hero-title, body.has-result .hero-title { font-size: clamp(28px, 5vw, 40px); }
body.has-result .hero { padding-top: 10px; }
body.has-result .hero-sub { display: none; }

.ask { max-width: 720px; margin: 0 auto; }
.ask-row {
  display: flex; gap: 8px; background: #fff; border: 2px solid var(--ink); border-radius: 999px;
  padding: 6px 6px 6px 22px; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .ask-row { background: var(--paper-2); } }
.ask-row input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font: inherit; font-size: 19px; color: var(--ink);
}
.ask-row input::placeholder { color: var(--muted); }
.ask-row input::-webkit-search-cancel-button { -webkit-appearance: none; }
.go-arrow { transition: transform .15s; }
.btn-primary:hover .go-arrow { transform: translateX(3px); }
.ask-opts { display: flex; flex-wrap: wrap; gap: 10px 18px; justify-content: center; align-items: center; margin-top: 14px; font-size: 14px; color: var(--ink-2); }
.opt { display: inline-flex; align-items: center; gap: 8px; }
.opt select, .dialog input {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--paper-2); border: 1.5px solid var(--line);
  border-radius: 10px; padding: 7px 10px;
}
.more { width: 100%; text-align: center; }
.more summary { cursor: pointer; color: var(--muted); list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: " ▾"; }
.more[open] summary::after { content: " ▴"; }
.more[open] { background: var(--paper-2); border-radius: 14px; padding: 10px 12px; }
.more .opt { margin-top: 8px; }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 24px auto 0; max-width: 760px; }
.chip {
  border: 1.5px solid var(--line); background: var(--paper-2); border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 600;
  transition: border-color .12s, transform .08s;
}
.chip:hover { border-color: var(--ink); transform: translateY(-1px); }
.chip small { font-weight: 700; color: var(--teal); margin-left: 4px; }
.chip-demo { border-color: var(--teal); }
.recent { margin-top: 18px; font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; align-items: center; }
.recent .chip { padding: 5px 11px; font-size: 13px; }

/* ---- loading / error ---- */
.loading { text-align: center; padding: 40px 0; }
.loading-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin: 10px 0 2px; }
.loading-msg { color: var(--muted); margin: 0 0 16px; min-height: 1.5em; }
.error { margin: 20px auto; max-width: 640px; background: #fde8e1; border: 2px solid var(--red); border-radius: var(--radius); padding: 14px 18px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.error p { margin: 0; color: #7a2a12; }
@media (prefers-color-scheme: dark) { .error { background: #3a1f16; } .error p { color: #ffd2c2; } }

/* ---- result ---- */
.result { margin-top: 26px; }
.result-head { text-align: center; margin-bottom: 14px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 800; color: var(--teal); }
.result-head h2 { font-family: var(--font-display); font-size: clamp(30px, 6vw, 48px); font-weight: 900; margin: 4px 0 6px; line-height: 1.05; letter-spacing: -.02em; }
.hook { margin: 0 auto; max-width: 620px; color: var(--ink-2); font-size: 18px; font-style: italic; font-family: var(--font-display); font-weight: 500; }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px 10px; justify-content: safe center; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; border: 2px solid var(--line); background: var(--paper-2); border-radius: 999px; padding: 9px 16px; font-weight: 800; font-size: 15px; white-space: nowrap; }
.tab.active { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.stage {
  position: relative; background: #fbf4e4; border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
@media (prefers-color-scheme: dark) { .stage { background: #fbf4e4; } }
.stage-canvas { display: block; }
.stage-canvas svg { display: block; width: 100%; height: auto; max-height: 72dvh; }
.stage-canvas svg [data-part] { cursor: pointer; transition: opacity .2s; }
.stage-canvas svg.dim [data-part]:not(.hot) { opacity: .22; }
.stage-canvas svg.exploded [data-part] { transition: transform .35s cubic-bezier(.2,.7,.2,1), opacity .2s; }
.stage-canvas svg .tmw-labels [data-label] { transition: transform .35s cubic-bezier(.2,.7,.2,1); }
.stage-canvas svg.dim .tmw-labels [data-label] { opacity: .35; }
.callout {
  position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 12px; align-items: flex-start;
  background: var(--ink); color: var(--paper); border-radius: 14px; padding: 12px 40px 12px 14px; box-shadow: var(--shadow);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.callout-num { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 900; display: grid; place-items: center; }
.callout strong { display: block; font-family: var(--font-display); font-size: 18px; }
.callout span:not(.callout-num) { color: #d9d2c2; font-size: 15px; }
.callout-x { position: absolute; top: 6px; right: 8px; background: none; border: 0; color: var(--paper); font-size: 22px; line-height: 1; }

.controls { display: flex; align-items: center; gap: 14px; justify-content: space-between; padding: 10px 4px; flex-wrap: wrap; }
.controls-hint { color: var(--muted); font-size: 14px; }
.slider { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14px; flex: 1; min-width: 220px; }
.slider input { flex: 1; accent-color: var(--red); }

.steps, .parts { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.steps li, .parts li {
  background: var(--paper-2); border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px 12px 50px; position: relative; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.steps li:hover, .parts li:hover, .steps li.hot, .parts li.hot { border-color: var(--ink); }
.steps li.hot { background: #fff; }
@media (prefers-color-scheme: dark) { .steps li.hot { background: #2a2f3c; } }
.num {
  position: absolute; left: 12px; top: 12px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; font-size: 14px; background: var(--ink); color: var(--paper);
}
.parts .num { color: #fff; }
.steps li strong, .parts li strong { display: block; font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.steps li span, .parts li span { color: var(--ink-2); font-size: 15px; }
.fact { margin: 18px 0 0; padding: 14px 18px; border-left: 5px solid var(--mustard); background: var(--paper-2); border-radius: 0 14px 14px 0; color: var(--ink-2); }
.fact::before { content: "Did you know? "; font-weight: 800; color: var(--ink); }
.fact:empty { display: none; }

/* ---- photos & 3D ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: var(--paper-2); border: 2px solid var(--line); border-radius: 14px; overflow: hidden; }
.gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #ddd; }
.gallery figcaption { padding: 8px 10px; font-size: 13px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gallery figure.wide { grid-column: 1 / -1; }
.gallery figure.broken img { display: none; }
.gallery figure.broken figcaption::before { content: '🖼 '; }
.gallery figure.wide img { aspect-ratio: 16 / 9; }
.credit { color: var(--muted); font-size: 13px; margin: 10px 2px 0; }
.credit a { color: inherit; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.model3d { display: grid; gap: 10px; }
.model3d .viewer { position: relative; border: 2px solid var(--ink); border-radius: var(--radius); overflow: hidden; background: #111; aspect-ratio: 16 / 10; }
.model3d iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.model3d .thumbs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.model3d .thumbs button { flex: 0 0 auto; width: 120px; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--paper-2); padding: 0; text-align: left; }
.model3d .thumbs button.active { border-color: var(--red); }
.model3d .thumbs img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.model3d .thumbs span { display: block; padding: 4px 6px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.result-foot { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; justify-content: center; font-size: 14px; color: var(--muted); }

/* ---- footer & dialogs ---- */
.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 16px 28px; }
.foot a { color: inherit; }
.dialog { border: 2px solid var(--ink); border-radius: var(--radius); background: var(--paper); color: var(--ink); padding: 22px; max-width: 520px; width: calc(100% - 32px); }
.dialog::backdrop { background: rgba(29,36,51,.45); }
.dialog h3 { font-family: var(--font-display); margin: 0 0 10px; font-size: 22px; }
.dialog table { border-collapse: collapse; font-size: 14px; }
.dialog th, .dialog td { text-align: left; vertical-align: top; padding: 6px 8px 6px 0; border-top: 1px solid var(--line); }
.dialog th { white-space: nowrap; color: var(--ink-2); font-weight: 700; }
.dialog form { margin-top: 14px; }
.dialog input { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

/* ---- right-to-left answers ---- */
.result[dir="rtl"] { font-family: "Noto Naskh Arabic", "Amiri", var(--font-body); }
.result[dir="rtl"] h2, .result[dir="rtl"] .hook, .result[dir="rtl"] strong { font-family: "Noto Naskh Arabic", "Amiri", var(--font-display); }
.result[dir="rtl"] .steps li, .result[dir="rtl"] .parts li { padding: 12px 50px 12px 14px; }
.result[dir="rtl"] .num { left: auto; right: 12px; }
.result[dir="rtl"] .fact { border-left: 0; border-right: 5px solid var(--mustard); border-radius: 14px 0 0 14px; }
.result[dir="rtl"] .callout-x { right: auto; left: 8px; }
.result[dir="rtl"] .callout { padding: 12px 14px 12px 40px; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .ask-row { padding-left: 16px; }
  .ask-row input { font-size: 17px; }
  .go-label { display: none; }
  .btn-primary { padding: 12px 14px; }
  .brand-name { font-size: 19px; }
  .steps, .parts { grid-template-columns: 1fr; }
  body.has-result .chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; padding: 2px 4px; margin-top: 14px; }
  body.has-result .chips .chip { flex: 0 0 auto; }
  .top .btn-sm { padding: 7px 10px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .callout { animation: none; }
  .stage-canvas svg.exploded [data-part] { transition: none; }
}

/* ---- sharing ---- */
.share-lead { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-opt { text-align: left; border: 2px solid var(--line); background: var(--paper-2); border-radius: 14px; padding: 12px 14px; }
.share-opt:hover { border-color: var(--ink); }
.share-opt strong { display: block; font-family: var(--font-display); font-size: 17px; }
.share-opt span { display: block; color: var(--muted); font-size: 13px; }
.shared-note { margin: 0 0 14px; text-align: center; background: var(--paper-2); border: 1.5px dashed var(--line); border-radius: 999px; padding: 8px 16px; font-size: 14px; color: var(--ink-2); }
.shared-note a { color: var(--red); font-weight: 800; text-decoration: none; }
@media (max-width: 560px) { .share-grid { grid-template-columns: 1fr; } }

/* ---- live drawing under the headline ---- */
.hero-live {
  display: block; width: min(100%, 560px); margin: 0 auto 22px; padding: 0; border: 2px solid var(--ink); border-radius: var(--radius);
  background: #fbf4e4; overflow: hidden; box-shadow: var(--shadow); text-align: left; transition: transform .12s;
}
.hero-live:hover { transform: translateY(-2px); }
.hero-live-stage svg { display: block; width: 100%; height: auto; max-height: 42dvh; }
.hero-live-cap { display: block; padding: 8px 14px; font-size: 14px; color: var(--muted); border-top: 1.5px solid var(--line); background: var(--paper-2); }
.hero-live-cap strong { color: var(--ink); font-family: var(--font-display); font-size: 16px; }

/* ---- gallery on the home page ---- */
.gallery-home { margin-top: 36px; text-align: left; }
.gallery-h { font-family: var(--font-display); font-weight: 900; font-size: 26px; margin: 0 0 12px; letter-spacing: -.01em; }
.gallery-h em { font-style: italic; color: var(--red); }
.gallery-h small { font-family: var(--font-body); font-weight: 700; font-size: 13px; color: var(--teal); margin-left: 8px; text-transform: uppercase; letter-spacing: .1em; }
.ggrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.gcard {
  display: block; width: 100%; padding: 0; text-align: left; border: 2px solid var(--line); border-radius: 16px; background: var(--paper-2);
  overflow: hidden; transition: transform .12s, border-color .12s;
}
.gcard:hover { transform: translateY(-2px); border-color: var(--ink); }
.gthumb { background: #fbf4e4; border-bottom: 1.5px solid var(--line); }
.gthumb svg { display: block; width: 100%; height: auto; aspect-ratio: 800 / 520; }
.gcard strong { display: block; padding: 10px 12px 0; font-family: var(--font-display); font-size: 17px; }
.gcard span { display: -webkit-box; margin: 2px 12px 12px; font-size: 13px; line-height: 1.35; color: var(--muted); -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gcard[dir="rtl"] { text-align: right; font-family: "Noto Naskh Arabic", "Amiri", var(--font-body); }
@media (max-width: 560px) { .ggrid { grid-template-columns: 1fr 1fr; gap: 8px; } .gcard strong { font-size: 15px; } .gcard span { display: none; } }

/* ---- the step the animation is at right now ---- */
.steps li.now { border-color: var(--red); background: #fff; box-shadow: 0 0 0 3px rgba(228,87,46,.18); }
@media (prefers-color-scheme: dark) { .steps li.now { background: #2a2f3c; } }
.steps li.now .num { background: var(--red); color: #fff; }
.stage-canvas svg [data-part].now { filter: drop-shadow(0 0 6px rgba(228,87,46,.9)); }
.stage-canvas svg.dim [data-part].now { filter: none; }

/* ---- follow-up questions ---- */
.ask-more { display: block; margin-top: 6px; background: none; border: 0; padding: 0; color: var(--red); font-weight: 800; font-size: 13px; text-align: left; }
.ask-more:hover { text-decoration: underline; }
.ask-more-light { color: var(--mustard); }
.result[dir="rtl"] .ask-more { text-align: right; }
