/* PAT-1067: the toy in the game's design system. Every colour, radius, size and weight is a token from Assets/Ui/Design/tokens.json, set on
   :root by design.js under the token's own name; the rules below follow the game's theme (Core/Presentation/HudThemeSpec.cs): slate
   panels at 93 % with an ivory rim, 14 px corners and corner brackets (G1), the secondary button's ivory wash under a fine rule, the
   primary's petrol under a 2 px ink rule with its 2 px press drop, fields on the well ground, style C's slider (a 4 px cream bar filling
   terracotta, the wheel-window thumb). Ochre stays scarce (owner, 2026-11-28): the rare bracket's cross only. */

@font-face { font-family: "Alegreya"; src: url("fonts/Alegreya.ttf") format("truetype"); font-weight: 400 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Alegreya"; src: url("fonts/Alegreya-Italic.ttf") format("truetype"); font-weight: 400 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Alegreya Sans"; src: url("fonts/AlegreyaSans-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }

:root {
  --display: "Alegreya", Georgia, "Times New Roman", serif;
  --ui: "Alegreya Sans", "Alegreya", system-ui, sans-serif;
  /* The main menu's night sky (World/Ui/Chrome.cs CrestBlue, CrestDeep, Night: the game's own values, not tokens), the page's ground. */
  --sky-crest: #2f3d63; --sky-deep: #1b2340; --sky-night: #111731;
}
/* Until the tokens are on, nothing shows (design.js sets data-tokens; main.js shows the page anyway if they fail). */
html:not([data-tokens]) body { visibility: hidden; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--sky-night); }
body {
  margin: 0; min-height: 100vh; color: var(--text-on-ground); background: transparent;
  font: var(--weight-body) var(--text-md)/1.45 var(--ui); -webkit-font-smoothing: antialiased;
}
a { color: var(--text-link); text-underline-offset: 2px; }

/* --- The sky: the commissioned panorama at dusk behind the page, blurred and darkened toward the top so the ivory logo reads over it
   (owner, 2026-12-03, of a ComfyUI look preview: "The backdrop one looks the best"). The dusk is CSS on the painting, not a generated image:
   a blue multiply, a darker head and foot, and a warm glow low on the horizon. Over the main menu's night colours, which show while it loads. */
.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(ellipse 120% 80% at 50% 30%, var(--sky-crest) 0%, var(--sky-deep) 55%, var(--sky-night) 100%); }
.sky::before {
  content: ""; position: absolute; inset: -24px; filter: blur(4px) saturate(.8);
  background: linear-gradient(#8a96c4, #a3a2bd 45%, #6c78aa), url("art/panorama.webp") center 28% / cover no-repeat; background-blend-mode: multiply;
}
.sky::after {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 12% at 74% 25%, rgba(232, 160, 96, .42), transparent 72%),
    linear-gradient(to bottom, rgba(17, 23, 49, .82) 0%, rgba(27, 35, 64, .45) 22%, rgba(27, 35, 64, .22) 42%, rgba(17, 23, 49, .62) 75%, rgba(17, 23, 49, .85) 100%);
}

/* --- The masthead: the half-window logo in ivory (the main menu's title; no tagline, owner 2026-12-02) ---------------------- */
.masthead { display: flex; flex-direction: column; align-items: center; padding: var(--space-7) var(--space-4) var(--space-5); text-align: center; }
.logo { margin: 0; line-height: 0; }
.logo-art {
  display: block; width: min(460px, 72vw); aspect-ratio: 1091 / 417; background: var(--majolica-ivory);
  -webkit-mask: url("brand/patronage_logo_half_window.svg") center / contain no-repeat; mask: url("brand/patronage_logo_half_window.svg") center / contain no-repeat;
}

/* --- The stage: the portrait the hero, the sitting beside it (or under it, narrow). The two are one size side by side: two 400 px
   columns, the sitting as tall as the portrait (owner, 2026-12-02: "decrease the size of the portrait", then "the portrait and controls
   the same size"). ------------------------------------------------------------------------------------------------------------------- */
.stage {
  display: grid; gap: var(--space-5); align-items: stretch; justify-content: center;
  grid-template-columns: repeat(2, minmax(0, 400px)); max-width: 1040px; margin: 0 auto; padding: 0 var(--space-4) var(--space-6);
}
@media (max-width: 899px) { .stage { grid-template-columns: minmax(0, 400px); } }

/* The website: the portrait and its sitting are one card (owner, 2026-12-02), the rare surface round both, the portrait on the left and the
   sitting on the right past a hairline; narrow, the sitting goes under the portrait. dev.html keeps the two cards above. */
.stage:has(.sitting-card) { grid-template-columns: minmax(0, 824px); }
.sitting-card { display: grid; grid-template-columns: minmax(0, 352px) minmax(0, 1fr); gap: 0; padding: var(--space-5); }
.sitting-card .portrait-frame { align-self: start; }
.sitting-card .controls { padding: 6px 0 0 var(--space-5); margin-left: var(--space-5); border-left: 1px solid var(--hairline-ground); }
@media (max-width: 719px) {
  .sitting-card { grid-template-columns: minmax(0, 1fr); }
  .sitting-card .controls { padding: var(--space-5) 0 0; margin: var(--space-5) 0 0; border-left: 0; border-top: 1px solid var(--hairline-ground); }
}

/* The panel: the slate ground at 93 % under a 1 px ivory rim, 14 px corners (`surface-ground`, `surface-rim`, `radius-panel`). */
.panel { position: relative; background: var(--surface-ground); border: 1px solid var(--surface-rim); border-radius: var(--radius-panel); }
.panel .bracket { position: absolute; pointer-events: none; }
.bracket.tl { top: -1px; left: -1px; }
.bracket.tr { top: -1px; right: -1px; transform: scaleX(-1); }
.bracket.bl { bottom: -1px; left: -1px; transform: scaleY(-1); }
.bracket.br { bottom: -1px; right: -1px; transform: scale(-1, -1); }

/* The hero: the rare surface (all four corners, as the main menu's card) holding the portrait in the theme's portrait frame (the well
   under a 2 px soft rule). */
.hero { padding: var(--space-5); }
.portrait-frame { position: relative; margin: 0; padding: 2px; background: var(--well-ground); border: 2px solid var(--rule-soft); border-radius: 2px; }
.portrait-frame canvas { display: block; width: 100%; height: auto; aspect-ratio: 448 / 560; background: var(--well-ground); }
.busy {
  position: absolute; inset: 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  background: var(--scrim); color: var(--text-on-ground); font-size: var(--text-sm); opacity: 0; transition: opacity .2s; pointer-events: none;
}
.busy img { width: 26px; height: 26px; animation: turn 2.4s linear infinite; }
@keyframes turn { to { transform: rotate(360deg); } }
.portrait-frame[data-busy] .busy { opacity: 1; }
/* PAT-1067: once a portrait is up it stays seen while the next paints, under a quiet chip instead of the scrim */
.portrait-frame[data-painted] .busy {
  inset: auto auto var(--space-3) 50%; transform: translateX(-50%); flex-direction: row; padding: var(--space-1) var(--space-3) var(--space-1) var(--space-2);
  border-radius: var(--radius-tip); font-size: 13px;
}
.portrait-frame[data-painted] .busy img { width: 18px; height: 18px; }
.caption { text-align: center; padding-top: var(--space-4); }
.sitter { margin: 0; font: var(--weight-title) var(--text-xl)/1.2 var(--display); color: var(--text-on-ground); }
.meta { margin: var(--space-1) 0 0; font-size: 13px; color: var(--text-on-ground-muted); }

/* The sitting: a panel you open (the Standard surface: 24/30/24/24 margins, terracotta brackets at top-left and bottom-right). */
.controls { padding: 30px var(--space-5) var(--space-5); }
.panel-title { margin: 0 0 var(--space-3); font: var(--weight-title) 22px/1.2 var(--display); }
.group { padding: var(--space-3) 0; border-top: 1px solid var(--hairline-ground); display: grid; gap: var(--space-3); }
.caps { margin: 0; font: var(--weight-body) var(--text-xs)/1 var(--ui); letter-spacing: .16em; text-transform: uppercase; color: var(--text-on-ground); }
.field-row { display: flex; gap: var(--space-3); align-items: end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field.grow { flex: 1 1 9em; }
.label { font-size: 13px; color: var(--text-on-ground-muted); display: flex; justify-content: space-between; gap: var(--space-2); }
.label output { color: var(--text-on-ground); font-variant-numeric: tabular-nums; }

/* Fields (LineEdit, OptionButton): the well ground under a fine rule, `radius-control`; focus is the 3 px focus ring. */
input:not([type]), input[type=text], select {
  width: 100%; min-height: 36px; padding: 6px 10px; font: inherit; font-size: var(--text-md); color: var(--text-on-ground);
  background: var(--well-ground); border: 1.5px solid var(--rule-field); border-radius: var(--radius-control);
}
select {
  appearance: none; padding-right: 30px; cursor: pointer;
  background: var(--well-ground) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23f1e6d6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 11px center / 12px 8px no-repeat;
}
select option { background: var(--hud-ground); color: var(--text-on-ground); }
select option:disabled { color: var(--text-on-ground-muted); }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
input:not([type]):focus, select:focus { outline: 3px solid var(--focus-ring); outline-offset: 0; }

/* Style C's slider: a 4 px bar, fully rounded, cream, filling terracotta to the thumb (--fill, set by main.js); the wheel-window thumb. */
.slider { display: grid; gap: 2px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 26px; margin: 0; background: transparent; cursor: pointer; --fill: 50%;
}
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--frame-terracotta) var(--fill), var(--cream-300) var(--fill)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--cream-300); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--frame-terracotta); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -11px; border: 0; background: url("design/pieces/thumb.svg") center / contain no-repeat; }
input[type=range]::-moz-range-thumb { width: 26px; height: 26px; border: 0; background: url("design/pieces/thumb.svg") center / contain no-repeat; }
input[type=range]:hover::-webkit-slider-runnable-track { background: linear-gradient(to right, var(--majolica-terracotta) var(--fill), var(--cream-300) var(--fill)); }
input[type=range]:hover::-webkit-slider-thumb { background-image: url("design/pieces/thumb-hover.svg"); }
input[type=range]:hover::-moz-range-thumb { background-image: url("design/pieces/thumb-hover.svg"); }
input[type=range]:focus-visible { outline: none; }
input[type=range]:focus-visible::-webkit-slider-thumb { border-radius: 50%; box-shadow: 0 0 0 3px var(--focus-ring); }

/* Icon buttons: the ghost button (clear, a hairline wash on hover, a stronger one pressed), icon only, the name in a tooltip
   (owner, 2026-10-22: icons with tooltips). The segmented facing control is a row of them, the chosen one terracotta with an ink glyph
   (the open tile, `tile-open`). */
.icon-btn, .segmented label {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; color: var(--text-on-ground); cursor: pointer;
  background: var(--wash-rest); border: 1.5px solid var(--rule-control); border-radius: var(--radius-control);
}
.icon-btn:hover, .segmented label:hover { background: var(--wash-hover); }
.icon-btn:active { background: var(--wash-press); transform: translateY(2px); }
.icon-btn svg, .segmented svg { width: 20px; height: 20px; fill: currentColor; }
.segmented { display: flex; gap: 0; }
.segmented label { border-radius: 0; margin-left: -1.5px; position: relative; }
.segmented label:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); margin-left: 0; }
.segmented label:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented label:has(input:checked) { background: var(--tile-open); color: var(--ink); border-color: var(--ink); z-index: 1; }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--focus-ring); outline-offset: 2px; z-index: 2; }

/* The tooltip: the dark ground, `radius-tip`, its shadow; shown on hover and keyboard focus. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 600;
  padding: 6px 10px; white-space: nowrap; font: var(--weight-body) var(--text-sm)/1.2 var(--ui); color: var(--text-on-ground);
  background: var(--surface-ground); border: 1px solid var(--surface-rim); border-radius: var(--radius-tip); box-shadow: var(--shadow-tooltip);
  opacity: 0; pointer-events: none; transition: opacity .12s .25s;
}
[data-tip]:hover::after, [data-tip]:focus-visible::after, [data-tip]:has(:focus-visible)::after { opacity: 1; }
@media (hover: none) { [data-tip]::after { display: none; } }

/* The primary button: petrol under a 2 px ink rule, ivory text; hover and press deepen, the press drops 2 px; disabled is clear under a
   faint ivory rule. */
.btn-primary {
  min-height: 40px; padding: 9px 22px; font: var(--weight-body) var(--text-md)/1 var(--ui); color: var(--majolica-ivory); cursor: pointer;
  background: var(--color-primary); border: 2px solid var(--ink); border-radius: var(--radius-control);
}
.btn-primary:hover { background: var(--btn-primary-hover); }
.btn-primary:active { background: var(--btn-primary-press); transform: translateY(2px); }
.btn-primary:disabled { background: transparent; border-color: color-mix(in srgb, var(--majolica-ivory) 12%, transparent); color: var(--text-on-ground-muted); cursor: progress; transform: none; }
.foot { display: flex; gap: var(--space-3); align-items: end; justify-content: space-between; padding-top: var(--space-4); border-top: 1px solid var(--hairline-ground); }
.foot .field { flex: 0 1 10em; }
.status { margin: var(--space-3) 0 0; min-height: 2.6em; font-size: var(--text-xs); color: var(--text-on-ground-muted); font-variant-numeric: tabular-nums; }

/* --- The website's sitting (owner, 2026-12-02): a name, a man or a woman, an age; dev.html keeps the full sitting above ------------- */
.controls:has(.lede) { display: flex; flex-direction: column; gap: var(--space-4); }
.controls:has(.lede) .panel-title { margin: 0; }
/* Paint sits at the card's foot, level with the portrait's, the status (loading, painting, a failure; no timings) beside it */
.controls:has(.lede) .foot { align-items: center; margin-top: auto; }
.controls:has(.lede) .status { margin: 0; min-height: 0; }
.lede { margin: calc(-1 * var(--space-2)) 0 0; font-size: var(--text-sm); color: var(--text-on-ground-muted); }
.segmented.words label { width: auto; padding: 0 var(--space-4); font-size: var(--text-md); }

/* --- The colophon ------------------------------------------------------------------------------------------------------------------ */
.colophon { max-width: 720px; margin: 0 auto; padding: 0 var(--space-4) var(--space-7); text-align: center; color: var(--text-on-ground-muted); font-size: var(--text-sm); }
.colophon p { margin: 0 0 var(--space-2); }
.colophon .credits { font-size: var(--text-xs); }

/* Narrow (phone) widths: a 16 px gutter, a smaller masthead, the hero's padding trimmed. */
@media (max-width: 599px) {
  .masthead { padding: var(--space-6) var(--space-4) var(--space-4); }
  .stage { padding: 0 var(--space-4) var(--space-5); gap: var(--space-4); }
  .hero { padding: var(--space-4); }
  .controls { padding: 26px var(--space-4) var(--space-4); }
}
