/* OHT's themes (OHT-212): a few looks to try, each a set of OHT's own colour names.

   Menu > Theme (app.js, theme.js) puts data-theme on the page - or on a tile in the picker, to draw
   that tile in its theme. No data-theme is OHT's own look, dark or light with the device, and nothing
   in this file touches it.

   What a theme sets: the surfaces (--bg --panel --panel-2 --line), the inks (--ink --ink-2 --ink-3),
   the accent and the two names drawn from it (--accent-ink: the accent as text and lines; --on-accent:
   text on the accent), a trim, and the muscle colour drawn as the card's own edge rather than a bar
   beside it (OHT-218). What it keeps: the meaning colours - fat, protein, carbs, muscle,
   the body regions, warnings, ticks - OHT's dark ones on a dark theme and its light ones on a light
   one, so a chart reads the same in every theme. Every block names its own accent names: a custom
   property inherits already worked out, so the defaults in app.css would carry the PAGE's accent into
   every tile. The meaning colours as text likewise (--muscle-ink --fat-ink --warn-ink, OHT-217):
   every block names them, OHT's dark ones or its deeper light ones, or a dark theme on a phone
   set to light would take the deep ones meant for white.

   Adding one: a block here, a line in theme.js, its name in THEMES in src/services/profile.js - a
   test holds the three together. The tiers are names in theme.js; nothing is sold yet (OHT-158). */

/* --- Included --------------------------------------------------------------------------------- */

/* OHT's own, for its tile only: the page shows OHT with no data-theme at all. A copy of app.css's
   :root, so the tile can be drawn in it whatever the page is wearing. */
.theme-tile[data-theme="oht"] {
  --bg: #0d1017; --panel: #151a23; --panel-2: #1b2029; --line: #262d3a;
  --ink: #e7ecf3; --ink-2: #9aa5b6; --ink-3: #7d899b;
  --accent: #3373d1; --accent-ink: #5b9dff; --on-accent: #fff;
}
@media (prefers-color-scheme: light) {
  .theme-tile[data-theme="oht"] {
    --bg: #f4f6fa; --panel: #ffffff; --panel-2: #f0f3f8; --line: #dfe4ed;
    --ink: #131722; --ink-2: #5b6577; --ink-3: #656e7f;
    --accent: #2b6fd6; --accent-ink: #2159ad;
  }
}

/* Pastel: light - mint, butter and blush, a soft pink to press and a deeper rose to read. */
[data-theme="pastel"] {
  --bg: #eef7f1; --panel: #ffffff; --panel-2: #fff6dc; --line: #f2d4df;
  --ink: #1f2a24; --ink-2: #55615b; --ink-3: #656e6a;
  --accent: #f4a7c3; --accent-ink: #b8336a; --on-accent: #3a1424;
  --bone: #7d879b; --check: #1f9a5a;
  --muscle-ink: #037e50; --fat-ink: #a05e02; --warn-ink: #b23523;
}

/* --- Colour ----------------------------------------------------------------------------------- */

/* Dark Red: near-black and crimson. The red sits near the warning colour, which stays OHT's. */
[data-theme="dark-red"] {
  --bg: #0f0a0b; --panel: #1a1112; --panel-2: #22181a; --line: #3a2427;
  --ink: #f2e8e8; --ink-2: #c0a5a7; --ink-3: #9a8183;
  --accent: #d0213c; --accent-ink: #ff6b7d; --on-accent: #fff;
  --bone: #8f9bb3; --check: #4fc48b;
  --muscle-ink: #4fc48b; --fat-ink: #f2a65a; --warn-ink: #f2705a;
}

/* Dark Orange: charcoal and orange, with dark text on the orange - white on it does not read. */
[data-theme="dark-orange"] {
  --bg: #0e0c0a; --panel: #1a1613; --panel-2: #221d18; --line: #3a3027;
  --ink: #f3ece4; --ink-2: #c2b3a3; --ink-3: #95887b;
  --accent: #ff7a1a; --accent-ink: #ff9a4d; --on-accent: #1a0d00;
  --bone: #8f9bb3; --check: #4fc48b;
  --muscle-ink: #4fc48b; --fat-ink: #f2a65a; --warn-ink: #f2705a;
}

/* Fluoro: light, with fluoro green to press. Fluoro green cannot be read as text on white, so text,
   lines and rings in it take a deep green (--accent-ink) while the buttons stay fluoro. */
[data-theme="fluoro"] {
  --bg: #f3f7f0; --panel: #ffffff; --panel-2: #ecf5e6; --line: #d3e3c9;
  --ink: #122012; --ink-2: #4a5a48; --ink-3: #616e5f;
  --accent: #39ff14; --accent-ink: #1a7a00; --on-accent: #0b1f05;
  --bone: #7d879b; --check: #1f9a5a;
  --muscle-ink: #037e50; --fat-ink: #a05e02; --warn-ink: #b23523;
}

/* --- Trim ------------------------------------------------------------------------------------- */

[data-theme="gold-trim"], [data-theme="gold-moving"] {
  --bg: #08080a; --panel: #121214; --panel-2: #19191c; --line: #2a2a2e;
  --ink: #f5f1e6; --ink-2: #bdb5a3; --ink-3: #8d8677;
  --accent: #d4af37; --accent-ink: #e6c45c; --on-accent: #1a1405;
  --bone: #8f9bb3; --check: #4fc48b;
  --muscle-ink: #4fc48b; --fat-ink: #f2a65a; --warn-ink: #f2705a;
  --trim-paint: linear-gradient(135deg, #8a6a1f, #f5d77a 28%, #b8892b 52%, #fbe7a1 76%, #8a6a1f);
}

[data-theme="silver-trim"] {
  --bg: #0b0d10; --panel: #15181c; --panel-2: #1c2025; --line: #2c3238;
  --ink: #eef1f4; --ink-2: #aab3bd; --ink-3: #848d96;
  --accent: #c0c7d0; --accent-ink: #d5dbe2; --on-accent: #121417;
  --bone: #8f9bb3; --check: #4fc48b;
  --muscle-ink: #4fc48b; --fat-ink: #f2a65a; --warn-ink: #f2705a;
  --trim-paint: linear-gradient(135deg, #6f7781, #f1f3f6 28%, #9aa3ad 52%, #ffffff 76%, #6f7781);
}

[data-theme="spectrum-trim"], [data-theme="spectrum-moving"] {
  --bg: #0b0b12; --panel: #14141f; --panel-2: #1b1b29; --line: #2a2a3d;
  --ink: #eeeef7; --ink-2: #aaaac2; --ink-3: #87879c;
  --accent: #7c4dff; --accent-ink: #a78bfa; --on-accent: #fff;
  --bone: #8f9bb3; --check: #4fc48b;
  --muscle-ink: #4fc48b; --fat-ink: #f2a65a; --warn-ink: #f2705a;
  --trim-paint: conic-gradient(from 210deg, #ff4d6d, #ffb84d, #f5f55a, #4dff88, #4dc4ff, #9b6bff, #ff4d6d);
}

/* Spectrum's day (OHT-237): light - white panels on a pale violet page, the same violet to press and
   a deeper one to read. The spectrum runs deeper too: the night's yellow and green are pale enough
   to fade into white. */
[data-theme="spectrum-day-trim"], [data-theme="spectrum-day-moving"] {
  --bg: #f4f3fa; --panel: #ffffff; --panel-2: #f1effa; --line: #dedbee;
  --ink: #16141f; --ink-2: #57546a; --ink-3: #66637a;
  --accent: #7c4dff; --accent-ink: #5b2fd6; --on-accent: #fff;
  --bone: #7d879b; --check: #1f9a5a;
  --muscle-ink: #037e50; --fat-ink: #a05e02; --warn-ink: #b23523;
  --trim-paint: conic-gradient(from 210deg, #e11d48, #ea580c, #ca8a04, #16a34a, #0284c7, #7c3aed, #e11d48);
}

/* The trim: the edge of every surface with a plain one - panels, pages, sheets, the menu, the
   session's progress card and its timer, a workout card not yet done or skipped, the cards on the
   exercises, splits and planner pages - repainted in the trim. It is the background's outer ring
   rather than a border colour, so it can be a gradient and keep the rounded corners. It is 2px
   (OHT-218, 2026-10-12 - at 1px it read thin beside the workout cards' 6px muscle edge): the
   surface's own 1px edge made a pixel wider outwards, and a margin of -1px gives that pixel back,
   so what is inside a surface stays where it was and nothing around it moves - the gaps between
   surfaces are a pixel narrower each side. A surface with a margin or a width of its own has them
   adjusted below. Never an edge that says something: a
   finished or skipped card's thick edge, the muscle colour, the timer running, up or nearly done,
   and Edit layout's dashed and dotted edges all keep OHT's colours. The food-add sheet, a full
   screen of its own on a phone, is left alone. A tile in the picker trims its small panel the
   same way.

   The moving themes' rule further down names the same surfaces, word for word: change one, change
   both. */
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"])
  :is(.panel:not(.grid.is-editing .panel), .page__body, .sheet:not(#food-add-sheet) > .sheet__panel,
    .settings__menu, .sess__progress, .rest:not(.is-running, .is-up, .is-final),
    .entry:not(.entry--done, .entry--skipped), .ex-card, .split-card, .goal-plan,
    .plan-form, .plan-summary, .plan-block, .plan-list),
:is(.theme-tile[data-theme="gold-trim"], .theme-tile[data-theme="silver-trim"],
    .theme-tile[data-theme="spectrum-trim"], .theme-tile[data-theme="gold-moving"],
    .theme-tile[data-theme="spectrum-moving"], .theme-tile[data-theme="spectrum-day-trim"],
    .theme-tile[data-theme="spectrum-day-moving"]) > .theme-tile__panel {
  border-color: transparent;
  border-width: 2px;
  margin: var(--trim-margin, -1px);
  background: linear-gradient(var(--panel), var(--panel)) padding-box, var(--trim-paint) border-box;
}
/* A surface with a margin or a width of its own: app.css's values, 1px less a side or 2px more
   across, so the trim's pixel moves nothing there either. Change one in app.css, change it here.
   Not inherited, so a trimmed surface inside one of these still gives back its own pixel. */
@property --trim-margin { syntax: '*'; inherits: false; }
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"]) .goal-plan {
  --trim-margin: 3px -1px 15px;
}
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"]) .split-card {
  --trim-margin: 9px -1px -1px;
}
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"]) .settings__menu {
  width: calc(min(272px, 100vw - 32px) + 2px);
}
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"]) .sheet:not(#food-add-sheet) > .sheet__panel {
  --trim-margin: auto -1px -1px;
  width: calc(100% + 2px);
  max-height: calc(92dvh + 2px);
}
@media (min-width: 640px) {
  :is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
      html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
      html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"]) .sheet:not(#food-add-sheet) > .sheet__panel {
    --trim-margin: auto;
    width: calc(min(560px, 100% - 32px) + 2px);
    max-height: calc(88dvh + 2px);
  }
}
/* The bar along the top, underlined in it - 2px too, the pixel given back below it. */
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"]) .topbar {
  border-image: var(--trim-paint) 1;
  border-bottom-width: 2px;
  margin-bottom: -1px;
}

/* --- Effects: the trim's light goes round ----------------------------------------------------- */

/* Each surface turns its own angle. One inherited from the page would have every element on it
   worked out again on every frame; this way only the trimmed ones are, and only their edge is
   painted again. The run itself is held in a name, --trim-run, like the colours: the one line for
   less motion at the end stops it everywhere, where a rule naming the surfaces again would have to
   outweigh this one to win. */
@property --trim-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes trim-run { to { --trim-angle: 360deg; } }

[data-theme="gold-moving"] {
  --trim-stops: #8a6a1f, #b8892b 60%, #fff3c4 80%, #fff 84%, #fff3c4 88%, #b8892b 96%, #8a6a1f;
  --trim-run: trim-run 6s linear infinite;
}
[data-theme="spectrum-moving"] {
  --trim-stops: #ff4d6d, #ffb84d, #f5f55a, #4dff88, #4dc4ff, #9b6bff, #ff4d6d;
  --trim-run: trim-run 8s linear infinite;
}
[data-theme="spectrum-day-moving"] {
  --trim-stops: #e11d48, #ea580c, #ca8a04, #16a34a, #0284c7, #7c3aed, #e11d48;
  --trim-run: trim-run 8s linear infinite;
}

:is(html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-moving"])
  :is(.panel:not(.grid.is-editing .panel), .page__body, .sheet:not(#food-add-sheet) > .sheet__panel,
    .settings__menu, .sess__progress, .rest:not(.is-running, .is-up, .is-final),
    .entry:not(.entry--done, .entry--skipped), .ex-card, .split-card, .goal-plan,
    .plan-form, .plan-summary, .plan-block, .plan-list),
:is(.theme-tile[data-theme="gold-moving"], .theme-tile[data-theme="spectrum-moving"],
    .theme-tile[data-theme="spectrum-day-moving"]) > .theme-tile__panel {
  background: linear-gradient(var(--panel), var(--panel)) padding-box,
    conic-gradient(from var(--trim-angle), var(--trim-stops)) border-box;
  animation: var(--trim-run);
}
/* A sheet keeps the slide it opens with. */
html:is([data-theme="gold-moving"], [data-theme="spectrum-moving"], [data-theme="spectrum-day-moving"])
  .sheet:not(#food-add-sheet) > .sheet__panel {
  animation: sheet-in .18s ease-out, var(--trim-run);
}
/* Still, for a device that asks for less movement: the trim stays, its light stops. */
@media (prefers-reduced-motion: reduce) {
  [data-theme] { --trim-run: none; }
}

/* --- The muscle colour: the card's own edge (OHT-218) ------------------------------------------ */

/* OHT's own look draws a card's muscle colour as a square-ended bar beside it, whose ends stand
   clear of the card's rounded corners. In a theme it is the card's own left edge: a band inside the
   edge that curves with the corners, on the workout cards and the dashboard's Today's session rows
   alike. 6px (2026-10-12): the weight at which the line matches the corner it curves into - 8px was
   tried and put back the same day. A shadow, not a border, so the padding is OHT's and nothing
   moves, and the trim's ring still goes round the whole card. */
html[data-theme] :is(.entry, .slot).region-edge::before { display: none; }
html[data-theme] :is(.entry, .slot).region-edge { box-shadow: inset 6px 0 0 var(--region, var(--region-other)); }

/* --- The workout log's header (OHT-218) --------------------------------------------------------- */

/* Pinned from the first pixel of scroll, with a strip of the page under it, and the place the next
   exercise glides to: app.css, for every look since OHT-223. In a trim theme the header is a pixel
   wider each side too: the trimmed cards scrolling under it reach a pixel past its own edge, and its
   background has to cover them. */
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"]) .sess__top {
  margin-inline: -1px; padding-inline: 1px;
}
/* A trimmed card's edge reaches a pixel out (the -1px margin above), and the glide lines up the
   edge: taken back here, so it lands where an untrimmed one does and the card before it ends under
   the header, not a pixel below it. */
:is(html[data-theme="gold-trim"], html[data-theme="silver-trim"], html[data-theme="spectrum-trim"],
    html[data-theme="gold-moving"], html[data-theme="spectrum-moving"],
    html[data-theme="spectrum-day-trim"], html[data-theme="spectrum-day-moving"])
  #session-view .sess__body > .entry:not(.entry--done, .entry--skipped) { scroll-margin-top: -1px; }

/* A date's calendar mark and picker in the theme's own dark or light (OHT-229), whatever the device
   is set to: dark, but for the light themes - a new light theme joins this list. */
html[data-theme] input[type=date] { color-scheme: dark; }
html:is([data-theme="pastel"], [data-theme="fluoro"], [data-theme="spectrum-day-trim"],
    [data-theme="spectrum-day-moving"]) input[type=date] { color-scheme: light; }

/* --- The picker: Menu > Theme ------------------------------------------------------------------- */

.theme-intro { margin: 0 0 14px; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.theme-group { margin: 0 0 18px; }
.theme-group__name {
  margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.theme-group__note { margin: -2px 0 8px; color: var(--ink-2); font-size: 12px; line-height: 1.45; }
.theme-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
/* A tile is drawn in its own theme: its data-theme gives it that theme's colours. */
.theme-tile {
  appearance: none; font: inherit; cursor: pointer; text-align: left;
  display: grid; gap: 8px; padding: 10px; border-radius: 12px;
  background: var(--bg); color: var(--ink); border: 1px solid var(--line);
}
.theme-tile:focus-visible, .theme-tile[aria-pressed="true"] { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.theme-tile__panel {
  display: grid; gap: 6px; padding: 10px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line);
}
.theme-tile__line { height: 6px; width: 80%; border-radius: 3px; background: var(--ink-2); }
.theme-tile__line--short { width: 50%; background: var(--ink-3); }
.theme-tile__press { height: 16px; width: 54px; margin-top: 2px; border-radius: 8px; background: var(--accent); }
.theme-tile__name { font-size: 13px; font-weight: 600; }
.theme-tile[aria-pressed="true"] .theme-tile__name::after { content: " · on"; color: var(--accent-ink); font-weight: 500; }
