/* FaxFace web demo — layout & look
   Stage is designed at 1600×1000 and scaled to fit the window (see js/app.js). */

@font-face {
  font-family: "EASyText";
  src: url("../assets/fonts/EASyText.ttf") format("truetype");
  font-display: block;
}

:root {
  --bg: #d8d8dd;            /* matches the render backdrop */
  --ink: #141414;
  --ink-soft: #6b6b70;
  --paper: #f3f0e8;         /* thermal paper */
  --lime: #8aa61c;
  --lime-soft: #c8cf6a;
  --titanium: #8a827d;
  --pixel: "EASyText", ui-monospace, monospace;
  --sys: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sys);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- Stage & scaling ----------
   Designed at 1600px wide and scaled to the window width. The page scrolls vertically. */
:root { --stage-h: 1110px; }
.viewport {
  position: relative;
  width: 100%;
  height: calc(var(--stage-h) * var(--scale, 1));
  overflow: hidden;
  background: var(--bg);
}
.stage {
  position: absolute; left: 50%; top: 0;
  width: 1600px; height: var(--stage-h);
  transform-origin: top center;
  transform: translateX(-50%) scale(var(--scale, 1));
}

/* ---------- Header ---------- */
.top { position: absolute; inset: 0 0 auto 0; height: 120px; }
.logo {
  position: absolute; left: 50%; top: 32px;
  height: 86px; transform: translateX(-50%);
  z-index: 2;
  image-rendering: pixelated;
  user-select: none;
}
.about-btn {
  position: absolute; right: 32px; top: 46px; z-index: 2;
  font: 500 14px/1 var(--sys); letter-spacing: .02em;
  color: var(--ink); text-decoration: none;
  padding: 10px 16px; border-radius: 999px;
  background: rgba(255, 255, 255, .45);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: background .2s var(--ease);
}
.about-btn:hover { background: rgba(255, 255, 255, .8); }

/* ---------- Machines ---------- */
.machines {
  position: absolute; left: 0; right: 0; top: 150px;
  display: flex; justify-content: center; gap: 40px;
}
.machine {
  position: relative; margin: 0;
  width: 640px;                       /* 1023×1439 render → 640×900 */
  height: 900px;
}
.machine__frame {
  position: absolute; left: 0; top: 0; width: 100%;
  aspect-ratio: 1470 / 2069;
}
.machine__body {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  user-select: none; pointer-events: none;
}

/* Overlay coordinates are % of the render (1023×1439). */
.screen {
  position: absolute;
  left: 35.68%; top: 14.59%;          /* centre 510,356 · r 145 */
  width: 28.35%; aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: var(--paper);
  isolation: isolate;
  container-type: size;
  box-shadow:
    inset 0 0 0 1.5px rgba(0, 0, 0, .55),
    inset 0 5px 12px rgba(0, 0, 0, .28);
}
/* glass highlight */
.screen::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: linear-gradient(150deg, rgba(255,255,255,.35) 0%, rgba(255,255,255,0) 38%),
              radial-gradient(100% 100% at 50% 50%, transparent 62%, rgba(0,0,0,.14) 100%);
  pointer-events: none; z-index: 5;
}
/* dimmed (friend idle) */
.screen::before {
  content: ""; position: absolute; inset: 0; z-index: 4;
  background: #1b1b1d; opacity: 0;
  transition: opacity .8s var(--ease);
  pointer-events: none;
}
.screen--dim::before { opacity: .62; }

.screen__layer {
  position: absolute; inset: 0;
  display: grid; place-items: center; text-align: center;
  visibility: hidden;                 /* swaps are instant; the dither dissolve hides the cut */
}
.screen__layer.is-active { visibility: visible; }

/* accent tick at 12 o'clock on paper screens */
.screen__layer.is-paper::before {
  content: ""; position: absolute; left: 50%; top: 3.6cqw;
  width: 8.8cqw; height: 2.2cqw; margin-left: -4.4cqw; border-radius: 1.1cqw;
  background: var(--accent);
}
.machine--lime { --accent: var(--lime); }
.machine--titanium { --accent: var(--titanium); }

.clock { color: var(--ink); }
.clock__time {
  font: 600 24.8cqw/1 var(--sys);
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.clock__date {
  margin-top: 3.6cqw;
  font: 500 6.2cqw/1 var(--sys); letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft);
}
.clock__cta {
  margin-top: 8.8cqw;
  font: 6.6cqw/1 var(--pixel); letter-spacing: .04em;
  color: var(--ink);
  animation: breathe 2.4s var(--ease) infinite;
}
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ---------- Screen views ----------
   Same structure as the prototype's round-screen UI (machine/faxface/screen.py),
   in the thermal-paper palette: badge · title · subtitle · "turn · press",
   and a rim ring whose segment follows the knob. Sizes in cqw (screen = 100). */
.screen__dissolve {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; z-index: 3; pointer-events: none;
}
.feed {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated; background: var(--paper);
}

/* rim ring */
.ring { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; }
.ring circle { fill: none; }
.ring__track { stroke: rgba(20, 20, 20, .16); stroke-width: .55; }
.ring__seg, .ring__prog { stroke: var(--ink); stroke-width: 1.25; stroke-linecap: round; }
.ring__seg { stroke-dasharray: 0 360; transition: stroke-dashoffset .16s var(--ease), stroke-dasharray .16s var(--ease); }
.ring__prog { stroke-dasharray: 0 360; }
.ring__tick { stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; }
.ring.no-track .ring__track { display: none; }

/* knob menu */
.menu__badge {
  position: absolute; left: 0; right: 0; top: 25cqw;
  font: 5.2cqw/1 var(--pixel); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft);
}
.menu__body { display: grid; justify-items: center; gap: 2.6cqw; padding: 0 12cqw; margin-top: -1cqw; }
.menu__title {
  font: 600 11.5cqw/1.08 var(--sys); letter-spacing: -.02em; color: var(--ink);
  text-wrap: balance;
}
.menu__title.is-long { font-size: 9.6cqw; }
.menu__sub { font: 500 6.2cqw/1.25 var(--sys); color: var(--ink-soft); white-space: pre-line; }
.menu__sub:empty { display: none; }
.menu__hint {
  position: absolute; left: 0; right: 0; bottom: 15.5cqw;
  font: 500 5.4cqw/1 var(--sys); color: var(--ink-soft); letter-spacing: .02em;
}

/* picture screens: caption band across the lower chord */
.band {
  position: absolute; left: 0; right: 0; top: 71cqw; height: 13.5cqw;
  display: flex; align-items: center; justify-content: center; gap: 4cqw;
  background: var(--ink); color: var(--paper);
  font: 600 6.4cqw/1 var(--sys); letter-spacing: .01em;
}
.band i { font-style: normal; font-weight: 400; opacity: .55; font-size: 8cqw; margin-top: -.6cqw; }
.band--choose span { min-width: 30cqw; text-align: center; }

/* countdown */
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 700 38cqw/1 var(--sys); color: var(--ink);
  text-shadow: 1cqw 0 var(--paper), -1cqw 0 var(--paper), 0 1cqw var(--paper), 0 -1cqw var(--paper),
               .7cqw .7cqw var(--paper), -.7cqw -.7cqw var(--paper), .7cqw -.7cqw var(--paper), -.7cqw .7cqw var(--paper);
  opacity: 0; transition: opacity .12s;
}
.countdown.is-on { opacity: 1; }
.camera--counting .band { display: none; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.is-on { animation: flash .45s ease-out; }
@keyframes flash { from { opacity: .95; } to { opacity: 0; } }

/* notice (sent, printing, about) */
.msg { display: grid; justify-items: center; gap: 2.4cqw; padding: 0 12cqw; }
.msg__badge { position: static; }
.msg__badge:empty { display: none; }
.msg__icon { width: 12cqw; height: 12cqw; fill: none; stroke: var(--ink); stroke-width: 2.2;
  stroke-linecap: round; stroke-linejoin: round; }
.msg__icon[hidden] { display: none; }

/* sending: photo feeds out line by line while the ring fills */
.screen { --send-ms: 2400ms; }
.feed--sending { transform: translateY(0); }
.is-running .feed--sending { animation: feed-out var(--send-ms) steps(48, end) forwards; }
@keyframes feed-out { to { transform: translateY(-100%); } }
.pill {
  position: absolute; left: 50%; bottom: 15cqw; transform: translateX(-50%);
  font: 600 6cqw/1 var(--sys); padding: 2.6cqw 4.6cqw; border-radius: 999px;
  background: var(--ink); color: var(--paper); white-space: nowrap;
}
.ellipsis::after { content: ""; display: inline-block; width: 1.2em; text-align: left;
  animation: ellipsis 1.2s steps(4, end) infinite; }
@keyframes ellipsis { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75%, 100% { content: "..."; } }

/* Knob */
.knob {
  position: absolute;
  left: 43.30%; top: 37.25%;          /* centre 507,600 · sprite 128px */
  width: 12.51%; aspect-ratio: 1;
  padding: 0; margin: 0; border: 0; background: none;
  border-radius: 50%;
  transition: transform .14s var(--ease);
}
.knob img { display: block; width: 100%; height: 100%; user-select: none; }
img.knob { display: block; user-select: none; }
img.knob { pointer-events: none; }
.knob--live { cursor: pointer; }
.knob--live img { transform: rotate(var(--knob-angle, 0deg)); transition: transform .12s var(--ease); }
.knob--live:focus-visible { outline: 2px solid var(--lime); outline-offset: 4px; }
.knob.is-pressed { transform: scale(.95); }

/* Paper slot (receipt anchor) */
.slot {
  position: absolute;
  left: 32.16%; width: 36.27%;
  top: 82.42%;                        /* 1186 / 1439 */
  height: 0;
}

/* Name label — plain text just above each machine */
.plate {
  position: absolute; left: 50%; top: 2px;
  transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 10px;
  white-space: nowrap;
  z-index: 2;
}
.plate__label {
  font: 12px/1 var(--pixel); letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft);
}
.plate__input {
  font: 500 17px/1.3 var(--sys); color: var(--ink);
  border: 0; padding: 0; margin: 0; background: transparent;
  outline: none;
  field-sizing: content; min-width: 4ch; max-width: 20ch;
  border-bottom: 1px dashed transparent;
  transition: border-color .2s;
  cursor: text;
}
.plate:hover .plate__input { border-bottom-color: rgba(0,0,0,.3); }
.plate__input:focus { border-bottom-color: var(--accent); }

/* Hints */
.hints {
  position: absolute; left: 50%; top: 814px;
  transform: translateX(-50%);
  display: flex; gap: 18px; white-space: nowrap;
  font: 14px/1 var(--sys); color: var(--ink-soft);
}
.hint { display: inline-flex; align-items: center; gap: 6px; }
.hints.is-swapping { animation: hints-in .25s var(--ease); }
@keyframes hints-in { from { opacity: 0; transform: translate(-50%, 3px); } to { opacity: 1; transform: translate(-50%, 0); } }
kbd {
  display: inline-grid; place-items: center;
  min-width: 24px; height: 24px; padding: 0 6px;
  font: 500 12px/1 var(--sys); color: var(--ink);
  background: linear-gradient(#fbfbfc, #ececf0);
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.10), 0 2px 0 rgba(0,0,0,.12);
}
kbd + kbd { margin-left: -2px; }
.kbd--wide { min-width: 52px; }

/* Footer */
.foot {
  position: absolute; left: 0; right: 0; bottom: 18px;
  text-align: center;
  font: 12px/1 var(--sys); color: #8b8b91; letter-spacing: .01em;
}

/* ---------- Phones & tablets ---------- */
.mobile { display: none; }

@media (hover: none) and (pointer: coarse), (max-width: 760px) {
  body { overflow: auto; }
  .viewport { display: none; }
  .mobile {
    display: flex; flex-direction: column; align-items: center;
    min-height: 100%; padding: 48px 24px 40px; text-align: center;
    background: var(--bg);
  }
  .mobile__logo { height: 44px; image-rendering: pixelated; }
  .mobile__hero { display: flex; justify-content: center; margin: 28px 0 12px; max-width: 520px; }
  .mobile__hero img { width: 50%; height: auto; margin: 0 -4%; }
  .mobile__msg { font: 16px/1.5 var(--sys); color: var(--ink); margin: 8px 0 20px; }
  .mobile__msg strong { font: 15px/1 var(--pixel); letter-spacing: .03em; }
  .mobile__about { font: 14px/1 var(--sys); color: var(--ink-soft); }
}

/* ---------- Friend's machine: busy spinner + glow orbiting the shell ---------- */
.ring--spin { opacity: 0; transition: opacity .4s; }
.ring--spin .ring__seg { stroke-dasharray: 46 314; transition: none; }
.screen.is-busy .ring--spin { opacity: 1; animation: spin 1.3s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@property --glow-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.glow {
  position: absolute; left: 10.4%; right: 10.4%; top: 3.5%; bottom: 10.8%;
  border-radius: 19% / 13.5%;
  filter: blur(4px) drop-shadow(0 0 6px rgba(255, 255, 255, .9));
  opacity: 0; transition: opacity .9s var(--ease);
  pointer-events: none;
}
.glow i {
  position: absolute; inset: -2px; border-radius: inherit; padding: 7px;
  background: conic-gradient(from var(--glow-a),
    transparent 0deg 200deg, rgba(255, 255, 255, .55) 270deg, #fff 318deg, rgba(255, 255, 255, .6) 334deg, transparent 352deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.glow.is-on { opacity: 1; }
.glow.is-on i { animation: orbit 2.4s linear infinite; }
@keyframes orbit { to { --glow-a: 360deg; } }

/* ---------- Receipt hanging from a slot ---------- */
.receipt {
  position: absolute; left: 32.16%; width: 36.27%; top: 82.42%;
  clip-path: inset(0 -80px -140px -80px);   /* paper above the slot line stays inside the machine */
  pointer-events: none;
}
.receipt__feed { height: 100%; transform: translateY(-100%); }
.receipt.is-printing .receipt__feed { animation: feed var(--print-ms) steps(var(--print-steps), end) forwards; }
.receipt.is-done .receipt__feed { transform: none; }
@keyframes feed { from { transform: translateY(-100%); } to { transform: translateY(0); } }

.receipt__sway {
  position: relative; display: block; width: 100%; height: 100%;
  padding: 0; margin: 0; border: 0; background: none;
  transform-origin: 50% 0;
  filter: drop-shadow(0 6px 7px rgba(0, 0, 0, .16));
  pointer-events: auto; cursor: default;
  transition: filter .25s var(--ease);
}
.receipt.is-done .receipt__sway { cursor: zoom-in; animation: sway 3.4s cubic-bezier(.3, .6, .3, 1) both; }
.receipt.is-done .receipt__sway:hover { filter: drop-shadow(0 10px 12px rgba(0, 0, 0, .22)); }
.receipt__sway:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; }
@keyframes sway {
  0% { transform: rotate(0); }
  16% { transform: rotate(1.5deg); }
  38% { transform: rotate(-1deg); }
  60% { transform: rotate(.55deg); }
  80% { transform: rotate(-.2deg); }
  100% { transform: rotate(0); }
}
.receipt__body, .receipt__curl {
  position: absolute; left: 0; width: 100%;
  background-size: 100% auto; background-repeat: no-repeat;
}
.receipt__body { top: 0; height: 88.3%; background-position: center top; }
.receipt__curl {
  top: 88%; height: 12%; background-position: center bottom;
  transform-origin: 50% 0;
  transition: transform 1.6s var(--ease);
}
.receipt__curl::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .1) 70%, rgba(255, 255, 255, .2));
  opacity: 0; transition: opacity 1.6s var(--ease);
}
.receipt.is-done .receipt__curl { transform: perspective(360px) rotateX(30deg); }
.receipt.is-done .receipt__curl::after { opacity: 1; }
.receipt.is-leaving { animation: tear .5s var(--ease) forwards; }
@keyframes tear { to { opacity: 0; transform: translateY(26px); } }

/* hints move below a receipt hanging from the visitor's machine */
.machine--lime.has-receipt .hints { top: calc(741.8px + var(--receipt-h) + 28px); }

/* ---------- Large view ---------- */
.viewer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.viewer[hidden] { display: none; }
.viewer__backdrop {
  position: absolute; inset: 0;
  background: rgba(28, 28, 32, .42);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .22s var(--ease);
}
.viewer.is-open .viewer__backdrop { opacity: 1; }
.viewer__panel {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 18px;
  opacity: 0; transform: translateY(14px) scale(.98);
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.viewer.is-open .viewer__panel { opacity: 1; transform: none; }
.viewer__sheet {
  display: block; height: min(80vh, 1120px); width: auto; max-width: 92vw;
  background: var(--paper);
  box-shadow: 0 26px 60px -14px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .12);
}
.viewer__actions { display: flex; gap: 10px; }
.btn {
  font: 500 14px/1 var(--sys); letter-spacing: .01em;
  padding: 12px 18px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .88); color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: background .15s;
}
.btn:hover { background: #fff; }
.btn--primary { background: var(--ink); color: var(--paper); box-shadow: none; }
.btn--primary:hover { background: #000; }
.btn:focus-visible, .viewer__close:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
.viewer__close {
  position: fixed; top: 18px; right: 22px; width: 40px; height: 40px; border-radius: 50%;
  border: 0; cursor: pointer; background: rgba(255, 255, 255, .88); color: var(--ink);
  font: 300 26px/1 var(--sys);
  opacity: 0; transition: opacity .22s var(--ease);
}
.viewer.is-open .viewer__close { opacity: 1; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .clock__cta, .ellipsis::after, .glow.is-on i, .screen.is-busy .ring--spin { animation: none; }
  .receipt.is-done .receipt__sway { animation: none; }
  .receipt__curl, .viewer__panel, .viewer__backdrop, .knob--live img { transition: none; }
  .is-running .feed--sending { animation-timing-function: linear; }
}
