/* 1zoku.radio text mode: components.
   Built on WebTUI 0.1.10 (box-, is-, size-, variant- attributes) and tokens.css only.
   Every control lives on the 1ch x 1lh grid. No radius, no shadow, no soft gradient.
   State vocabulary, used everywhere:
     cursor (hover, keyboard focus, selected)  = inverse video
     current / playing / done                  = signal green
     LIVE / sold out                           = alarm
     disabled                                  = rule gray + strike
   `.is-focus` / `.is-hover` only exist so kit.html can show those states statically. */

/* ---------- base ---------- */
html, body { word-break: normal; overflow-wrap: anywhere; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeSpeed; }
::selection { background: var(--gray); color: var(--black); }
:focus-visible { outline: 1px solid var(--gray); outline-offset: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
p, li, blockquote { color: var(--foreground0); }
p { max-width: var(--measure); }
.dim { color: var(--gray-dim); }
.rule-c { color: var(--gray-rule); }
.sig { color: var(--signal); }
.alarm { color: var(--alarm); }
strong, b { font-weight: var(--font-weight-bold); color: var(--gray); }

a { color: inherit; text-decoration: underline; text-decoration-color: var(--gray-rule); text-underline-offset: .25em; }
a:not([is-~=button], .row):is(:hover, :focus-visible, .is-focus) { background: var(--gray); color: var(--black); text-decoration: none; outline: none; }

kbd { font: inherit; color: var(--gray); }
kbd::before { content: "["; color: var(--gray-dim); }
kbd::after { content: "]"; color: var(--gray-dim); }

/* ---------- panel: WebTUI box with a title (and optional meta) on the top line ---------- */
[box-] { padding: var(--row) var(--pad); }
[box-] > .pt, [box-] > .ph { position: absolute; top: 0; left: 1ch; z-index: 1; height: 1lh; }
[box-] > .pt { max-width: calc(100% - 2ch); }
/* .ph holds title + meta: the meta keeps its full width, the title yields with an ellipsis */
[box-] > .ph { right: 1ch; display: flex; justify-content: space-between; gap: 2ch; pointer-events: none; }
.ph > * { pointer-events: auto; }
.pt, .pm { padding: 0 1ch; background: var(--background0); color: var(--gray-dim); font-weight: var(--font-weight-normal); white-space: nowrap; }
.pt { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pm { flex: none; }
.pt :is(h1, h2, h3) { display: inline; font-weight: inherit; color: var(--gray); }
[box-][data-on] { --box-border-color: var(--signal); }
[box-][data-on] .pt { color: var(--signal); }
[tabindex="-1"]:focus { outline: none; }

/* ---------- buttons ---------- */
button, [is-~=button] { cursor: pointer; white-space: nowrap; }
:is(button, [is-~=button]):focus { font-weight: inherit; text-decoration: none; }
:is(button, [is-~=button]):is(:focus-visible, .is-focus):not(:disabled) { font-weight: var(--font-weight-bold); }
button:active { --mapped-primary: var(--button-primary); --mapped-secondary: var(--button-secondary); }
button[variant-=signal], [is-~=button][variant-=signal] { --button-primary: var(--signal); --button-secondary: var(--black); }
button:disabled, [is-~=button][aria-disabled=true] { --button-primary: var(--gray-rule); cursor: not-allowed; }

/* large: box-drawn, 3 rows */
button[box-], [is-~=button][box-] { padding: 0 2ch; text-decoration: none; }
button[box-]:is(:hover, :focus-visible, .is-focus):not(:disabled)::before,
[is-~=button][box-]:is(:hover, :focus-visible, .is-focus)::before { background: var(--mapped-primary); }
button[box-]:is(:hover, :focus-visible, .is-focus):not(:disabled),
[is-~=button][box-]:is(:hover, :focus-visible, .is-focus) { color: var(--mapped-secondary); outline: none; background-color: transparent; }
button[box-]:active:not(:disabled)::before { background: var(--signal); }

/* small: one row, bracketed */
button[size-=small], [is-~=button][size-=small] {
  height: auto; min-height: 1lh; padding: 0; background: transparent; color: var(--mapped-primary); text-decoration: none;
}
button[size-=small]::before, [is-~=button][size-=small]::before { content: "["; }
button[size-=small]::after, [is-~=button][size-=small]::after { content: "]"; }
button[size-=small]:is(:hover, :focus-visible, .is-focus):not(:disabled),
[is-~=button][size-=small]:is(:hover, :focus-visible, .is-focus) { background: var(--mapped-primary); color: var(--mapped-secondary); outline: none; }
button[size-=small]:active:not(:disabled) { background: var(--signal); color: var(--black); }
button[size-=small][aria-pressed=true] { color: var(--signal); }

/* ---------- menu / tabs: hotkey links ---------- */
.menu { display: flex; flex-wrap: wrap; gap: 0 2ch; list-style: none; }
.menu li::before { content: none; }
.menu a { display: inline-flex; gap: 1ch; text-decoration: none; padding: 0 1ch; margin: 0 -1ch; }
.menu a[aria-current=page], .menu a[aria-selected=true] { color: var(--signal); }
.menu a[aria-current=page] kbd, .menu a[aria-selected=true] kbd { color: var(--signal); }
/* tabs: [ Newsletter ] with the current tab in inverse */
.tabs a::before { content: "["; color: var(--gray-dim); }
.tabs a::after { content: "]"; color: var(--gray-dim); }
.tabs a[aria-current=page] { background: var(--gray); color: var(--black); }
.tabs a:is([aria-current=page], :hover, :focus-visible)::before, .tabs a:is([aria-current=page], :hover, :focus-visible)::after { color: var(--black); }
.menu a:is(:hover, :focus-visible, .is-focus) kbd, .menu a:is(:hover, :focus-visible, .is-focus) kbd::before,
.menu a:is(:hover, :focus-visible, .is-focus) kbd::after { color: var(--black); }

/* ---------- rows: playlists, catalogs, file lists ---------- */
.rows { list-style: none; }
.rows li::before { content: none; }
.row {
  display: grid; grid-template-columns: 4ch 1fr auto; gap: 0 1ch; width: 100%;
  padding: 0 1ch; text-align: left; text-decoration: none; color: var(--gray);
  /* WebTUI resets for <button class=row> */
  height: auto; min-height: 1lh; background: transparent; font: inherit; line-height: var(--line-height);
}
.row > :last-child { text-align: right; white-space: nowrap; }
.row > :nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .dim { color: var(--gray-dim); }
.row[data-playing] { color: var(--signal); }
.row[data-playing] .dim { color: var(--signal); }
:is(a, button).row { cursor: pointer; }
:is(a, button).row:is(:hover, :focus-visible, .is-focus, [aria-current]) { background: var(--gray); color: var(--black); outline: none; }
:is(a, button).row:is(:hover, :focus-visible, .is-focus, [aria-current]) :is(.dim, .alarm, .dot, .mode, kbd) { color: var(--black); }
:is(a, button).row:is(:hover, :focus-visible, .is-focus, [aria-current]) kbd::before,
:is(a, button).row:is(:hover, :focus-visible, .is-focus, [aria-current]) kbd::after { color: var(--black); }
.row[data-playing]:is(:hover, :focus-visible, .is-focus) { background: var(--signal); color: var(--black); }
.row[data-playing]:is(:hover, :focus-visible, .is-focus) :is(.dim, .dot) { color: var(--black); }
/* cursor is on it but focus is elsewhere: keep a lighter mark */
:is(a, button).row[aria-current]:not(:hover, :focus-visible, .is-focus) { background: transparent; color: var(--signal); }
:is(a, button).row[aria-current]:not(:hover, :focus-visible, .is-focus) :is(.dim, .mode, kbd) { color: var(--signal); }
.row.off, .row[aria-disabled=true] { color: var(--gray-rule); }
.row.off .lead > :first-child { text-decoration: line-through; }
.row.tier > :nth-child(2) { text-align: right; }
.choice:has(.lead) > :last-child { min-width: 12ch; text-align: right; }
.row[data-paused] > :first-child, .row[data-paused] > :last-child { color: var(--signal); }
.row[data-paused] > :last-child::before { content: "paused "; }
.row[data-paused]:is(:hover, :focus-visible, .is-focus) > * { color: var(--black); }

/* ---------- fields: WebTUI input / textarea, drawn in characters ---------- */
/* single line: [ value            ]   no fill; width capped per field with --w */
.field { display: grid; justify-items: start; }
.field > span:first-child { color: var(--gray-dim); }
.in { display: flex; align-items: center; width: min(100%, calc(var(--w, 40ch) + 2ch)); }
.in::before { content: "["; color: var(--gray-rule); }
.in::after { content: "]"; color: var(--gray-rule); }
.in:focus-within::before, .in:focus-within::after { color: var(--gray); }
.in input { flex: 1; min-width: 0; width: auto; height: 1lh; padding: 0 1ch; background: transparent; }
/* multi line: a WebTUI box frame */
.in-box { width: min(100%, calc(var(--w, 56ch) + 4ch)); padding: var(--row) 1ch; }
textarea { display: block; width: 100%; min-width: 0; min-height: 4lh; padding: 0 1ch; background: transparent; resize: none; }
input:is([type=text], [type=email], [type=url], [type=tel], [type=search]), textarea { caret-color: var(--signal); }
/* focus: the whole [ field ] lifts and its brackets brighten; textarea frames go light */
.in:is(:focus-within, :has(.is-focus)), .in-box:is(:focus-within, :has(.is-focus)) { background: var(--background2); --box-border-color: var(--gray); }
.in input:focus, textarea:focus, .field .is-focus { outline: none; background: transparent; }
input::placeholder, textarea::placeholder { color: var(--gray-dim); opacity: 1; }
/* invalid: dashed outline around the whole field, brackets included */
.in:has([aria-invalid=true]), .in-box:has([aria-invalid=true]) { outline: 1px dashed var(--gray); }
.err { color: var(--gray); font-weight: var(--font-weight-bold); }
.err::before { content: "! "; }
input:disabled, textarea:disabled { color: var(--gray-rule); }
.in:has(:disabled)::before, .in:has(:disabled)::after { color: var(--background3); }

/* ---------- choices: WebTUI radio ( ) / (*) ---------- */
input[type=radio] { --placeholder-background: transparent; --placeholder-color: var(--gray-dim); --checked-color: var(--signal); }
.choice { display: grid; grid-template-columns: 3ch 1fr auto; gap: 0 1ch; padding: 0 1ch; cursor: pointer; }
.choice:has(:checked) { color: var(--gray); font-weight: var(--font-weight-bold); }
.choice:is(:hover, :has(:focus-visible), .is-focus):not(:has(:disabled)) { background: var(--gray); color: var(--black); }
.choice:is(:hover, :has(:focus-visible), .is-focus):not(:has(:disabled)) input[type=radio] { --placeholder-color: var(--black); --checked-color: var(--black); }
.choice:has(:disabled) { color: var(--gray-rule); cursor: not-allowed; }
.choice:has(:disabled) .lead > :first-child, .choice:has(:disabled) > span:nth-child(2):not(.lead) { text-decoration: line-through; }
input[type=radio]:is(:disabled, :focus)::before, input[type=radio]:is(:disabled, :focus)::after, input[type=radio]:focus { text-decoration: none; }
.choices-inline { display: flex; flex-wrap: wrap; gap: 0 1ch; border: 0; }
.choices-inline .choice { grid-template-columns: 3ch auto; }
fieldset { border: 0; min-width: 0; }
legend { color: var(--gray-dim); padding: 0; }

/* dot leaders: "Advance ........ $18" */
.lead { display: flex; min-width: 0; }
.lead > :first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; max-width: 100%; }
.lead::after { content: " ........................................................................................................"; flex: 1; overflow: hidden; white-space: nowrap; color: var(--gray-rule); min-width: 2ch; }

/* stepper: [-] 2 [+] */
.stepper { display: inline-flex; gap: 1ch; align-items: center; }
.stepper output { min-width: 2ch; text-align: center; color: var(--gray); }

/* ---------- badges: WebTUI badge, three tones ---------- */
[is-~=badge] { --badge-color: var(--gray-press); --badge-text: var(--gray); }
[is-~=badge][variant-=alarm] { --badge-color: var(--alarm); --badge-text: var(--black); }
[is-~=badge][variant-=signal] { --badge-color: var(--signal); --badge-text: var(--black); }
[is-~=badge][variant-=line] { --badge-color: transparent; --badge-text: var(--gray-dim); }
.dot { color: var(--alarm); }
.dot.sig { color: var(--signal); }

/* ---------- progress: WebTUI progress drawn with # and - ---------- */
.meter { display: flex; color: var(--gray-dim); min-width: 0; flex: 1; }
.meter::before { content: "["; }
.meter::after { content: "]"; }
.meter [is-~=progress] {
  flex: 1; min-width: 4ch;
  --progress-value-background: transparent; --progress-empty-background: transparent;
  --progress-value-color: var(--gray); --progress-empty-color: var(--gray-rule);
  --progress-value-content: "################################################################################################################";
  --progress-empty-content: "----------------------------------------------------------------------------------------------------------------";
}
.meter[data-on] [is-~=progress] { --progress-value-color: var(--signal); }
/* seek / volume: a native range laid invisibly over the meter, so keys, clicks and drags work as usual */
.meter { position: relative; }
.meter input { position: absolute; inset: 0; width: 100%; min-width: 0; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 2; }
.meter:has(:focus-visible) { outline: 1px solid var(--gray); }
.meter:has(:disabled) [is-~=progress] { --progress-value-color: var(--gray-rule); }
.meter:hover [is-~=progress] { --progress-empty-color: var(--gray-dim); }
.on-air { color: var(--alarm); white-space: nowrap; }

/* ---------- separators and section rules ---------- */
.rule { display: flex; gap: 1ch; align-items: center; color: var(--gray-dim); font-weight: var(--font-weight-normal); }
.rule > [is-~=separator] { flex: 1; }

/* ---------- key/value: NFO block ---------- */
.nfo { display: grid; grid-template-columns: 11ch 1fr; gap: 0 1ch; }
.nfo dt { display: flex; color: var(--gray-dim); overflow: hidden; white-space: nowrap; }
.nfo dt::after { content: " ............"; color: var(--gray-rule); }
.nfo dd { color: var(--gray); min-width: 0; }

/* ---------- messages and status ---------- */
.md { white-space: pre-line; } /* Markdown fields shown as written: line breaks and blank lines kept */
.msg { color: var(--gray-dim); }
.msg::before { content: "-!- "; color: var(--gray-rule); }
.msg[data-tone=ok] { color: var(--signal); }
.msg[data-tone=ok]::before { color: var(--signal); }
.msg[data-tone=err] { color: var(--gray); font-weight: var(--font-weight-bold); }
.msg[data-tone=err]::before { content: "!!! "; color: var(--gray); }
.cursor { display: inline-block; width: 1ch; height: 1lh; vertical-align: top; background: var(--gray); animation: blink 1.06s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* steps: 1 Tickets > 2 Details > 3 Review > 4 Done (a real sequence) */
.steps { display: flex; flex-wrap: wrap; gap: 0 1ch; list-style: none; color: var(--gray-rule); }
.steps li { color: inherit; }
.steps li::before { content: none; }
.steps li + li::before { content: "> "; color: var(--gray-rule); }
.steps [data-done] { color: var(--gray-dim); }
.steps [aria-current=step] { color: var(--signal); }
.steps li { white-space: nowrap; }

/* ---------- log (IRC) and nick list ---------- */
.log { list-style: none; }
.log li { display: grid; grid-template-columns: 6ch 18ch 1fr; gap: 0 1ch; color: var(--gray); }
.log li::before { content: none; }
.log time { color: var(--gray-rule); }
.log .nick { text-align: right; color: var(--gray-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log .ev { color: var(--gray-dim); }
.log .ev .nick, .log li.ev > :nth-child(2) { color: var(--gray-rule); }
.nicks a[data-away] { color: var(--gray-dim); }
.nicks .mode { color: var(--signal); }

/* ---------- art: expressive panels (canvas or figlet) ---------- */
.art { margin: 0; }
.art-c { position: relative; width: 100%; overflow: hidden; background: var(--black); }
.art-c canvas { display: block; }
.art figcaption { color: var(--gray-dim); }
.banner { margin: 0; padding: 0; white-space: pre; line-height: 1; color: var(--gray); background: none; overflow: hidden; font-size: var(--fit, 1em); }
.banner b { font-weight: var(--font-weight-normal); color: var(--gray-rule); }

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
}

/* ---------- touch: two-row hit areas ---------- */
@media (pointer: coarse) {
  button[size-=small], .menu a, .row, .choice { min-height: 2lh; align-items: center; }
  .row, .choice { align-content: center; }
  .in input { height: 2lh; font-size: max(16px, 1em); }
  .pl-ctl button { min-width: 6ch; justify-content: center; }
  .meter input { inset: -.5lh 0; height: 2lh; }
  textarea { font-size: max(16px, 1em); }
}
@media (max-width: 640px) {
  .log li { display: block; }
  .log li > * { display: inline; margin-right: 1ch; }
  .nfo { grid-template-columns: 9ch 1fr; }
  .pm.hint { display: none; }
  .steps li:not([aria-current]) .lbl { display: none; }
}
