/* ===========================================================================
 * The Scoren mark and name — ONE sheet draws them everywhere
 * (Preyash, 2026-09-26; docs/design/visual-identity.md "The mark").
 *
 * The till loads it from here; the office's door pages load ../lane/ui/mark.css
 * and the office rail reaches it through shell.css. Every page that shows the
 * mark draws it from this file, so a future screen gets the same ring, the same
 * states and the same motion by writing the markup below and nothing else.
 *
 * ITS CLASSES ARE mark-*, NOT scoren-*: scoren-* names a shared CONTROL,
 * drawn by controls.css and primitives.css, and rule 15 (check-rules.mjs)
 * holds every page to placing those, never drawing them. The mark is a
 * picture, drawn here; a page sets only --mark-size on the element around it.
 *
 * THE MARKUP (viewBox 0 0 200 200; the size comes from the page):
 *
 *   <svg class="mark-ring" viewBox="0 0 200 200" aria-hidden="true">
 *     <g class="mark-ring__arcs">
 *       <path class="mark-ring__arc" d="M 45.70 140.92 A 68 68 0 0 1 45.70 59.08"/>
 *       <path class="mark-ring__arc" d="M 59.08 45.70 A 68 68 0 0 1 140.92 45.70"/>
 *       <path class="mark-ring__arc mark-ring__arc--hot" d="M 154.30 59.08 A 68 68 0 0 1 154.30 140.92"/>
 *       <path class="mark-ring__arc" d="M 140.92 154.30 A 68 68 0 0 1 59.08 154.30"/>
 *     </g>
 *     <circle class="mark-ring__whole" cx="100" cy="100" r="68" pathLength="360"/>
 *     <circle class="mark-ring__dot" cx="100" cy="100" r="19"/>
 *   </svg>
 *
 * Four arcs of a ring, gaps between them, the right-hand arc orange, a blue
 * dot in the middle. The other three arcs are the text colour (currentColor):
 * white on a dark screen, ink on a light one.
 *
 * THE STATES — data-state on the <svg>; no data-state is the plain mark:
 *   waiting   the arcs turn, 2.2 s a turn; the dot breathes, 1.6 s
 *   approved  the gaps close into one solid green ring; the dot is green
 *   declined  the whole mark is red and shakes ONCE; the colour holds until
 *             the page takes the state away
 *   offline   grey; the dot breathes slowly, 3 s; nothing turns
 * Colour always tells the state, so under prefers-reduced-motion every motion
 * stops and the states freeze to their colours (the design's "statics").
 * A state is never the only thing a cashier reads: the words beside the ring
 * say it too (visual-identity.md: colour never carries meaning alone).
 * =========================================================================== */

@font-face {
  /* Space Grotesk, SIL Open Font License 1.1 — fonts/OFL.txt. Kept in the
     repo, never fetched: a till sells for hours with no internet. One
     variable file, Latin, weights 300 to 700. */
  font-family: "Space Grotesk";
  src: url("fonts/SpaceGrotesk-Latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* ── the name: SCOREN, capitals, letter-spaced ─────────────────────────────
   Only the brand name uses this face. Every other word on every screen stays
   on IBM Plex (tokens.css). The word is written in capitals in the markup,
   so a screen reader and a copy-paste get SCOREN, as the screen shows. */
.mark-name {
  font-family: "Space Grotesk", var(--font-ui);
  font-weight: 500;
  letter-spacing: .18em;
  /* letter-spacing also adds space after the last letter; take it back so
     the word sits centred and its right edge is where the N ends */
  margin-right: -.18em;
  line-height: 1;
  white-space: nowrap;
}

/* ── the ring ──────────────────────────────────────────────────────────── */
/* Its size is the page's choice, handed over as --mark-size on the element
   around it (a page never sizes the ring itself: it is drawn here). */
.mark-ring {
  display: block;
  flex: none;
  width: var(--mark-size, 24px);
  height: var(--mark-size, 24px);
  overflow: visible;
}
.mark-ring__arcs,
.mark-ring__whole {
  fill: none;
  stroke-width: 22;
}
.mark-ring__arc { stroke: currentColor; }
.mark-ring__arc--hot { stroke: var(--mark-orange); }
/* On a ground that is dark in both themes (the till's start-up screen) the
   orange is the dark theme's, whatever the theme (Preyash, 2026-09-26, B). */
.mark-ring--on-dark .mark-ring__arc--hot { stroke: var(--boot-mark-orange); }
.mark-ring__dot { fill: var(--mark-blue); }
.mark-ring__whole { display: none; stroke: var(--mark-ok); }
/* Turning and breathing happen around the ring's own centre. */
.mark-ring__arcs,
.mark-ring__dot {
  transform-box: view-box;
  transform-origin: 100px 100px;
}

/* waiting — the card reader, the start-up screen, anything loading */
.mark-ring[data-state="waiting"] .mark-ring__arcs {
  animation: scoren-turn 2.2s linear infinite;   /* the shared turn, controls.css */
}
.mark-ring[data-state="waiting"] .mark-ring__dot {
  animation: mark-breathe 1.6s ease-in-out infinite;
}

/* approved — the gaps close: the solid ring draws from the four arcs' shape */
.mark-ring[data-state="approved"] .mark-ring__arcs { display: none; }
.mark-ring[data-state="approved"] .mark-ring__whole {
  display: inline;
  animation: mark-close .45s ease-out both;
}
.mark-ring[data-state="approved"] .mark-ring__dot { fill: var(--mark-ok); }

/* declined — red, one short shake, and the red stays */
.mark-ring[data-state="declined"] .mark-ring__arc,
.mark-ring[data-state="declined"] .mark-ring__arc--hot { stroke: var(--danger); }
.mark-ring[data-state="declined"] .mark-ring__dot { fill: var(--danger); }
.mark-ring[data-state="declined"] {
  animation: mark-shake .5s ease-out 1;
}

/* offline — grey, a slow breath, nothing turns */
.mark-ring[data-state="offline"] .mark-ring__arc,
.mark-ring[data-state="offline"] .mark-ring__arc--hot { stroke: var(--ink-faint); }
.mark-ring[data-state="offline"] .mark-ring__dot {
  fill: var(--ink-faint);
  animation: mark-breathe 3s ease-in-out infinite;
}

@keyframes mark-breathe {
  0%, 100% { transform: scale(.7); }
  50%      { transform: scale(1.25); }
}
/* The whole ring is drawn as four 70° dashes with 20° gaps — exactly the arcs —
   and the gaps shrink to nothing (pathLength 360: one unit is one degree; the
   circle starts at 3 o'clock, so an offset of half a dash centres it there). */
@keyframes mark-close {
  from { stroke-dasharray: 70 20; stroke-dashoffset: 35; }
  to   { stroke-dasharray: 90 0;  stroke-dashoffset: 45; }
}
@keyframes mark-shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-7%); }
  35%      { transform: translateX(7%); }
  55%      { transform: translateX(-5%); }
  75%      { transform: translateX(5%); }
}

/* All motion off, the colours kept. tokens.css shortens every animation to
   1 ms under this setting, but an INFINITE 1 ms turn is a flicker, not a
   stop — so the ring says none, outright. */
@media (prefers-reduced-motion: reduce) {
  .mark-ring,
  .mark-ring * {
    animation: none !important;
  }
}
