/* Layout: shape picker and sliders, then the 3D stone beside its ray-traced face-up light map,
   then the bow-tie explanation, size per carat and GIA's position. Palette follows the JewelLoop site. */
:root {
  --paper: #ffffff;
  --ink: #16161a;
  --ink-soft: #3d3d45;
  --muted: #6b6b75;
  --rule: #e4e2de;
  --mist: #f4f3f1;
  --ruby: #9b1b30;
  --gold: #b8892f;
  --good: #2f7d4f;
  --warn: #b7791f;
  --stage-top: #e6e3dc;
  --stage-bottom: #c9c4b9;
  --map-bright: #f3ead2;
  --map-head: #6f86a6;
  --map-leak: #141418;
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  --paper: #121216; --ink: #f1efe9; --ink-soft: #c9c6bf; --muted: #9a978f; --rule: #2c2c33; --mist: #1b1b21;
  --ruby: #e0566c; --gold: #e1b25a; --good: #5fbf86; --warn: #e3a948; --stage-top: #24242b; --stage-bottom: #0d0d11;
  --map-bright: #efe3c4; --map-head: #7d95b8; --map-leak: #000000; color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
a { color: var(--ink); text-decoration-color: var(--ruby); text-underline-offset: 3px; }
.wrap { max-width: 1200px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 48px; display: grid; gap: 26px; }
header.top { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--ink); padding-bottom: 14px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ruby); display: inline-flex; align-items: center; gap: 10px; }
.eyebrow::before { content: ""; flex: none; width: 4px; height: 15px; background: var(--gold); clip-path: polygon(0 24%, 100% 0, 100% 76%, 0 100%); }
h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(30px, 4.6vw, 48px); line-height: 1.03; letter-spacing: -.01em; margin: 6px 0 0; text-wrap: balance; }
h2.sec { font-family: var(--font-display); font-weight: 500; font-size: 28px; margin: 0; line-height: 1.1; text-wrap: balance; }
.lede { max-width: 56ch; color: var(--ink-soft); margin: 0; }
.prototype { font-size: 12px; color: var(--muted); border: 1px solid var(--rule); padding: 4px 10px; white-space: nowrap; }
p.copy { margin: 0; color: var(--ink-soft); max-width: 68ch; }
.mini { font: 600 12px var(--font-body); letter-spacing: .14em; text-transform: uppercase; margin: 0; color: var(--ink-soft); }
section.study { border-top: 1px solid var(--ink); padding-top: 18px; display: grid; gap: 16px; }

.controls { display: grid; gap: 14px 24px; grid-template-columns: minmax(0, 1.3fr) repeat(2, minmax(0, 1fr)); align-items: end; }
@media (max-width: 900px) { .controls { grid-template-columns: 1fr 1fr; } .controls .shapes { grid-column: 1 / -1; } }
@media (max-width: 520px) { .controls { grid-template-columns: 1fr; } }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { font: 600 14px var(--font-body); border: 1px solid var(--ink); background: var(--paper); color: var(--ink); padding: 7px 12px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:focus-visible, input:focus-visible { outline: 2px solid var(--ruby); outline-offset: 2px; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; }
.slider label { font-size: 13px; font-weight: 600; }
.slider output { font: 500 13px var(--font-data); }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--ruby); }
.slider .help { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

.views { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .views { grid-template-columns: 1fr; } }
.panel { display: grid; gap: 8px; min-width: 0; }
.stage { position: relative; aspect-ratio: 1 / 1; max-width: 100%; background: radial-gradient(120% 90% at 50% 25%, var(--stage-top), var(--stage-bottom)); clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 20px 100%, 0 calc(100% - 20px)); overflow: hidden; touch-action: none; }
.stage canvas { display: block; width: 100%; height: 100%; }
.stage .hint { position: absolute; top: 10px; left: 12px; font-size: 12px; color: var(--ink-soft); pointer-events: none; }
.mapbox { position: relative; aspect-ratio: 1 / 1; background: var(--mist); display: grid; place-items: center; }
#map { width: 92%; height: auto; image-rendering: auto; }
.busy { position: absolute; top: 10px; right: 12px; font: 500 12px var(--font-body); color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; display: inline-block; border: 1px solid var(--rule); }
.ratio-note { margin: 0; padding: 8px 12px; background: var(--mist); border-left: 3px solid var(--rule); font-size: 14px; }
.ratio-note.in { border-color: var(--good); } .ratio-note.out { border-color: var(--warn); }

.explain { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .explain { grid-template-columns: 1fr; } }
.explain div { border-top: 2px solid var(--ink); padding-top: 10px; display: grid; gap: 6px; align-content: start; }
.explain h3 { margin: 0; font: 600 15px var(--font-body); }
.explain p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.tablewrap { overflow-x: auto; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 620px; }
table.cmp th { text-align: left; font: 600 12px var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--ink); }
table.cmp td { padding: 8px; border-bottom: 1px solid var(--rule); }
table.cmp td.num { font-family: var(--font-data); white-space: nowrap; }
table.cmp tr.current td { background: var(--mist); }
.callout { margin: 0; border-left: 3px solid var(--ruby); background: var(--mist); padding: 10px 14px; max-width: 80ch; }
.sources { font-size: 13px; color: var(--ink-soft); display: grid; gap: 4px; padding-left: 18px; margin: 0; }
footer.note { font-size: 12px; color: var(--muted); border-top: 1px solid var(--rule); padding-top: 12px; max-width: 95ch; }
.fallback { padding: 24px; color: var(--ink-soft); }
/* jewelloop.net: one column that never grows wider than the screen */
.wrap { grid-template-columns: minmax(0, 1fr); }
.jl-table-scroll { overflow-x: auto; max-width: 100%; }
/* shown once the page's script has run (static/visual/ready.js): no jump while loading */
html:not(.jl-ready) .wrap { visibility: hidden; }

/* On jewelloop.net the page around it shows the title and the introduction. */
header.top { display: none !important; }
