/* ============================================================
   PrintSizer Design System — ps.css
   Warm editorial-craft. One stylesheet for every page.
   ------------------------------------------------------------
   TOKENS         :root custom properties (color, type, space,
                  radius, shadow, motion)
   BASE           reset, typography rhythm, links, prose
   GRAIN          .ps-grain body overlay (3% noise, data-URI)
   LAYOUT         .container, .section, .grid, .stack, .cluster
   NAV / FOOTER   .nav, .footer
   BUTTONS        .btn, .btn-primary, .btn-ghost, .btn-sm, .btn-lg
   CARDS          .card, .card-pad, .tool-card, .lock-row
   FORMS          .input, .field, .label, .select, .toggle
   CHIPS/BADGES   .chip, .badge, .badge-ok/-amber/-red
   MODAL          .modal-backdrop, .modal (dialog pattern)
   DROPZONE       .dropzone (+ .is-drag glow state)
   PREVIEW GRID   .preview-grid, .preview-card, focal drag UI
   PROGRESS       .progress (shimmer bar), .done-check
   MOTION         .stagger-in children fade/rise, press states
   UTILITIES      .muted, .small, .center, .mt-*, .hidden …
   ============================================================ */

/* ---------- TOKENS ---------- */
:root {
  /* palette */
  --paper: #FAF7F2;
  --paper-deep: #F3EEE5;
  --ink: #1C1917;
  --ink-soft: #4A443E;
  --ink-faint: #857D72;
  --terra: #C4593B;
  --terra-deep: #A84730;
  --terra-tint: #F6E3DC;
  --sage: #7D8C6F;
  --sage-tint: #EAEEE5;
  --line: #E7E0D6;
  --amber: #B07C24;
  --amber-tint: #F7EBD3;
  --red: #A83232;
  --red-tint: #F6DFDD;
  --white: #FFFFFF;

  /* type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Instrument Sans", -apple-system, "Segoe UI", sans-serif;
  --fs-hero: clamp(2.4rem, 1.4rem + 4.2vw, 4.2rem);
  --fs-h2: clamp(1.7rem, 1.3rem + 1.6vw, 2.4rem);
  --fs-h3: clamp(1.25rem, 1.1rem + 0.7vw, 1.55rem);
  --fs-body: 1.0625rem;
  --fs-small: 0.875rem;
  --fs-tiny: 0.78rem;

  /* rhythm */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 7rem;

  /* surfaces */
  --radius: 20px;
  --radius-sm: 12px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(28,25,23,.04), 0 4px 14px rgba(28,25,23,.05);
  --shadow-2: 0 2px 4px rgba(28,25,23,.05), 0 12px 32px rgba(28,25,23,.09);
  --shadow-3: 0 4px 8px rgba(28,25,23,.06), 0 24px 64px rgba(28,25,23,.14);

  /* motion */
  --ease-out: cubic-bezier(.22,.8,.32,1);
  --ease-spring: cubic-bezier(.34,1.4,.44,1);
  --t-fast: 140ms;
  --t-med: 260ms;
  --t-slow: 480ms;
}

/* ---------- BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 550;
  font-variation-settings: "opsz" 72;
  line-height: 1.12;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-4);
  text-wrap: balance;
}
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }
p { margin: 0 0 var(--space-4); }
p:last-child { margin-bottom: 0; }
a { color: var(--terra); text-decoration: none; transition: color var(--t-fast) var(--ease-out); }
a:hover { color: var(--terra-deep); text-decoration: underline; text-underline-offset: 3px; }
img, canvas, svg { max-width: 100%; height: auto; display: block; }
::selection { background: var(--terra-tint); color: var(--ink); }
:focus-visible { outline: 2px solid var(--terra); outline-offset: 3px; border-radius: 4px; }
.prose { max-width: 68ch; }
.prose h2 { margin-top: var(--space-7); }
.prose h3 { margin-top: var(--space-6); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 var(--space-4); }
.prose li { margin-bottom: var(--space-2); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--space-7) 0; }

/* ---------- GRAIN (subtle paper texture, ~3% opacity) ---------- */
.ps-grain::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.032;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

/* ---------- LAYOUT ---------- */
.container { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }
.container-narrow { width: min(760px, 100% - 2.5rem); margin-inline: auto; }
.section { padding-block: var(--space-8); }
.section-tight { padding-block: var(--space-7); }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid-3 { display: grid; gap: var(--space-5); grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.center { text-align: center; }
.center > * { margin-inline: auto; }

/* ---------- NAV ---------- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: var(--space-5);
}
.brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--ink);
  display: inline-flex; align-items: baseline; gap: 2px;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand .brand-dot { color: var(--terra); font-size: 1.6em; line-height: 0; transform: translateY(0.08em); }
.nav-links { display: flex; gap: var(--space-5); font-size: var(--fs-small); }
.nav-links a { color: var(--ink-soft); }
.nav-links a:hover { color: var(--terra); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--terra); font-weight: 600; }
@media (max-width: 560px) { .nav-links { gap: var(--space-4); } }

/* ---------- FOOTER ---------- */
.footer {
  border-top: 1px solid var(--line);
  margin-top: var(--space-8);
  padding-block: var(--space-6);
  font-size: var(--fs-small);
  color: var(--ink-faint);
}
.footer a { color: var(--ink-soft); }
.footer .cluster { justify-content: space-between; }

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-body); font-weight: 600;
  padding: 0.8em 1.6em;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  transition: transform var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out),
              background var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
  box-shadow: var(--shadow-1);
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); text-decoration: none; }
.btn:active { transform: translateY(1px) scale(0.985); box-shadow: none; }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary {
  background: var(--terra);
  border-color: var(--terra);
  color: #FFF8F4;
}
.btn-primary:hover { background: var(--terra-deep); border-color: var(--terra-deep); color: #FFF8F4; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper-deep); box-shadow: none; }
.btn-sm { font-size: var(--fs-small); padding: 0.55em 1.1em; }
.btn-lg { font-size: 1.15rem; padding: 0.95em 2.2em; }

/* ---------- CARDS ---------- */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--space-6); }
.tool-card {
  display: block; color: var(--ink);
  padding: var(--space-6);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out);
}
.tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); text-decoration: none; color: var(--ink); }
.tool-card .tool-kicker {
  font-size: var(--fs-tiny); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--sage); margin-bottom: var(--space-3);
}
.tool-card h3 { margin-bottom: var(--space-2); }
.tool-card p { color: var(--ink-soft); font-size: var(--fs-small); }
.tool-card .tool-go { color: var(--terra); font-weight: 600; font-size: var(--fs-small); }

/* locked Pro row */
.lock-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-deep);
  color: var(--ink-faint);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out);
  font-size: var(--fs-small);
}
.lock-row:hover { border-color: var(--terra); color: var(--ink-soft); }
.lock-row .lock-ico { color: var(--amber); flex: none; }

/* ---------- FORMS ---------- */
.field { display: block; }
.label {
  display: block; font-size: var(--fs-small); font-weight: 600;
  color: var(--ink-soft); margin-bottom: var(--space-2);
}
.input, .select {
  width: 100%;
  font: inherit; color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7em 1em;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.input:focus, .select:focus { outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px var(--terra-tint); }
.input::placeholder { color: var(--ink-faint); }
.input-error { border-color: var(--red); }
.help-text { font-size: var(--fs-tiny); color: var(--ink-faint); margin-top: var(--space-1); }

/* ---------- CHIPS & BADGES ---------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: var(--fs-tiny); font-weight: 600;
  padding: 0.4em 0.9em;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink-soft);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), background var(--t-fast) var(--ease-out);
}
.chip:hover { border-color: var(--terra); }
.chip-pro { background: var(--terra-tint); border-color: transparent; color: var(--terra-deep); }
.badge {
  display: inline-flex; align-items: center; gap: 0.35em;
  font-size: var(--fs-tiny); font-weight: 600;
  padding: 0.28em 0.75em;
  border-radius: var(--radius-pill);
}
.badge-ok { background: var(--sage-tint); color: #55663F; }
.badge-amber { background: var(--amber-tint); color: var(--amber); }
.badge-red { background: var(--red-tint); color: var(--red); }

/* ---------- MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(28,25,23,0.42);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med) var(--ease-out);
}
.modal-backdrop.is-open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  width: min(460px, 100%);
  padding: var(--space-6);
  transform: translateY(14px) scale(0.97);
  transition: transform var(--t-med) var(--ease-spring);
  max-height: 90vh; overflow: auto;
}
.modal-backdrop.is-open .modal { transform: none; }
.modal-close {
  float: right; background: none; border: 0; cursor: pointer;
  font-size: 1.3rem; color: var(--ink-faint); line-height: 1; padding: var(--space-1);
}
.modal-close:hover { color: var(--ink); }
.modal h3 { margin-top: 0; }

/* ---------- DROPZONE ---------- */
.dropzone {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--white);
  padding: clamp(2.5rem, 6vw, 4.5rem) var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--t-med) var(--ease-out),
              box-shadow var(--t-med) var(--ease-out),
              background var(--t-med) var(--ease-out),
              transform var(--t-med) var(--ease-out);
  box-shadow: var(--shadow-1);
}
.dropzone:hover { border-color: var(--terra); box-shadow: var(--shadow-2); }
.dropzone.is-drag {
  border-color: var(--terra);
  background: #FFFCF9;
  box-shadow: 0 0 0 6px var(--terra-tint), var(--shadow-2);
  transform: scale(1.008);
}
.dropzone .dz-icon { margin: 0 auto var(--space-4); color: var(--terra); width: 52px; height: 52px; }
.dropzone .dz-title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 550; margin-bottom: var(--space-2); }
.dropzone .dz-sub { color: var(--ink-faint); font-size: var(--fs-small); margin: 0; }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

/* ---------- PREVIEW GRID ---------- */
.preview-grid {
  display: grid;
  gap: var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.preview-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  transition: box-shadow var(--t-med) var(--ease-out);
}
.preview-card:hover { box-shadow: var(--shadow-2); }
.preview-thumb {
  position: relative;
  background:
    repeating-conic-gradient(var(--paper-deep) 0% 25%, var(--white) 0% 50%) 0 0/16px 16px;
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1 / 1.05;
  overflow: hidden;
  touch-action: none;             /* focal drag on touch */
}
.preview-thumb canvas {
  max-width: 88%; max-height: 88%;
  width: auto; height: auto;
  box-shadow: var(--shadow-2);
  cursor: grab;
  border-radius: 2px;
}
.preview-thumb.is-dragging canvas { cursor: grabbing; box-shadow: var(--shadow-3); }
.preview-thumb .drag-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: var(--fs-tiny); color: var(--ink-faint);
  background: rgba(250,247,242,0.9);
  padding: 0.15em 0.7em; border-radius: var(--radius-pill);
  pointer-events: none;
  opacity: 0; transition: opacity var(--t-med) var(--ease-out);
  white-space: nowrap;
}
.preview-card:hover .drag-hint { opacity: 1; }
.preview-meta { padding: var(--space-4); }
.preview-meta .ratio-name {
  font-family: var(--font-display); font-weight: 600; font-size: 1.05rem;
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2);
}
.preview-meta .ratio-sizes { font-size: var(--fs-tiny); color: var(--ink-faint); margin: var(--space-1) 0 var(--space-3); }
.preview-meta .badge { width: 100%; justify-content: center; }

/* ---------- PROGRESS ---------- */
.progress {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--paper-deep);
  overflow: hidden;
  position: relative;
}
.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--terra), #D87A5C, var(--terra));
  background-size: 200% 100%;
  animation: ps-shimmer 1.2s linear infinite;
  transition: width var(--t-med) var(--ease-out);
}
@keyframes ps-shimmer {
  from { background-position: 200% 0; }
  to { background-position: 0% 0; }
}

/* done state: gentle scale + check */
.done-check {
  width: 64px; height: 64px; margin-inline: auto;
  border-radius: 50%;
  background: var(--sage-tint); color: #55663F;
  display: flex; align-items: center; justify-content: center;
  animation: ps-pop var(--t-slow) var(--ease-spring) both;
}
.done-check svg { width: 30px; height: 30px; }
.done-check svg path {
  stroke-dasharray: 48; stroke-dashoffset: 48;
  animation: ps-draw 500ms 180ms var(--ease-out) forwards;
}
@keyframes ps-pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes ps-draw { to { stroke-dashoffset: 0; } }

/* ---------- MOTION: stagger-in ---------- */
.stagger-in > * {
  opacity: 0;
  transform: translateY(14px);
  animation: ps-rise var(--t-slow) var(--ease-out) forwards;
}
.stagger-in > *:nth-child(1) { animation-delay: 40ms; }
.stagger-in > *:nth-child(2) { animation-delay: 110ms; }
.stagger-in > *:nth-child(3) { animation-delay: 180ms; }
.stagger-in > *:nth-child(4) { animation-delay: 250ms; }
.stagger-in > *:nth-child(5) { animation-delay: 320ms; }
.stagger-in > *:nth-child(6) { animation-delay: 390ms; }
.stagger-in > *:nth-child(n+7) { animation-delay: 460ms; }
@keyframes ps-rise { to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .stagger-in > * { opacity: 1; transform: none; }
}

/* ---------- FAQ ---------- */
.faq details {
  border-bottom: 1px solid var(--line);
  padding-block: var(--space-4);
}
.faq summary {
  font-weight: 600; cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; color: var(--terra); font-size: 1.3em; font-weight: 400;
  transition: transform var(--t-med) var(--ease-out); flex: none;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details p { color: var(--ink-soft); margin-top: var(--space-3); max-width: 62ch; }

/* ---------- UTILITIES ---------- */
.muted { color: var(--ink-faint); }
.soft { color: var(--ink-soft); }
.small { font-size: var(--fs-small); }
.tiny { font-size: var(--fs-tiny); }
.accent { color: var(--terra); }
.hidden { display: none !important; }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); } .mt-6 { margin-top: var(--space-6); } .mt-7 { margin-top: var(--space-7); }
.mb-4 { margin-bottom: var(--space-4); } .mb-5 { margin-bottom: var(--space-5); } .mb-6 { margin-bottom: var(--space-6); }
.kicker {
  font-size: var(--fs-tiny); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--sage); display: block; margin-bottom: var(--space-3);
}

/* ---------- homepage hero background (gallery wall) ---------- */
html, body { overflow-x: clip; }
#hero {
  position: relative;
  padding-top: var(--space-8);
  padding-bottom: var(--space-8);
  isolation: isolate;
}
#hero::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  z-index: -1;
  background:
    linear-gradient(180deg,
      rgba(250,247,242,0.93) 0%,
      rgba(250,247,242,0.80) 38%,
      rgba(250,247,242,0.60) 66%,
      rgba(250,247,242,0.74) 100%),
    url("/assets/img/hero_bg.jpg") center 30% / cover no-repeat;
}
@media (max-width: 640px) {
  #hero::before {
    background:
      linear-gradient(180deg,
        rgba(250,247,242,0.95) 0%,
        rgba(250,247,242,0.86) 42%,
        rgba(250,247,242,0.70) 100%),
      url("/assets/img/hero_bg.jpg") center 28% / cover no-repeat;
  }
}

/* ---------- sticky frosted nav ---------- */
header.container {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 100;
}
header.container::before {
  content: "";
  position: absolute;
  inset: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  z-index: -1;
  background: rgba(250, 247, 242, 0.82);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
header.container .nav { padding-block: var(--space-4); }
