/* ============================================================================
   Termina Discs — landing page + the face (the face is also on the home page
   and the watch faces page). The watch hardware (.watch, .watch-case,
   .dial…) and the playground layout (.pg-*) come from ../style.css. This
   file keeps what is Termina's own.
============================================================================ */

/* The theme's roles, set on each face by termina.js. Registered so a theme
   change eases across the face, the glow and the headline. */
@property --tm-accent { syntax: "<color>"; inherits: true; initial-value: #d9442e; }
@property --tm-ink { syntax: "<color>"; inherits: true; initial-value: #f6e7c1; }
@property --tm-sub { syntax: "<color>"; inherits: true; initial-value: #d9a441; }
@property --tm-hub { syntax: "<color>"; inherits: true; initial-value: #d9442e; }
@property --tm-wellc { syntax: "<color>"; inherits: true; initial-value: #051417; }
@property --tm-glow { syntax: "<color>"; inherits: true; initial-value: #d9442e; }

[data-tm-face],
[data-tm-page] {
  transition: --tm-accent var(--dur-slower) var(--ease), --tm-ink var(--dur-slower) var(--ease),
    --tm-sub var(--dur-slower) var(--ease), --tm-hub var(--dur-slower) var(--ease),
    --tm-wellc var(--dur-slower) var(--ease);
}
:where([data-tm-glow], [data-tm-page] .pg-stage) { transition: --tm-glow var(--dur-slower) var(--ease); }
.app-visual[data-tm-glow] { --src-bg: color-mix(in srgb, var(--tm-glow) 55%, #000); }
[data-tm-page] .pg-stage { --pg-glow: var(--tm-glow); }

/* Morphs between the home page card and this page */
.app-visual .watch.tm-watch,
[data-tm-page] .pg-visual .watch { view-transition-name: termina-watch; }
.app-title img.tm-mark,
[data-tm-page] .pg-intro .app-badge img { view-transition-name: termina-mark; }

/* ----------------------------------------------------------------------------
   The face, drawn by termina.js into a 450×450 SVG (the watch's own canvas).
   Colours are the theme's five roles; the ring and plate gradients are set
   on the SVG's own stops.
---------------------------------------------------------------------------- */
.tm-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  font-family: Barlow, var(--font);
  font-weight: 600;
  font-kerning: normal;
}
.tm-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Everything that turns, turns about the dial's centre */
.tm-turn { transform-box: view-box; transform-origin: 225px 225px; }

.tm-sub-fill { fill: var(--tm-sub); }
.tm-accent-fill { fill: var(--tm-accent); }
.tm-ink-fill { fill: var(--tm-ink); }
.tm-well { fill: var(--tm-wellc); }
.tm-faint-stroke { fill: none; stroke: var(--tm-sub); stroke-opacity: 0.353; }
.tm-ray { stroke: var(--tm-accent); stroke-width: 2.5; stroke-linecap: round; }

/* Numerals on the ring and the plate: dim, except the one under the marker */
.tm-num { fill: var(--tm-sub); text-anchor: middle; }
.tm-num.is-lit { fill: var(--tm-ink); }
.tm-five { stroke: var(--tm-sub); stroke-width: 3; stroke-linecap: round; }
.tm-five.is-lit { stroke: var(--tm-ink); }

/* Counter cards: plain cream cards with dark digits */
.tm-card { fill: var(--tm-ink); stroke: #000; stroke-width: 1.5; }
.tm-card-digit { fill: #141414; text-anchor: middle; }

/* Complications */
.tm-arc-text { fill: var(--tm-ink); text-anchor: middle; white-space: pre; }
.tm-arc-end { fill: var(--tm-sub); text-anchor: middle; }
.tm-arc-fill { fill: none; stroke: var(--tm-accent); stroke-width: 6; stroke-linecap: round; }
.tm-value { fill: var(--tm-ink); text-anchor: middle; }
.tm-hub-track,
.tm-hub-fill { fill: none; stroke-width: 6; stroke-linecap: round; }
.tm-hub-track { stroke: var(--tm-sub); stroke-opacity: 0.353; }
.tm-hub-fill { stroke: var(--tm-hub); }

/* Always-on keeps only dark backgrounds: the band, the plate and the wells
   go, the marks and numerals stay. The counter cards go too, and the
   complications follow their setting. */
.tm-face .tm-amb-hide,
.tm-face .tm-slot { transition: opacity 0.4s var(--ease); }
.is-aod .tm-amb-hide { opacity: 0; }
.is-aod.no-cx-aod .tm-slot { opacity: 0; }

/* ----------------------------------------------------------------------------
   Landing page
---------------------------------------------------------------------------- */
/* The headline in the theme's accent into its numerals' colour, with the
   lightness pinned per page theme so it stays readable on a light page. */
[data-tm-page] .pg-intro .hl {
  background: linear-gradient(100deg, light-dark(#b4321f, #e8735f), light-dark(#8a6416, #d9a441));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
@supports (color: oklch(from red l c h)) {
  [data-tm-page] .pg-intro .hl {
    background-image: linear-gradient(100deg,
      light-dark(oklch(from var(--tm-accent) 0.52 max(c, 0.03) h), oklch(from var(--tm-accent) 0.78 c h)),
      light-dark(oklch(from var(--tm-sub) 0.5 max(c, 0.03) h), oklch(from var(--tm-sub) 0.84 c h)));
  }
}

/* The slider's track: the hour plate steps once an hour, so the notches
   mark every hour; the day goes light in the middle, like the window. */
[data-tm-page] .pg-range {
  --track:
    repeating-linear-gradient(90deg, transparent 0 calc(100% / 24 - 1px), rgb(255 255 255 / 0.18) 0 calc(100% / 24)),
    linear-gradient(90deg, #12161c 22%, color-mix(in srgb, var(--tm-accent) 55%, #12161c) 50%, #12161c 78%);
}

/* Themes: the watch editor's own swatches */
.tm-themes { gap: var(--space-2); }
.pg-chip-face.tm-swatch {
  border: 0;
  overflow: hidden;
  background: #000;
}
.tm-swatch img { display: block; width: 100%; height: 100%; }

/* Seconds: the editor's option previews, with their names */
.tm-picks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.tm-pick { position: relative; display: grid; justify-items: center; align-content: start; gap: var(--space-2); }
.tm-pick input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.tm-pick img {
  width: 100%;
  max-width: 80px;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 1px var(--border-strong);
  transition: box-shadow var(--dur-fast) var(--ease),
    scale var(--press-dur, var(--dur-spring)) var(--press-ease, var(--ease-spring));
}
.tm-pick span {
  color: var(--muted);
  font-size: var(--text-2xs);
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  transition: color var(--dur-fast) var(--ease);
}
.tm-pick:hover span,
.tm-pick input:checked ~ span { color: var(--text); }
.tm-pick input:checked ~ img { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.tm-pick input:focus-visible ~ img { outline: 2px solid var(--accent); outline-offset: 6px; }
.tm-pick input:active ~ img { --press-dur: 0.1s; --press-ease: var(--ease); scale: 0.94; }

/* Straight from the face file: round renders in a rim like the watch's */
.tm-gallery { --gallery-cols: 8; --gallery-cols-md: 4; --gallery-w: 150px; }
.tm-gallery img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #000;
  box-shadow: 0 0 0 6px #17181c, 0 0 0 7px var(--border-strong), 0 18px 36px -18px var(--shadow-color, rgb(0 0 0 / 0.5));
}
