/* ---------- Base ---------- */

:root {
  --paper: #f4f1ea;
  --ink: #26231f;
  --ink-2: #4a443c;
  --muted: #8a7f70;
  --rule: #d9d2c5;

  --font-display: 'Newsreader', serif;
  --font-ui: 'Instrument Sans', system-ui, sans-serif;

  --content-max: 1320px;
  --pad-x: clamp(20px, 4vw, 56px);
  --section-pad: clamp(120px, 16vw, 220px);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode follows the OS preference unless the person has picked a theme
   explicitly (data-theme on <html>, set by the inline script in <head>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1c1a17;
    --ink: #f4f1ea;
    --ink-2: #cfc9bd;
    --muted: #8f8577;
    --rule: #3a362f;
  }
}

:root[data-theme="dark"] {
  --paper: #1c1a17;
  --ink: #f4f1ea;
  --ink-2: #cfc9bd;
  --muted: #8f8577;
  --rule: #3a362f;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 300;
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

a {
  color: var(--ink);
  text-decoration: none;
  transition: color 150ms var(--ease);
}

a:hover {
  color: var(--muted);
}

button {
  font-family: inherit;
}

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

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease);
}

.btn:active {
  opacity: 0.8;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: none;
  border-radius: 999px;
  padding: 14px 26px;
}

.btn-primary:hover {
  opacity: 0.85;
}

.btn-secondary {
  background: none;
  border: 1px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  padding: 14px 26px;
}

.btn-secondary:hover {
  background: var(--ink);
  color: var(--paper);
}

.btn-secondary:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.btn-block {
  width: 100%;
}

.btn-link {
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 8px 4px;
  justify-self: start;
  white-space: nowrap;
  text-decoration: none;
}

.btn-link:hover {
  color: var(--muted);
}

/* ---------- Nav ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid transparent;
  transition: background 300ms var(--ease), border-color 300ms var(--ease);
}

.nav.is-scrolled {
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  border-bottom-color: var(--rule);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.nav-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 28px var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: padding 300ms var(--ease);
}

.nav.is-scrolled .nav-inner {
  padding: 14px var(--pad-x);
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-links a {
  font-family: var(--font-ui);
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
  transition: color 150ms var(--ease), border-color 150ms var(--ease);
}

.nav-links a:hover {
  color: var(--ink);
}

.nav-links a[aria-current="page"] {
  color: var(--ink);
  border-color: var(--ink);
}

@media (max-width: 560px) {
  .nav-left {
    gap: 16px;
  }

  .wordmark {
    display: none;
  }
}

/* Narrow screens: the links don't all fit next to the logo, so they scroll
   sideways inside the nav (fading out at the right edge) instead of pushing
   the theme toggle off screen and making the whole page scroll. */
@media (max-width: 860px) {
  .nav-inner {
    gap: 20px;
  }

  .nav-left,
  .theme-toggle {
    flex: none;
  }

  .nav-actions {
    flex: 1;
    min-width: 0;
    justify-content: flex-end;
    gap: 16px;
  }

  .nav-links {
    min-width: 0;
    gap: 24px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-right: 24px;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  }

  .nav-links::-webkit-scrollbar {
    display: none;
  }

  .nav-links a {
    flex: none;
  }
}

.brand-favicon {
  width: 22px;
  height: 22px;
  display: block;
}

.brand-logo {
  height: 22px;
  width: auto;
  display: block;
  transition: height 300ms var(--ease);
}

.nav.is-scrolled .brand-logo {
  height: 18px;
}

.wordmark {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.01em;
  transition: font-size 300ms var(--ease);
}

.nav.is-scrolled .wordmark {
  font-size: 19px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 28px;
}

.theme-toggle {
  width: 38px;
  height: 38px;
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

.theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

/* ---------- Hero ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hero {
  max-width: 1320px;
  margin: 0 auto;
  padding: 100px var(--pad-x) clamp(60px, 8vw, 100px);
}

.hero-tagline {
  font-size: clamp(52px, 9vw, 136px);
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 0.98;
  color: var(--ink);
}

.hero-description {
  max-width: 475px;
  margin: 18px 0;
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
}

/* ---------- Gallery ---------- */

.gallery {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--pad-x) var(--section-pad);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 56px 32px;
}

.card {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 0;
  color: inherit;
  text-decoration: none;
  transition: opacity 220ms var(--ease);
}

.card:hover {
  opacity: 0.85;
}

.card-thumb {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 0;
  border: none;
  overflow: hidden;
  background: var(--paper);
}

.card-thumb canvas {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 220ms var(--ease);
}

.card:hover .card-thumb canvas {
  transform: scale(1.02);
}

/* Planets gallery: square thumb, circle drawn by the canvas itself (see
   planetPresets.js's cornerRadius), so the paper background shows through
   the square's corners exactly like the reference renders. */
.card-thumb-circle {
  aspect-ratio: 1 / 1;
}

.card-title {
  margin-top: 20px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  line-height: 1.2;
  color: var(--ink);
}

.card-desc {
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--rule);
}

.site-footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: clamp(80px, 12vw, 160px) var(--pad-x) 48px;
}

.footer-note {
  max-width: 900px;
}

.footer-note-title {
  font-size: clamp(34px, 4.6vw, 60px);
  font-weight: 300;
  line-height: 1.12;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.footer-note p {
  margin-top: 28px;
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
}

.footer-note-title + p {
  margin-top: 40px;
}

.footer-note em {
  font-family: var(--font-display);
  font-style: italic;
}

.site-footer-bottom {
  margin-top: 64px;
  padding-top: 28px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-brand-name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.footer-brand-tagline {
  margin-top: 4px;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.footer-email {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid transparent;
}

.footer-email:hover {
  color: var(--ink);
  border-color: var(--rule);
}

.footer-email:empty {
  display: none;
}

.site-footer-copyright {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* ---------- Editor ---------- */

.editor {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--paper);
  display: flex;
  flex-direction: column;
}

.editor[hidden] {
  display: none;
}

.editor-topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--rule);
  flex: none;
}

.editor-title {
  font-family: var(--font-ui);
  font-size: 15px;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--ink);
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

@media (max-width: 640px) {
  .editor-topbar {
    grid-template-columns: 1fr auto;
    row-gap: 10px;
  }

  .btn-link {
    grid-column: 1;
    grid-row: 1;
  }

  .editor-title {
    grid-column: 2;
    grid-row: 1;
  }

  .editor-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    display: flex;
    flex-wrap: wrap;
    gap: 14px 18px;
  }
}

.editor-actions .btn-secondary,
.editor-actions .btn-primary {
  padding: 10px 20px;
  font-size: 14px;
}

/* ---------- Export dropdown ---------- */

.dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-toggle {
  gap: 8px;
}

.dropdown-caret {
  transition: transform 180ms var(--ease);
}

.dropdown.open .dropdown-caret {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  min-width: 150px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--rule);
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--ink);
  padding: 9px 12px;
  cursor: pointer;
}

.dropdown-menu-item:hover,
.dropdown-menu-item:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

.editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

@media (max-width: 860px) {
  .editor-body {
    flex-direction: column;
    overflow-y: auto;
  }
}

.editor-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  position: relative;
}

@media (max-width: 860px) {
  .editor-preview {
    flex: none;
    height: 46vh;
    padding: 20px;
  }
}

.canvas-frame {
  position: relative;
  overflow: hidden;
}

.canvas-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.blob-handles {
  position: absolute;
  inset: 0;
}

.blob-handle {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 50%;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
}

.blob-handle:active {
  cursor: grabbing;
}

.blob-handle:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---------- Editor control panel ---------- */

.editor-panel {
  width: 420px;
  flex: none;
  overflow-y: auto;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  padding: 20px 22px 60px;
}

@media (max-width: 860px) {
  .editor-panel {
    width: auto;
    border-left: none;
    border-top: 1px solid var(--rule);
  }
}

.panel-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--rule);
}

.panel-section:first-child {
  padding-top: 4px;
}

.panel-section-title {
  font-family: var(--font-ui);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 14px;
}

.control {
  margin-bottom: 16px;
}

.control:last-child {
  margin-bottom: 0;
}

.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.control-label {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
}

.control-value {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--rule);
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--rule);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  margin-top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--rule);
}

input[type="color"] {
  -webkit-appearance: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  background: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 3px;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
}

.color-row {
  display: flex;
  gap: 16px;
}

.number-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--rule);
  border-radius: 0;
  font-size: 14px;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
}

.color-field {
  flex: 1;
}

.export-size-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.export-size-input {
  width: 0;
  flex: 1;
}

.export-size-sep {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}

.export-size-lock {
  flex-shrink: 0;
  cursor: default;
}

.export-size-lock:hover {
  border-color: var(--rule);
  color: var(--muted);
}

.color-field-label {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
  display: block;
  margin-bottom: 8px;
}

.angle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.angle-row input[type="range"] {
  flex: 1;
}

.angle-arrow {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 150ms var(--ease);
}

.blob-item {
  border: 1px solid var(--rule);
  border-radius: 0;
  padding: 14px;
  margin-bottom: 12px;
}

.blob-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.blob-item-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
}

.blob-item-title input[type="color"] {
  width: 24px;
  height: 24px;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  line-height: 1;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}

.icon-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.chip {
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--paper);
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  transition: background 150ms var(--ease), color 150ms var(--ease), border-color 150ms var(--ease);
}

.chip:hover {
  border-color: var(--ink);
}

.chip.active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.chip-label {
  font-family: var(--font-ui);
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 14px 0 8px;
}

.chip-label:first-child {
  margin-top: 0;
}

/* ---------- Code export modal ---------- */

.code-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.code-modal[hidden] {
  display: none;
}

.code-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.code-modal-panel {
  position: relative;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 0;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 22px;
}

.code-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.code-modal-header h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.code-modal-note {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 0 0 14px;
}

.code-modal-textarea {
  flex: 1;
  min-height: 240px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  padding: 14px;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  white-space: pre;
  overflow: auto;
}

.code-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  margin-top: 14px;
}

@media (max-width: 560px) {
  .code-modal {
    padding: 12px;
  }

  .code-modal-actions {
    flex-direction: column-reverse;
    align-items: flex-end;
  }
}

/* ---------- Hari (glass tool) ---------- */

.card-thumb-phone {
  aspect-ratio: 9 / 19.5;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.swatch {
  aspect-ratio: 1;
  padding: 0;
  border-radius: 0;
  border: 2px solid transparent;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--rule);
}

.swatch.active {
  border-color: var(--ink);
}

.swatch-custom {
  background: var(--paper);
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.webgl-fallback {
  max-width: 480px;
  margin: 0 auto;
  padding: 120px 24px;
  text-align: center;
  color: var(--ink-2);
}

.webgl-fallback-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  color: var(--ink);
  margin-bottom: 10px;
}

/* ---------- Landing ---------- */

.hero-landing {
  padding-bottom: clamp(80px, 10vw, 140px);
}

.hero-landing-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-top: 18px;
}

.hero-landing-row .hero-description {
  margin: 0;
}

.landing-tool {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--pad-x) clamp(100px, 13vw, 180px);
}

.landing-tool--last {
  padding-bottom: var(--section-pad);
}

.landing-tool-inner {
  border-top: 1px solid var(--rule);
  padding-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 48px 64px;
}

.landing-tool-inner--reverse {
  flex-wrap: wrap-reverse;
}

.landing-tool-text {
  flex: 1 1 300px;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.landing-tool-text .panel-section-title {
  margin-bottom: 0;
}

.landing-tool-heading {
  font-size: clamp(40px, 5.4vw, 72px);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.landing-tool-desc {
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
}

.landing-tool-visual {
  flex: 2 1 520px;
  min-width: 0;
  display: grid;
  gap: 20px;
}

.landing-visual-3 {
  grid-template-columns: repeat(3, 1fr);
}

.landing-visual-4 {
  grid-template-columns: repeat(4, 1fr);
  align-items: end;
}

@media (max-width: 640px) {
  .landing-visual-3,
  .landing-visual-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.landing-thumb-caption {
  margin-top: 14px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  line-height: 1.2;
  color: var(--ink);
}

/* ---------- Objects ---------- */

/* Object gallery: square thumb so the fixed-aspect WebGL preview isn't
   stretched by the default card-thumb's 4:5 box (see .card-thumb-circle,
   which does the same thing for Planets). */
.card-thumb-square {
  aspect-ratio: 1 / 1;
}

/* Page sections: two featured fluted-glass families, then the tube shapes.
   The hero is the page's only big title; each family gets a compact label
   so the sections don't add much scroll. */
.object-family {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--pad-x) 72px;
}

.object-family--last {
  padding-bottom: var(--section-pad);
}

.object-family-head {
  border-top: 1px solid var(--rule);
  padding-top: 18px;
  margin-bottom: 28px;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.object-family-heading {
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.object-family-desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
}

.object-family .gallery {
  max-width: none;
  padding: 0;
}

/* Editor: canvases stacked in the frame. */
.editor-objects .editor-preview {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.editor-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-frame .canvas-layer {
  position: absolute;
  inset: 0;
}

.canvas-frame .canvas-layer.is-hidden {
  visibility: hidden;
}

.transition-canvas {
  opacity: 0;
  pointer-events: none;
  transition: opacity 650ms var(--ease);
}

.canvas-frame.can-orbit {
  cursor: grab;
  touch-action: none;
}

.canvas-frame.can-orbit:active {
  cursor: grabbing;
}

.offscreen-canvas {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 8px;
  height: 8px;
  opacity: 0;
  pointer-events: none;
}

/* Fluted glass controls */
.profile-preview {
  margin: -4px 0 18px;
  border-bottom: 1px solid var(--rule);
}

.profile-preview svg {
  display: block;
  width: 100%;
  height: 40px;
}

.profile-preview-fill {
  opacity: 0.45;
}

.profile-preview-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.stops-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.stops-buttons {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.btn-small {
  padding: 8px 16px;
  font-size: 13px;
}

.video-export {
  margin-top: 18px;
}

/* Bottom sheet: below 860px the control panel slides up over the preview
   instead of pushing it off screen. */
.sheet-handle {
  display: none;
}

@media (max-width: 860px) {
  .editor-objects {
    --sheet-h: 48vh;
  }

  .editor-objects .editor-body {
    position: relative;
    overflow: hidden;
  }

  .editor-objects .editor-preview {
    flex: 1;
    height: auto;
    min-height: 0;
    padding: 12px 16px calc(var(--sheet-h) + 12px);
  }

  .editor-objects.sheet-collapsed .editor-preview {
    padding-bottom: 64px;
  }

  .editor-objects .editor-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--sheet-h);
    padding-top: 0;
    border-top: 1px solid var(--rule);
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.1);
    transition: transform 300ms var(--ease);
  }

  .editor-objects.sheet-collapsed .editor-panel {
    transform: translateY(calc(100% - 52px));
    overflow: hidden;
  }

  .sheet-handle {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: calc(100% + 44px);
    margin: 0 -22px 8px;
    padding: 10px 0 8px;
    border: none;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
    color: var(--muted);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
  }

  .sheet-grip {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--rule);
  }
}

/* ---------- Stars ---------- */

/* Star gallery: wide hero-shaped thumb, matching the 16:9 the engine is
   tuned for (see .card-thumb-square for the Objects equivalent). */
.card-thumb-wide {
  aspect-ratio: 16 / 9;
}

/* Shown behind the preview when the background is transparent, so it's
   clear the PNG/embed will let the page show through. */
.canvas-frame-checker {
  background-color: var(--paper);
  background-image:
    linear-gradient(45deg, var(--rule) 25%, transparent 25%),
    linear-gradient(-45deg, var(--rule) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--rule) 75%),
    linear-gradient(-45deg, transparent 75%, var(--rule) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.panel-note {
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Blog ---------- */

/* Posts follow the rest of the site: left-aligned on the same content
   column as the heroes, a 680px reading measure, and figures/grids that
   step out to 960px with the "wide" class. */

.post-meta {
  font-family: var(--font-ui);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.post-meta a {
  color: var(--muted);
}

.post-meta a:hover {
  color: var(--ink);
}

.post {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 100px var(--pad-x) 0;
}

.post:last-child,
.post-more:last-child {
  padding-bottom: var(--section-pad);
}

.post-header {
  max-width: 960px;
}

.post-title {
  margin-top: 20px;
  font-size: clamp(44px, 6.6vw, 92px);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--ink);
}

.post-dek {
  margin-top: 24px;
  max-width: 620px;
  font-size: 19px;
  line-height: 1.6;
  color: var(--ink-2);
}

.post-cover {
  margin: clamp(48px, 6vw, 72px) 0 0;
  max-width: 960px;
}

.post-cover img,
.post-body img,
.post-item-thumb img {
  display: block;
  width: 100%;
  height: auto;
}

.post-body {
  margin-top: clamp(48px, 6vw, 72px);
}

.post-body > * {
  max-width: 680px;
}

.post-body > .wide {
  max-width: 960px;
}

.post-body > * + * {
  margin-top: 24px;
}

.post-body p,
.post-body li {
  font-size: 18px;
  line-height: 1.7;
  color: var(--ink-2);
}

.post-body h2 {
  margin-top: 88px;
  font-size: clamp(32px, 3.6vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.post-body h3 {
  margin-top: 52px;
  font-size: 25px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.post-body h2 + *,
.post-body h3 + * {
  margin-top: 16px;
}

.post-body > figure,
.post-body > .post-figures,
.post-body > figure + *,
.post-body > .post-figures + * {
  margin-top: 44px;
}

/* A heading right after a figure keeps its own (larger) space above it. */
.post-body > figure + h2,
.post-body > .post-figures + h2 {
  margin-top: 88px;
}

.post-body > figure + h3,
.post-body > .post-figures + h3 {
  margin-top: 52px;
}

.post-body a {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease);
}

.post-body a:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

.post-body strong {
  font-weight: 500;
  color: var(--ink);
}

.post-body em {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.06em;
}

.post-body ul,
.post-body ol {
  margin-bottom: 0;
  padding-left: 1.25em;
}

.post-body li + li {
  margin-top: 10px;
}

.post-body li::marker {
  color: var(--muted);
}

.post-body figure {
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 0;
}

.post-body figcaption {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.86em;
  padding: 0.15em 0.4em;
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

.post-body pre {
  margin-bottom: 0;
  padding: 18px 20px;
  border: 1px solid var(--rule);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.6;
}

.post-body pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.post-body blockquote {
  margin: 0;
  padding-left: 24px;
  border-left: 1px solid var(--ink);
}

.post-body blockquote p {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 24px;
  line-height: 1.4;
  color: var(--ink);
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin-top: 64px;
}

/* Image grids inside a post: <div class="post-figures wide cols-2">. */
.post-figures {
  display: grid;
  gap: 32px 20px;
}

.post-figures.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.post-figures.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.post-figures.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 640px) {
  .post-figures.cols-2 {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-figures.cols-3,
  .post-figures.cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.post-figures figure {
  margin: 0;
}

/* A linked thumbnail in a grid, e.g. a preset that opens in its editor. */
.post-body a.post-swatch {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: opacity 220ms var(--ease);
}

.post-body a.post-swatch:hover {
  opacity: 0.85;
}

.post-swatch-name {
  display: block;
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.2;
  color: var(--ink);
}

.post-swatch-desc {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
}

.post-cta {
  margin-top: clamp(88px, 11vw, 128px);
  max-width: 960px;
  border-top: 1px solid var(--rule);
  padding-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20px;
}

.post-cta .panel-section-title {
  margin-bottom: 0;
}

.post-cta-heading {
  font-size: clamp(36px, 4.6vw, 60px);
  font-weight: 300;
  line-height: 1.04;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.post-cta-desc {
  max-width: 480px;
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
}

/* ---------- Blog: post lists (index and "More from the blog") ---------- */

.post-list--index {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 var(--pad-x) var(--section-pad);
}

.post-item {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 4fr);
  gap: 28px 56px;
  align-items: start;
  padding: 28px 0 64px;
  border-top: 1px solid var(--rule);
  color: inherit;
  transition: opacity 220ms var(--ease);
}

.post-item:hover {
  color: inherit;
  opacity: 0.85;
}

.post-item--text {
  grid-template-columns: minmax(0, 1fr);
}

.post-item-text {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.post-item-title {
  font-size: clamp(30px, 3.6vw, 48px);
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.post-item-desc {
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-2);
}

@media (max-width: 760px) {
  .post-item {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: 48px;
  }
}

.post-more {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: clamp(100px, 13vw, 160px) var(--pad-x) 0;
}

.post-more-title {
  margin-bottom: 28px;
  font-size: clamp(28px, 3vw, 36px);
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.post-more .post-item-title {
  font-size: clamp(24px, 2.6vw, 32px);
}

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

/* Live hero demo inside a post: a dark box a script draws into (the Stars
   post mounts a star field here). Content sits above the mounted canvas. */
.post-hero-demo {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: flex-end;
  padding: clamp(20px, 4vw, 44px);
  background: #16061c;
}

/* Taller on phones so the headline has room. (No min-height: with
   aspect-ratio it would turn into a min-width and overflow the column.) */
@media (max-width: 640px) {
  .post-hero-demo {
    aspect-ratio: 4 / 3;
  }
}

.post-hero-demo-content {
  position: relative;
  z-index: 1;
}

.post-body .post-hero-demo-kicker {
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
}

.post-body .post-hero-demo-title {
  margin-top: 8px;
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(28px, 4.4vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #fff;
}

/* Color palette in a post: <div class="post-palette"> holding swatches.
   Each swatch is an inline SVG whose fill is the color (no inline styles),
   followed by a name and the hex code. */
.post-palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 24px 16px;
}

.post-palette-swatch svg {
  display: block;
  width: 100%;
  height: 88px;
  border: 1px solid var(--rule);
}

.post-palette-name {
  display: block;
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
}

.post-palette-swatch code {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
}
