/* ---------- tokens ---------- */
:root {
  --ink: #22201c;
  --ink-soft: #4c4740;
  --paper: #fdfcf7;
  --glass: rgba(255, 255, 255, 0.52);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --glass-edge: rgba(255, 255, 255, 0.75);
  --shadow-soft: 0 24px 60px -24px rgba(34, 32, 28, 0.35);
  --pencil-yellow: #f2b04c;
  --radius-card: 30px;
  --wobble: 255px 18px 240px 20px / 20px 240px 18px 255px;
  --font-display: "Shantell Sans", "Comic Sans MS", cursive;
  --font-body: "Quicksand", "Avenir Next", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The `hidden` attribute must win over component display rules (e.g. the demo
   badge is a .glass-pill with display:inline-flex). Without this, hidden
   elements still show. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ---------- backdrop ---------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: url("assets/bg.jpg") center 65% / cover no-repeat #dfe9d3;
}
.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(253, 252, 247, 0.55) 0%, rgba(253, 252, 247, 0) 55%),
    linear-gradient(to bottom, rgba(253, 252, 247, 0.15), rgba(253, 252, 247, 0) 30%);
}

/* ---------- glass primitives ---------- */
.glass-pill,
.glass-card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  border: 1px solid var(--glass-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.25),
    var(--shadow-soft);
}

.glass-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}

/* ---------- topbar ---------- */
.topbar {
  position: fixed;
  top: 18px;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { font-family: var(--font-display); font-weight: 700; font-size: 17px; }
.brand-mark { width: 22px; height: 22px; color: var(--ink); }

.demo-badge {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

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

.theme-toggle { gap: 7px; padding: 7px 10px; }
.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(34, 32, 28, 0.25);
  cursor: pointer;
  background-size: 300%;
  background-position: center 70%;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.swatch:hover { transform: scale(1.12); }
.swatch:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8) inset; }
.swatch-vivid { background-image: url("assets/bg-vivid.jpg"); }
.swatch-sketch { background-image: url("assets/bg.jpg"); }

/* ---------- layout ---------- */
.page {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 108px 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

/* ---------- hero ---------- */
.hero { text-align: center; max-width: 620px; animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }

.eyebrow {
  font-weight: 700;
  font-size: 13.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-soft);
  margin-bottom: 14px;
}

.headline {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(38px, 7vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.01em;
}
.headline em { font-style: italic; font-weight: 700; }

.squiggle-wrap { position: relative; white-space: nowrap; }
.squiggle {
  position: absolute;
  left: -2%;
  bottom: -0.28em;
  width: 104%;
  height: 0.28em;
  color: var(--ink);
  overflow: visible;
}
.squiggle path {
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  animation: draw-squiggle 0.9s 0.55s ease-out forwards;
}

.subhead {
  margin: 20px auto 0;
  max-width: 480px;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.55;
  color: var(--ink-soft);
}

/* ---------- studio card ---------- */
.studio {
  margin-top: 34px;
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius-card);
  padding: 26px;
  animation: rise 0.7s 0.12s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.state[hidden] { display: none; }

/* idle / dropzone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 24px 30px;
  border: 2.5px dashed rgba(34, 32, 28, 0.45);
  border-radius: var(--wobble);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
  background: rgba(255, 255, 255, 0.25);
}
.dropzone:hover, .dropzone:focus-visible { background: rgba(255, 255, 255, 0.5); border-color: var(--ink); }
.dropzone.dragover {
  background: rgba(255, 255, 255, 0.65);
  border-color: var(--ink);
  transform: scale(1.015) rotate(-0.4deg);
}
.dropzone:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

.paw { width: 58px; height: 58px; color: var(--ink); margin-bottom: 14px; }
.dropzone:hover .paw { animation: wiggle 0.6s ease-in-out; }

.dz-title { font-family: var(--font-display); font-weight: 700; font-size: 21px; }
.dz-or { margin: 8px 0; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.dz-hint { margin-top: 16px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }

/* buttons */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  padding: 12px 26px;
  border-radius: 230px 16px 220px 18px / 18px 220px 16px 230px;
  border: 2px solid var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }

.btn-ink {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 10px 24px -10px rgba(34, 32, 28, 0.55);
}
.btn-ink:hover { transform: translateY(-2px) rotate(-0.5deg); box-shadow: 0 16px 30px -12px rgba(34, 32, 28, 0.6); }

.btn-ghost { background: rgba(255, 255, 255, 0.4); color: var(--ink); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.75); transform: translateY(-2px) rotate(0.5deg); }

/* drawing state */
.state-drawing { display: flex; flex-direction: column; align-items: center; padding: 12px 0 8px; }

.easel {
  position: relative;
  width: min(300px, 72vw);
  aspect-ratio: 1;
  background: var(--paper);
  border-radius: 18px;
  border: 1px solid rgba(34, 32, 28, 0.12);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 18px 40px -18px rgba(34, 32, 28, 0.35);
}
.easel #loaderSvg { position: absolute; inset: 0; width: 100%; height: 100%; }
.easel .stroke {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.easel .stroke.filled { fill: var(--ink); stroke-width: 2.4; }

.pencil {
  position: absolute;
  width: 52px;
  height: 52px;
  left: 0;
  top: 0;
  margin: -8px 0 0 -8px;
  filter: drop-shadow(0 4px 4px rgba(34, 32, 28, 0.25));
  will-change: transform;
}

.drawing-caption {
  margin-top: 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  min-height: 1.5em;
  transition: opacity 0.3s ease;
}
.drawing-caption.fading { opacity: 0; }
.drawing-note { margin-top: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }

/* result state */
.state-result { display: flex; flex-direction: column; align-items: center; }

.result-kicker {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  margin: 4px 0 18px;
}

.takes {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.take {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--paper);
  padding: 12px 12px 16px;
  border-radius: 6px;
  box-shadow: 0 20px 44px -18px rgba(34, 32, 28, 0.45);
  transform: rotate(var(--tilt, 0deg));
  animation: reveal 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.take:nth-child(2) { animation-delay: 0.12s; }

.preview-shield {
  position: relative;
  width: min(210px, 60vw);
  aspect-ratio: 1;
  overflow: hidden;
  background: #fff;
}
.takes.single .preview-shield { width: min(300px, 70vw); }
.preview-shield img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;         /* deterrents: no right-click target,   */
  user-select: none;            /* no selection, no drag,               */
  -webkit-user-select: none;    /* no iOS long-press save sheet         */
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
.preview-shield::after { content: ""; position: absolute; inset: 0; }

.take figcaption {
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}
.take.unlocked { box-shadow: 0 20px 44px -18px rgba(34, 32, 28, 0.45), 0 0 0 2px rgba(76, 145, 91, 0.55); }
.take-action { margin-top: 10px; }
.take-dl { font-size: 14px; padding: 9px 16px; }

.buy-row { display: flex; justify-content: center; margin-top: 22px; }
.btn-buy { font-size: 17px; padding: 13px 30px; }

.takes-note {
  margin: 16px auto 0;
  max-width: 380px;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--ink-soft);
}

.result-actions { display: flex; gap: 14px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }

/* error state */
.state-error { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 8px; }
.oops { width: 64px; height: 64px; color: var(--ink); margin-bottom: 10px; }
.error-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; }
.error-message { margin: 10px 0 22px; max-width: 380px; font-weight: 500; line-height: 1.5; color: var(--ink-soft); }

/* ---------- gallery ---------- */
.gallery { margin-top: 56px; text-align: center; width: 100%; }
.gallery-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  margin-bottom: 22px;
}
.gallery-row {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
}
.frame {
  background: var(--paper);
  padding: 10px 10px 12px;
  border-radius: 4px;
  box-shadow: 0 14px 30px -14px rgba(34, 32, 28, 0.4);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.frame:hover { transform: rotate(0deg) translateY(-6px) scale(1.03); box-shadow: 0 22px 40px -16px rgba(34, 32, 28, 0.45); }
.frame img {
  display: block;
  width: 156px;
  height: 156px;
  object-fit: cover;
  filter: grayscale(1) contrast(1.08);
}
.frame figcaption {
  margin-top: 9px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13.5px;
  color: var(--ink-soft);
}

/* ---------- footer ---------- */
.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 20px 34px;
  text-align: center;
}
.footer-links {
  gap: 6px;
  padding: 8px 10px;
}
.footer-links a {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
  padding: 5px 13px;
  border-radius: 999px;
  transition: background 0.15s ease;
}
.footer-links a:hover { background: rgba(255, 255, 255, 0.55); }
.footer-links a[aria-current="page"] { background: rgba(34, 32, 28, 0.1); }
.footer-links a:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.footer-note,
.footer-copy {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  max-width: 460px;
}
.footer-copy a { color: var(--ink-soft); }

/* ---------- legal / content pages ---------- */
.legal-page {
  max-width: 780px;
  padding-top: 100px;
  align-items: stretch;
}
.legal {
  border-radius: 28px;
  padding: 40px 46px 44px;
  text-align: left;
}
.legal h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.1;
  margin-bottom: 6px;
}
.legal-updated {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 22px;
}
.legal .lead {
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink);
  margin-bottom: 8px;
}
.legal h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  margin: 30px 0 8px;
}
.legal h3 {
  font-weight: 700;
  font-size: 16px;
  margin: 20px 0 4px;
  color: var(--ink);
}
.legal p {
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.65;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.legal ul { margin: 6px 0 14px; padding-left: 22px; }
.legal li {
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.legal strong { color: var(--ink); font-weight: 700; }
.legal a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1.5px;
}
.legal-tail { margin-top: 22px; font-weight: 600; }

.back-link {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
}
.brand[href] { text-decoration: none; color: inherit; }

/* ---------- animations ---------- */
@keyframes rise {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes draw-squiggle { to { stroke-dashoffset: 0; } }
@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  30% { transform: rotate(-8deg); }
  60% { transform: rotate(7deg); }
}
@keyframes reveal {
  from { opacity: 0; transform: rotate(-1.2deg) scale(0.92); clip-path: inset(0 100% 0 0); }
  60% { clip-path: inset(0 0 0 0); }
  to { opacity: 1; transform: rotate(-1.2deg) scale(1); clip-path: inset(0 0 0 0); }
}

/* ---------- vivid theme (background-example-1) ----------
   Brighter, saturated storybook meadow: frost the glass harder and give the
   hero its own pane so ink stays legible over the vivid sky. */
html[data-theme="vivid"] {
  --glass: rgba(255, 255, 255, 0.6);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --shadow-soft: 0 24px 60px -24px rgba(18, 48, 74, 0.45);
}
html[data-theme="vivid"] .backdrop {
  background-image: url("assets/bg-vivid.jpg");
  background-color: #9fcbe8;
  background-position: center 72%;
}
html[data-theme="vivid"] .backdrop::after {
  background:
    radial-gradient(110% 55% at 50% 0%, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 26%);
}
html[data-theme="vivid"] .hero {
  background: rgba(255, 255, 255, 0.42);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  backdrop-filter: blur(20px) saturate(1.35);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 32px;
  padding: 28px 32px 32px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 22px 54px -30px rgba(18, 48, 74, 0.4);
}
html[data-theme="vivid"] .footer-links a:hover { background: rgba(255, 255, 255, 0.7); }
html[data-theme="vivid"] .dropzone { background: rgba(255, 255, 255, 0.4); }
html[data-theme="vivid"] .dropzone:hover,
html[data-theme="vivid"] .dropzone:focus-visible,
html[data-theme="vivid"] .dropzone.dragover { background: rgba(255, 255, 255, 0.72); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---------- small screens ---------- */
@media (max-width: 520px) {
  .topbar { padding: 0 14px; }
  .studio { padding: 18px; }
  .frame img { width: 128px; height: 128px; }
}
