/* מתמונה לציור. "שולחן האנימטורית": a light table, a cel sheet, one ink line. */

@font-face {
  font-family: 'Suez One';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/suez-one-hebrew-400-normal.woff2) format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Suez One';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/suez-one-latin-400-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: 'Assistant';
  font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(fonts/assistant-hebrew-wght-normal.woff2) format('woff2');
  unicode-range: U+0307-0308, U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Assistant';
  font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(fonts/assistant-latin-wght-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+2000-206F;
}

:root {
  --paper: #F3ECDF;       /* page: warm animation paper */
  --paper-hi: #FBF7EF;    /* raised paper: secondary buttons, style cards */
  --paper-lo: #E9DFCB;    /* sunken paper: notes */
  --ink: #1E1A36;         /* every line and all text */
  --ink-soft: #4B4566;    /* secondary text, 7.6:1 on paper */
  --pencil: #3557A6;      /* animator's blue pencil: stamp, focus ring, 5.8:1 on paper */
  --desk: #2A2433;        /* light table body */
  --glass-mid: #FFF6E2;
  --glass-edge: #F2DFBC;
  --paint: #FF5C8D;       /* the one vivid colour, primary button only. Ink text on it 5.7:1 */
  --paint-hi: #FF7BA3;

  --f-display: 'Suez One', 'Frank Ruhl Libre', Georgia, serif;
  --f-body: 'Assistant', 'Segoe UI', 'Arial Hebrew', Arial, system-ui, sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --r: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
h1, h2, h3, p, ol { margin: 0; }
button, input, label { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ic {
  width: 24px; height: 24px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.ic--sm { width: 18px; height: 18px; }
.ic--lg { width: 30px; height: 30px; }

:focus-visible { outline: 3px solid var(--pencil); outline-offset: 3px; }

/* ---------- frame ---------- */
.app {
  max-width: 1180px;
  margin-inline: auto;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  margin-bottom: 14px;
}
.title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}
.sub { margin-top: 6px; color: var(--ink-soft); font-size: 17px; line-height: 1.4; max-width: 30ch; }

.motion-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 48px; padding: 6px 14px;
  border: 2px solid var(--ink); border-radius: 999px;
  background: transparent;
  font-size: 15px; font-weight: 700; white-space: nowrap;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.motion-btn .ic { width: 18px; height: 18px; }
.motion-btn:active { transform: scale(0.97); }

.motion-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  margin-bottom: 12px; padding: 8px 14px;
  border-radius: 12px; background: var(--paper-lo);
  font-size: 16px;
}
.text-btn {
  min-height: 48px; padding: 0 4px;
  border: 0; background: none; cursor: pointer;
  font-weight: 700; text-decoration: underline; text-underline-offset: 4px;
}

.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.desk, .glass, .controls { min-width: 0; }
.sheet { max-width: 100%; }

/* ---------- the light table ---------- */
.desk {
  background: var(--desk);
  border-radius: 26px;
  padding: 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 18px 30px -22px rgba(30, 26, 54, 0.7);
}
.glass {
  position: relative;
  display: grid; place-items: center;
  min-height: 300px;
  padding: 30px 14px 16px;
  border-radius: 18px;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(ellipse 70% 60% at 50% 46%, #FFFDF7 0%, var(--glass-mid) 55%, var(--glass-edge) 100%);
  box-shadow: inset 0 0 0 1px rgba(42, 36, 51, 0.25), inset 0 3px 14px rgba(42, 36, 51, 0.28);
}
/* the rotating drawing disc set into the glass, with its degree ticks */
.disc {
  position: absolute; z-index: -1;
  top: 50%; left: 50%;
  width: max(118%, 520px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid rgba(42, 36, 51, 0.12);
  background: repeating-conic-gradient(rgba(42, 36, 51, 0.16) 0 0.35deg, transparent 0.35deg 5deg);
  -webkit-mask: radial-gradient(closest-side, transparent 95%, #000 95.4%);
  mask: radial-gradient(closest-side, transparent 95%, #000 95.4%);
}

.empty {
  display: grid; place-items: center; align-content: center; gap: 10px;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
  width: min(100%, 300px); aspect-ratio: 4 / 5;
  border: 2.5px dashed rgba(30, 26, 54, 0.45);
  border-radius: 6px;
  color: var(--ink-soft);
  text-align: center; font-size: 18px; font-weight: 600;
  padding: 16px;
}
.empty:active { transform: scale(0.98); }
.empty__ic { width: 44px; height: 44px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* photo + drawing, stacked. Size is set by app.js and never exceeds the image's natural size. */
.sheet { position: relative; z-index: 1; }
.cmp {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 3px;
  overflow: hidden;
  background: #fff;
  touch-action: pan-y;
  -webkit-user-select: none; user-select: none;
  box-shadow: 0 1px 1px rgba(42, 36, 51, 0.25), 0 12px 24px -12px rgba(42, 36, 51, 0.55);
}
.cmp__layer {
  position: absolute; inset: 0;
  display: block; width: 100%; height: 100%;
  image-rendering: auto;
}
.cmp__anime { clip-path: inset(0 0 0 100%); }

.ink {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 0;
  pointer-events: none;
  will-change: transform;
}
.ink__line {
  position: absolute; top: 0; bottom: 0; left: -1.5px;
  width: 3px;
  background: var(--ink);
  box-shadow: 0 0 0 1px rgba(255, 253, 247, 0.75);
}
.ink__handle {
  position: absolute; top: 50%; left: 0;
  width: 48px; height: 48px;
  margin: -24px 0 0 -24px;
  display: grid; place-items: center;
  padding: 0;
  border: 2.5px solid var(--ink); border-radius: 50%;
  background: var(--paper-hi);
  color: var(--ink);
  cursor: ew-resize;
  touch-action: none;
  pointer-events: auto;
  -webkit-user-select: none; user-select: none;
  box-shadow: 0 3px 10px -2px rgba(30, 26, 54, 0.45);
  transition: opacity 200ms ease, scale 140ms var(--ease-out);
}
.ink__handle .ic { width: 22px; height: 22px; stroke-width: 2.6; }
.ink__handle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--paper-hi), 0 0 0 6px var(--pencil); }
@media (forced-colors: active) {
  .ink__handle:focus-visible { outline: 3px solid CanvasText; outline-offset: 3px; }
}
.is-dragging .ink__handle { scale: 1.08; }
.app:not([data-state="done"]) .ink { display: none; }
.is-sweeping .ink__handle { opacity: 0; pointer-events: none; }

.tag {
  position: absolute; top: 10px; z-index: 2;
  padding: 1px 10px;
  border: 1.5px solid var(--ink); border-radius: 999px;
  background: rgba(251, 247, 239, 0.94);
  font-size: 15px; font-weight: 700; line-height: 1.5;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.tag--start { inset-inline-start: 10px; }
.tag--end { inset-inline-end: 10px; }
.app:not([data-state="done"]) .tag,
.is-sweeping .tag { opacity: 0; }

/* the cel: a clear acetate sheet with the peg bar and a frame number stamp */
.cel {
  position: absolute;
  inset: -24px -8px -8px -8px;
  border-radius: 6px;
  pointer-events: none;
  border: 1px solid rgba(53, 87, 166, 0.38);
  background:
    linear-gradient(to bottom, rgba(53, 87, 166, 0.20) 0 22px, transparent 22px),
    linear-gradient(118deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.22) 46%, rgba(255, 255, 255, 0) 60%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  opacity: 0;
  overflow: hidden;
}
.cel::after {
  content: ''; position: absolute; top: 22px; bottom: 0; left: 0; width: 60%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.26) 50%, rgba(255, 255, 255, 0) 100%);
  transform: translateX(-110%);
  opacity: 0;
}
/* while drawing, light glides across the cel, slowly and calmly: the only sign of life besides the stamp */
.app[data-state="work"]:not(.is-still) .cel::after { opacity: 1; animation: sheen 3.2s ease-in-out infinite; }
@keyframes sheen {
  0% { transform: translateX(185%); }
  70%, 100% { transform: translateX(-110%); }
}
.app[data-state="done"] .cel__stamp { display: none; }
.app[data-state="work"] .cel,
.app[data-state="done"] .cel { opacity: 1; }
.cel__pegs { position: absolute; top: 1px; left: 50%; width: 180px; height: 20px; transform: translateX(-50%); }
.peg { fill: var(--desk); }
.cel__stamp {
  position: absolute; bottom: 10px; inset-inline-end: 10px;
  min-width: 38px; padding: 0 7px;
  border: 1.5px solid var(--pencil); border-radius: 6px;
  background: rgba(255, 253, 247, 0.92);
  color: var(--pencil);
  font-family: var(--f-display); font-size: 20px; line-height: 1.45;
  text-align: center; direction: ltr;
  font-variant-numeric: tabular-nums;
}

/* ---------- controls ---------- */
.controls { display: grid; align-content: start; }
.panel { display: grid; gap: 12px; }
.panel__title { font-family: var(--f-display); font-weight: 400; font-size: 25px; line-height: 1.2; }
.panel__sub { font-size: 17px; font-weight: 700; color: var(--ink-soft); margin-top: 6px; }
.btn-col { display: grid; gap: 12px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60px; padding: 10px 20px;
  border: 2.5px solid var(--ink); border-radius: var(--r);
  background: var(--paper-hi);
  font-size: 21px; font-weight: 700; line-height: 1.2; text-align: center;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease, box-shadow 140ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn--paint { background: var(--paint); box-shadow: 0 4px 0 var(--ink); }
.btn--paint:active { transform: translateY(2px) scale(0.98); box-shadow: 0 2px 0 var(--ink); }
.btn--line { box-shadow: 0 4px 0 rgba(30, 26, 54, 0.22); }
.btn--quiet {
  min-height: 48px; border-color: transparent; background: transparent;
  font-size: 18px; color: var(--ink);
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 5px;
}
.btn--quiet .ic { width: 20px; height: 20px; }
@media (hover: hover) and (pointer: fine) {
  .btn--paint:hover { background: var(--paint-hi); }
  .btn--line:hover { background: #fff; }
  .btn--quiet:hover { background: var(--paper-lo); }
  .motion-btn:hover { background: var(--paper-hi); }
  .style:hover { background: #fff; }
  .style[aria-pressed="true"]:hover { background: var(--ink); }
}

/* file inputs: hidden from the eye, still reachable by keyboard; the label shows focus */
.file-in { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-in:focus-visible + .btn { outline: 3px solid var(--pencil); outline-offset: 3px; }

.note { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-soft); font-size: 16px; line-height: 1.45; }
.note .ic { margin-top: 2px; }
.hint { color: var(--ink-soft); font-size: 18px; margin-top: -4px; }

/* style choice: four cards in a 2x2 grid, the chosen one is filled with ink */
.styles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.style {
  display: grid; justify-items: center; align-content: center; gap: 6px;
  min-height: 112px; padding: 10px 4px;
  border: 2.5px solid var(--ink); border-radius: var(--r);
  background: var(--paper-hi);
  font-size: 17px; font-weight: 700; line-height: 1.2; text-align: center;
  cursor: pointer;
  transition: transform 140ms var(--ease-out), background-color 160ms ease, color 160ms ease;
}
.style:active { transform: scale(0.97); }
.style[aria-pressed="true"] { background: var(--ink); color: var(--paper-hi); }
.style__desc { font-size: 15px; font-weight: 500; color: var(--ink-soft); margin-top: -4px; }
.style[aria-pressed="true"] .style__desc { color: var(--paper-lo); }
.style__swatch {
  display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px solid var(--ink);
  color: var(--ink);
}
.style[aria-pressed="true"] .style__swatch { border-color: var(--paper-hi); }
.style[data-style="anime"] .style__swatch { background: #F9D776; }
.style[data-style="face"] .style__swatch { background: #F7C4B2; }
.style[data-style="hayao"] .style__swatch { background: #B9D39A; }
.style[data-style="shinkai"] .style__swatch { background: #A9D3F5; }
.style__swatch .ic { width: 22px; height: 22px; }

/* waiting: real steps only, no invented percentages */
.steps { list-style: none; padding: 0; display: grid; gap: 10px; }
.step { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); font-size: 19px; }
.step__mark {
  position: relative; flex: none;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2.5px solid currentColor;
}
.step__pct { margin-inline-start: 6px; font-variant-numeric: tabular-nums; }
.step.is-current { color: var(--ink); font-weight: 700; }
.step.is-current .step__mark::after {
  content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--ink);
}
.step.is-current .step__mark::before {
  content: ''; position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid var(--ink); opacity: 0;
  animation: breathe 2.4s ease-in-out infinite;
}
.step.is-done { color: var(--ink); }
.step.is-done .step__mark { background: var(--ink); border-color: var(--ink); }
.step.is-done .step__mark::after {
  content: ''; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px;
  border: solid var(--paper-hi); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
@keyframes breathe {
  0% { opacity: 0; transform: scale(0.7); }
  40% { opacity: 0.5; }
  100% { opacity: 0; transform: scale(1.15); }
}
.note--wait { font-size: 17px; }

.panel--error { padding: 16px; border: 2.5px dashed var(--ink); border-radius: 18px; background: var(--paper-hi); }
.err__head { display: flex; align-items: center; gap: 10px; }
.err__text { font-size: 19px; }

/* motion off: nothing loops */
.is-still .step.is-current .step__mark::before { animation: none; opacity: 0; }

/* phones and tablets: once a photo is chosen, the picture gets the room the intro line used */
@media (max-width: 899px) {
  .app:not([data-state="pick"]) .sub { display: none; }
  .app:not([data-state="pick"]) .top { align-items: center; }
}

/* ---------- wider screens ---------- */
@media (min-width: 600px) {
  .title { font-size: 42px; }
  .sub { font-size: 18px; max-width: none; }
  .controls { width: min(100%, 560px); margin-inline: auto; }
  .glass { padding: 34px 22px 22px; }
}
@media (min-width: 900px) {
  .app { padding-top: 28px; }
  .top { margin-bottom: 22px; }
  .title { font-size: 52px; }
  .layout { grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
  .desk { position: sticky; top: 16px; padding: 14px; border-radius: 30px; }
  .glass { min-height: 520px; padding: 40px 28px 28px; }
  .empty { width: min(100%, 380px); }
  .controls { width: auto; margin: 0; padding-top: 8px; }
}
