/* Ink It ZM: shared tokens and components.
   The idea: every tattoo starts as a thin purple stencil line and ends as solid ink.
   Stencil (dashed, purple) = still to agree or to do: a choice not made, a price not yet accepted,
   a deposit not yet confirmed. Ink (solid bone or black) = agreed and done.
   Full notes in DESIGN.md. */

@font-face {
  font-family: "Pirata One";
  src: url("../fonts/pirata-one.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: only dark;

  --ink: #000;          /* the canvas: tattoo black */
  --wet: #151413;       /* raised panels, Pililani's messages */
  --wet-2: #1f1d1b;     /* fields, pressed panels */
  --line: #34302c;      /* quiet hairlines */
  --edge: #77706a;      /* borders of things you can tap (3:1 or better) */
  --bone: #efe8dc;      /* text, the main button, the transfer sheet, agreed things */
  --ash: #a8a094;       /* second-level text (8:1 on black) */
  --stencil: #9a8cff;   /* stencil line on black: pending, focus, progress. Never a fill behind text */
  --stencil-soft: rgba(154, 140, 255, 0.14);
  --transfer: #5a4ac8;  /* the same stencil on bone paper (thermal transfer purple) */
  --live: #8be0ae;      /* only for "now" signals: open now, a new reply */
  --wa: #25d366;        /* only inside the WhatsApp glyph */
  --danger: #ff9b8f;

  --font-mark: "Pirata One", "Iowan Old Style", Georgia, serif;
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Older names, still used by the dashboard. */
  --display: var(--font-mark);
  --body: var(--font);

  /* One family, three widths: narrow for headings, normal for reading, a little wide for small notes. */
  --w-head: 76%;
  --w-note: 110%;

  --t-xs: 0.8125rem;   /* 13 */
  --t-s: 0.9375rem;    /* 15 */
  --t-m: 1.0625rem;    /* 17 */
  --t-l: 1.25rem;      /* 20 */
  --t-xl: 1.5rem;      /* 24 */
  --t-2xl: 2.125rem;   /* 34 */
  --t-3xl: 3rem;       /* 48 */
  --step--1: var(--t-s);
  --step-0: var(--t-m);
  --step-1: var(--t-l);
  --step-2: var(--t-xl);
  --step-3: 2rem;
  --step-4: var(--t-2xl);

  --r-s: 6px;
  --r-m: 12px;
  --r-l: 20px;

  /* A real spring for presses and pop-ups (falls back to ease where linear() is missing). */
  --spring: linear(0, 0.009, 0.035 2.1%, 0.141, 0.281 6.7%, 0.723 12.9%, 0.938 16.7%, 1.017, 1.077, 1.121, 1.149 24.3%, 1.159, 1.163, 1.161, 1.154 29.9%, 1.129 32.8%, 1.051 39.6%, 1.017 43.1%, 0.991, 0.977 51%, 0.974 53.8%, 0.975 57.1%, 0.997 69.8%, 1.003 76.9%, 1.004 83.8%, 1);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: 20px;
  --max: 1120px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  /* Keeps focused fields clear of the bars fixed at the bottom of the screen. */
  scroll-padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  scroll-padding-top: 16px;
}
body {
  margin: 0;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font);
  font-size: var(--t-m);
  line-height: 1.6;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--bone); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
/* Links inside sentences: a 44px tall tap area without moving the text. */
p a, .foot-meta a { display: inline-block; padding: 14px 0; margin: -14px 0; }
p { margin: 0 0 1em; max-width: 68ch; }
h1, h2, h3, h4 { margin: 0; line-height: 1.1; font-weight: 650; font-stretch: 92%; text-wrap: balance; }
/* Headings: Archivo, narrow and firm. The gothic letters are kept for the logo and the price sheet. */
.display {
  font-family: var(--font);
  font-weight: 590; font-stretch: var(--w-head);
  font-size: var(--t-2xl); line-height: 1.02; letter-spacing: -0.012em;
}
h3 { font-size: var(--t-l); }
.mark { font-family: var(--font-mark); font-weight: 400; font-synthesis: none; letter-spacing: 0.01em; }
.note { font-size: var(--t-xs); font-stretch: var(--w-note); font-weight: 520; letter-spacing: 0.005em; color: var(--ash); }
small, .small { font-size: var(--t-s); }
.muted { color: var(--ash); }
.num { font-variant-numeric: tabular-nums lining-nums; }
[hidden] { display: none !important; }

.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;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 50;
  background: var(--bone); color: var(--ink);
  padding: 10px 14px; border-radius: var(--r-s); font-weight: 600;
}
.skip:focus { top: 12px; }

/* The stencil focus ring: dashed purple, on everything you can reach by keyboard. */
:focus-visible {
  outline: 2px dashed var(--stencil);
  outline-offset: 3px;
}

.wrap { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 22px;
  border: 1.5px solid transparent; border-radius: var(--r-s);
  font-family: var(--font); font-weight: 640; font-stretch: 88%;
  font-size: var(--t-m); line-height: 1; letter-spacing: 0.01em;
  text-decoration: none; white-space: nowrap;
  transition: transform 0.15s var(--spring), background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* Press feedback: buttons and cards dip to 97%, small round ones to 95%. */
.btn:active { transform: scale(0.97); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn-ink { background: var(--bone); color: var(--ink); }
.btn-ink:hover { background: #fff; }
.btn-line { border-color: var(--bone); color: var(--bone); background: transparent; }
.btn-line:hover { background: rgba(239, 232, 220, 0.08); }
/* WhatsApp stays easy to find (its green glyph) without shouting over the site's own buttons. */
.btn-wa { background: transparent; color: var(--bone); border-color: var(--edge); }
.btn-wa:hover { border-color: var(--bone); }
.btn-wa svg { color: var(--wa); }
.btn-quiet { background: transparent; color: var(--bone); border-color: var(--line); }
.btn-quiet:hover { border-color: var(--edge); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255, 155, 143, 0.55); }
.btn-small { min-height: 44px; padding: 0 16px; font-size: 1rem; }
.btn-block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 1.5px solid var(--line); border-radius: var(--r-s);
  background: transparent; color: var(--bone);
}
.icon-btn:hover { border-color: var(--edge); }
.icon-btn { transition: transform 0.15s var(--spring); -webkit-tap-highlight-color: transparent; }
.icon-btn:active { transform: scale(0.95); }
.icon-btn svg { width: 22px; height: 22px; }
.wa-glyph { color: var(--wa); }

/* ---------- Fields ---------- */
.field { display: grid; gap: 8px; margin: 0 0 22px; }
.field > label, .legend, legend {
  font-weight: 640; font-stretch: 92%; font-size: var(--t-m); color: var(--bone);
}
.hint { color: var(--ash); font-size: var(--t-s); margin: 0; max-width: 60ch; }
.optional { color: var(--ash); font-weight: 400; font-stretch: 100%; }
input[type="text"], input[type="tel"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"], input[type="search"], input[type="url"],
input:not([type]), textarea, select {
  width: 100%; min-height: 52px;
  padding: 12px 14px;
  background: var(--wet-2); color: var(--bone);
  border: 1.5px solid var(--edge); border-radius: var(--r-s);
  font-size: var(--t-m); /* 17px: stops iPhone zooming into the field */
  line-height: 1.4;
  -webkit-appearance: none; appearance: none;
}
input[type="date"], input[type="time"] { min-width: 0; display: block; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
textarea { min-height: 120px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #8a8278; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 2px; }
.field[data-invalid] input, .field[data-invalid] textarea, .field[data-invalid] select { border-color: var(--danger); }
.error { color: var(--danger); font-size: var(--t-s); margin: 0; font-weight: 600; }
fieldset { border: 0; padding: 0; margin: 0 0 26px; min-width: 0; }
legend { padding: 0; margin-bottom: 10px; }

/* Chips: choices drawn as stencil (dashed) until you pick one; then it is inked (solid bone). */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; display: inline-flex; }
.chip input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.chip > span {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 10px 16px;
  border: 1.5px dashed var(--edge); border-radius: var(--r-s);
  color: var(--bone); font-weight: 560; font-stretch: 94%; line-height: 1.2;
}
.chip input:hover + span { border-color: var(--bone); }
.chip > span, .card-choice .card-body { transition: transform 0.15s var(--spring), background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease; }
.chip:active > span, .card-choice:active .card-body { transform: scale(0.97); }
/* The invisible radio stays on top while its face is pressed (a scaled face would cover it). */
.chip input, .card-choice input { z-index: 1; }
.chip input:checked + span { background: var(--bone); color: var(--ink); border-style: solid; border-color: var(--bone); }
.chip input:focus-visible + span { outline: 2px dashed var(--stencil); outline-offset: 3px; }
.chips-big .chip { flex: 1 1 150px; }
.chips-big .chip > span { width: 100%; min-height: 64px; padding: 14px 18px; font-size: 1.125rem; justify-content: flex-start; }

/* Choice cards (size and similar): a title and a line under it. */
.cards { display: grid; gap: 10px; }
.card-choice { position: relative; display: block; }
.card-choice input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.card-choice .card-body {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 14px 16px; min-height: 64px;
  border: 1.5px dashed var(--edge); border-radius: var(--r-m);
}
.card-choice .card-title { font-weight: 640; font-stretch: 92%; font-size: 1.125rem; }
.card-choice .card-note { color: var(--ash); font-size: var(--t-s); grid-column: 1 / -1; }
.card-choice .card-price { font-variant-numeric: tabular-nums; font-weight: 600; }
.card-choice input:checked + .card-body { border-style: solid; border-color: var(--bone); background: var(--bone); color: var(--ink); }
.card-choice input:checked + .card-body .card-note { color: #4a443d; }
.card-choice input:focus-visible + .card-body { outline: 2px dashed var(--stencil); outline-offset: 3px; }

.check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--bone); flex: none; }

/* ---------- Panels, banners, toast ---------- */
.panel { background: var(--wet); border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px; }
.banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px var(--gutter);
  font-size: var(--t-s); line-height: 1.4;
  border-bottom: 1.5px dashed var(--stencil);
  background: #0c0a17; color: var(--bone);
}
.banner strong { font-weight: 700; }
.notice-bar { background: var(--bone); color: var(--ink); border: 0; font-weight: 600; justify-content: center; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0;
  max-width: min(92vw, 440px); padding: 12px 16px;
  background: var(--bone); color: var(--ink); border-radius: var(--r-s);
  font-weight: 600; font-stretch: 94%; line-height: 1.35;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
body.has-tabbar .toast { bottom: calc(88px + var(--safe-b)); }
body.has-actionbar .toast { bottom: calc(92px + var(--safe-b)); }
body.has-composer .toast { bottom: calc(96px + var(--safe-b)); }

/* ---------- Live signals: a small green dot for "now", and the open/closed badge ---------- */
.live-dot {
  position: relative; display: inline-block; flex: none;
  width: 8px; height: 8px; border-radius: 50%; background: var(--live);
}
.live-dot.off { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ash); }
/* After the logo is inked, the dot rings three times and then rests. */
.live-dot.ring::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 1.5px solid var(--live); opacity: 0;
  animation: ring 1.6s ease-out var(--ring-delay, 0.2s) 3;
}
@keyframes ring { 0% { transform: scale(0.5); opacity: 0.9; } 100% { transform: scale(1.7); opacity: 0; } }
.open-status {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0; min-height: 32px; padding: 4px 12px 4px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: var(--t-xs); font-stretch: var(--w-note); font-weight: 560; line-height: 1.2; color: var(--bone);
  white-space: nowrap;
}

/* ---------- Dialogs ---------- */
dialog {
  padding: 0; border: 0; color: var(--bone);
  background: var(--wet);
  max-width: 100vw; max-height: 100dvh;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.78); }
/* Pop-ups grow from 97% and fade in; closing fades out (Ink.closeDialog). Redraws inside never replay this. */
dialog[open] { animation: dialog-in 0.22s var(--ease-out); }
dialog[open]::backdrop { animation: fade-in 0.22s ease; }
dialog.closing { animation: dialog-out 0.15s ease forwards; }
dialog.closing::backdrop { animation: fade-out 0.15s ease forwards; }
@keyframes dialog-in { from { opacity: 0; transform: scale(0.97); } }
@keyframes dialog-out { to { opacity: 0; transform: scale(0.97); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* A refused form shakes once sideways, and still says in words what is wrong. */
.shake { animation: shake 0.36s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  16% { transform: translateX(-10px); }
  33% { transform: translateX(10px); }
  50% { transform: translateX(-6px); }
  66% { transform: translateX(6px); }
  83% { transform: translateX(-3px); }
}

/* ---------- Status chips (stencil to ink) ---------- */
.status {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 3px 10px;
  border-radius: var(--r-s); border: 1.5px dashed var(--stencil);
  font-size: 0.875rem; font-weight: 640; font-stretch: 90%; line-height: 1.1;
  color: var(--bone); white-space: nowrap;
}
.status-new { border-color: var(--stencil); color: #cfc7ff; }
.status-quoted { border-color: var(--bone); }
.status-confirmed { border-style: solid; border-color: var(--bone); background: var(--bone); color: var(--ink); }
.status-done { border-style: solid; border-color: var(--ash); background: var(--ash); color: var(--ink); }
.status-cancelled, .status-no_show { border-style: solid; border-color: var(--line); color: var(--ash); }
.status-question { border-color: var(--edge); color: var(--bone); }

/* ---------- Loading: a stencil line being drawn along the top, and quiet placeholder blocks ---------- */
.loadbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity 0.2s ease; }
.loadbar::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 34%; background: var(--stencil); transform: translateX(-100%); }
.loadbar.on { opacity: 1; }
.loadbar.on::before { animation: loadbar 1.1s cubic-bezier(0.6, 0, 0.4, 1) infinite; }
@keyframes loadbar { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
.skeleton { display: block; border-radius: var(--r-s); background: var(--wet-2); animation: skeleton 1.4s ease-in-out 3 alternate; }
@keyframes skeleton { from { opacity: 1; } to { opacity: 0.55; } }

/* ---------- Motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .loadbar.on::before { width: 100%; transform: none; animation: none !important; opacity: 0.7; }
  .live-dot.ring::after { display: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}

.hint-gap { margin-top: 12px; }
