/* Paint Your Pet – PaintEvents branding (slate + pink, Inter), mobile first. */
:root {
  --pe-ink: #373e48;
  --pe-ink-soft: #5a626e;
  --pe-pink: #df4c7d;
  --pe-pink-dark: #c02d5e;
  --pe-pink-tint: #fbe6ee;
  --pe-grey: #d9d9d9;
  --pe-grey-light: #f3f3f4;
  --pe-paper: #faf8f5;
  --pe-white: #ffffff;
  --ok: #2f8f5b;
  --danger: #c0392b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(55, 62, 72, 0.10);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--pe-ink);
  background: var(--pe-paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img, canvas { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--pe-pink-dark); }
[hidden] { display: none !important; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top));
  background: var(--pe-white); border-bottom: 1px solid var(--pe-grey);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--pe-ink); }
.brand-mark { width: 36px; height: 36px; color: var(--pe-pink); }
.brand-word { font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; font-size: 12px; line-height: 1.1; }
.lang-switch { display: flex; gap: 4px; }
.lang-switch button {
  border: 1px solid var(--pe-grey); background: var(--pe-white); color: var(--pe-ink-soft);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--pe-ink); color: var(--pe-white); border-color: var(--pe-ink); }

/* Layout */
.page { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 18px; }
.hero { padding: 8px 4px 0; }
.kicker { margin: 0 0 6px; color: var(--pe-pink); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
h1 { margin: 0 0 8px; font-size: clamp(2rem, 7vw, 3rem); line-height: 1.05; letter-spacing: -0.02em; }
.lead { margin: 0; color: var(--pe-ink-soft); font-size: 1.05rem; max-width: 60ch; }

.card { background: var(--pe-white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 16px; }
.step h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.2rem; }
.step-num {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--pe-pink); color: var(--pe-white); font-size: 14px; font-weight: 800; flex: none;
}
.hint { margin: 8px 0 0; color: var(--pe-ink-soft); font-size: 0.92rem; }
.hint.center { text-align: center; }
.notice {
  margin: 0 0 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--pe-grey-light); color: var(--pe-ink-soft); font-size: 0.92rem;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 2px solid transparent;
  font-weight: 700; text-decoration: none; cursor: pointer; text-align: center;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 3px solid var(--pe-pink-tint); outline-offset: 2px; }
.btn-primary { background: var(--pe-pink); color: var(--pe-white); }
.btn-primary:hover { background: var(--pe-pink-dark); }
.btn-secondary { background: var(--pe-white); color: var(--pe-ink); border-color: var(--pe-ink); }
.btn-secondary:hover { background: var(--pe-grey-light); }
.btn-ghost { background: transparent; color: var(--pe-ink-soft); border-color: var(--pe-grey); }
.btn-large { width: 100%; min-height: 54px; font-size: 1.05rem; }
.btn[disabled], .btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Step 1 */
.photo-actions { display: grid; gap: 12px; }
.file-pick { position: relative; overflow: hidden; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.orientation-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; background: var(--pe-grey-light); border-radius: 999px; }
.toggle {
  border: 0; border-radius: 999px; padding: 9px 8px; background: transparent; color: var(--pe-ink-soft);
  font-weight: 600; font-size: 0.9rem; cursor: pointer; min-height: 40px;
}
.toggle[aria-pressed="true"] { background: var(--pe-white); color: var(--pe-ink); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

.frame-wrap { display: flex; justify-content: center; margin-top: 18px; }
.frame {
  position: relative; box-sizing: content-box; /* aspect ratio applies to the canvas, not the border */
  width: min(100% - 16px, 330px); aspect-ratio: 3 / 4;
  background: repeating-conic-gradient(var(--pe-grey-light) 0% 25%, var(--pe-white) 0% 50%) 0 0 / 24px 24px;
  border: 8px solid var(--pe-white); border-radius: 4px;
  box-shadow: 0 0 0 1px var(--pe-grey), 0 14px 30px rgba(55,62,72,.18);
  overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
}
.frame.landscape { width: min(100% - 16px, 440px); aspect-ratio: 4 / 3; }
.frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.frame.has-photo canvas:active { cursor: grabbing; }
.frame:not(.has-photo) canvas { display: none; }
.frame-empty {
  position: absolute; inset: 0; margin: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  color: var(--pe-ink-soft); font-size: 0.95rem;
}
.frame.has-photo .frame-empty { display: none; }
.frame-label {
  position: absolute; right: 8px; bottom: 8px; padding: 3px 8px; border-radius: 999px;
  background: rgba(55,62,72,.78); color: var(--pe-white); font-size: 11px; font-weight: 600; pointer-events: none;
}
.crop-controls { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.zoom-label { flex: 1 1 200px; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 0.92rem; }
.zoom-label input[type="range"] { flex: 1; accent-color: var(--pe-pink); min-height: 32px; }

/* Step 2 */
.preset-list { display: grid; gap: 10px; }
.preset {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--radius-sm); border: 2px solid var(--pe-grey); background: var(--pe-white); cursor: pointer;
}
.preset[aria-checked="true"] { border-color: var(--pe-pink); background: var(--pe-pink-tint); }
.preset:focus-visible { outline: 3px solid var(--pe-pink-tint); }
.preset-swatch { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--pe-white); box-shadow: 0 0 0 1px var(--pe-grey); background: var(--pe-grey); }
.preset[data-preset="true_to_photo"] .preset-swatch { background: linear-gradient(135deg, #c9a27a, #7a5a3a 60%, #e8dcc8); }
.preset[data-preset="van_gogh"] .preset-swatch { background: conic-gradient(from 20deg, #1f3a93, #f2c12e, #3b8ea5, #e0a800, #1f3a93); }
.preset[data-preset="pop_art"] .preset-swatch { background: conic-gradient(#ff2d55 0 25%, #ffd60a 0 50%, #00c2ff 0 75%, #111 0); }
.preset[data-preset="watercolour"] .preset-swatch { background: radial-gradient(circle at 30% 30%, #f7c8d8, #a8d8ea 70%, #fff); }
.preset[data-preset="impressionist"] .preset-swatch { background: repeating-linear-gradient(45deg, #9fc5e8 0 4px, #f9cb9c 4px 8px, #b6d7a8 8px 12px); }
.preset[data-preset="vintage_illustration"] .preset-swatch { background: linear-gradient(135deg, #d9c5a0, #a67c52 60%, #6b4f3a); }
.preset[data-preset="custom"] .preset-swatch { background: conic-gradient(#df4c7d, #ffb703, #8ecae6, #df4c7d); }
.preset-text { display: grid; gap: 1px; }
.preset-text strong { font-size: 1rem; }
.preset-text small { color: var(--pe-ink-soft); font-size: 0.85rem; }
.custom-wrap { margin-top: 12px; display: grid; gap: 6px; }
.custom-wrap label { font-weight: 600; font-size: 0.95rem; }
.custom-wrap textarea {
  width: 100%; resize: vertical; min-height: 64px; padding: 10px 12px;
  border-radius: var(--radius-sm); border: 2px solid var(--pe-grey); background: var(--pe-white);
}
.custom-wrap textarea:focus { outline: none; border-color: var(--pe-pink); }
.char-count { text-align: right; color: var(--pe-ink-soft); font-size: 0.8rem; }

/* Step 3 */
.turnstile { margin: 0 0 12px; min-height: 0; }
.turnstile:empty { display: none; }
.busy { display: grid; justify-items: center; gap: 6px; margin-top: 16px; text-align: center; color: var(--pe-ink-soft); }
.busy p { margin: 0; }
.busy-timer { font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--pe-pink-tint); border-top-color: var(--pe-pink);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
.error, .error-inline {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: #fdecea; color: var(--danger); font-size: 0.95rem; font-weight: 600;
}
.error-inline { margin: 0 0 10px; }

/* Step 4 */
.result-grid { display: grid; gap: 22px; }
.result { margin: 0; display: grid; gap: 10px; justify-items: stretch; }
.result-img {
  aspect-ratio: 3 / 4; width: 100%; background: var(--pe-grey-light); border-radius: 6px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--pe-grey), 0 10px 24px rgba(55,62,72,.14);
}
.result-img.landscape { aspect-ratio: 4 / 3; }
.result-img img { width: 100%; height: 100%; object-fit: contain; }
.result figcaption { font-weight: 700; }
.outline-ok, .outline-failed { display: grid; gap: 10px; }
.result-actions { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--pe-grey); display: grid; gap: 10px; justify-items: start; }
.result-actions .hint { margin: 0; }

/* Footer */
.site-footer {
  display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; padding: 18px 16px 32px;
  color: var(--pe-ink-soft); font-size: 0.85rem;
}

/* Desktop */
@media (min-width: 760px) {
  .page { padding: 32px 24px 64px; }
  .card { padding: 26px 28px; }
  .photo-actions { grid-template-columns: auto 1fr; align-items: center; }
  .orientation-toggle { max-width: 420px; justify-self: end; }
  .preset-list { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
  .result-grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .frame { width: min(100% - 16px, 390px); }
  .frame.landscape { width: min(100% - 16px, 520px); }
}
