/* ==========================================================================
   zaq.to — global styles. Tokens live in tokens.css; this file only uses them.
   Shared primitives here; anything page-specific goes in that page's .razor.css.
   ========================================================================== */

/* ---- Bootstrap, mapped onto the tokens ----------------------------------
   The Identity pages are stock Bootstrap markup. Rather than restyle each one,
   point Bootstrap's own variables at the palette so they inherit the look.   */
[data-bs-theme="dark"] {
    --bs-body-bg: var(--void);
    --bs-body-color: var(--flash);
    --bs-secondary-color: var(--haze);
    --bs-tertiary-bg: var(--riser);
    --bs-border-color: var(--edge);
    --bs-emphasis-color: var(--flash);
    --bs-link-color: var(--hue);
    --bs-link-hover-color: var(--flash);
    --bs-link-color-rgb: 239, 255, 79;
    --bs-font-sans-serif: var(--body);
    --bs-font-monospace: var(--mono);
    --bs-border-radius: var(--r-sm);
    --bs-form-invalid-color: var(--stop);
    --bs-form-valid-color: var(--ok);
    --bs-danger-rgb: 255, 118, 118;
    --bs-success-rgb: 63, 191, 127;
}

html, body {
    background: var(--void);
    color: var(--flash);
    font-family: var(--body);
    font-size: var(--t-body);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--display);
    font-weight: 800;
    letter-spacing: -.005em;
    line-height: 1.05;
}

h1 { font-size: var(--t-h1); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); }
h1:focus { outline: none; }

a { color: var(--hue); }

.mono, code, kbd {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

.eyebrow {
    margin: 0;
    font-family: var(--mono);
    font-size: var(--t-label);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: var(--ls-label);
    color: var(--haze);
}

.muted { color: var(--haze); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Bootstrap buttons on the Identity pages. */
.btn-primary {
    --bs-btn-bg: var(--hue);
    --bs-btn-border-color: var(--hue);
    --bs-btn-color: var(--void);
    --bs-btn-hover-bg: var(--flash);
    --bs-btn-hover-border-color: var(--flash);
    --bs-btn-hover-color: var(--void);
    --bs-btn-active-bg: var(--flash);
    --bs-btn-active-color: var(--void);
    font-weight: 700;
}

.form-control, .form-select {
    background-color: var(--riser);
    border-color: var(--edge);
    color: var(--flash);
}

.form-control:focus, .form-select:focus, .btn:focus-visible {
    border-color: var(--hue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue) 30%, transparent);
}

.validation-message, .text-danger { color: var(--stop) !important; }

/* ---- page header -------------------------------------------------------- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-head h1 { margin: 4px 0 0; }

.page-head .back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--haze);
    text-decoration: none;
    font-size: var(--t-small);
    font-weight: 600;
}

/* ---- buttons -------------------------------------------------------------
   Press, not hover: every control depresses on :active, because hover does
   not exist on touch.                                                        */

.btn-z {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 0 18px;
    border: 1px solid var(--edge);
    border-radius: var(--r);
    background: var(--riser);
    color: var(--flash);
    font-family: var(--body);
    font-size: var(--t-body);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: transform var(--press), background var(--press), border-color var(--press);
}

.btn-z:active:not(:disabled) { transform: translateY(var(--press-y)); }
.btn-z:disabled { opacity: .45; cursor: not-allowed; }

.btn-z.primary { background: var(--hue); border-color: var(--hue); color: var(--void); }
.btn-z.ghost { background: transparent; }
.btn-z.ghost:hover { border-color: var(--haze); }
.btn-z.danger { background: transparent; border-color: color-mix(in srgb, var(--stop) 50%, transparent); color: var(--stop); }
.btn-z.danger.armed { background: var(--stop); border-color: var(--stop); color: var(--void); }
.btn-z.small { min-height: 34px; padding: 0 12px; font-size: var(--t-small); border-radius: var(--r-sm); }

.icon-btn {
    display: inline-grid;
    place-items: center;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--haze);
    font-size: var(--t-small);
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform var(--press), color var(--press), background var(--press);
}

.icon-btn:hover { color: var(--flash); background: var(--edge); }
.icon-btn:active { transform: translateY(var(--press-y)); }
.icon-btn.ok { color: var(--ok); }
.icon-btn.armed { color: var(--void); background: var(--stop); }

/* ---- surfaces ----------------------------------------------------------- */

.card-z {
    background: var(--riser);
    border: 1px solid var(--edge);
    border-radius: var(--r-lg);
    padding: 20px;
}

/* ---- fields ------------------------------------------------------------- */

.field { display: grid; gap: 6px; align-content: start; }

.field > label, .field-label {
    font-size: var(--t-small);
    font-weight: 700;
    color: var(--flash);
}

.hint { font-size: var(--t-small); color: var(--haze); }
.hint.ok { color: var(--ok); display: inline-flex; align-items: center; gap: 4px; }
.error { font-size: var(--t-small); color: var(--stop); font-weight: 600; }

.input-z {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 14px;
    border: 1px solid var(--edge);
    border-radius: var(--r);
    background: var(--void);
    color: var(--flash);
    font: inherit;
    transition: border-color var(--press), box-shadow var(--press);
}

.input-z::placeholder { color: color-mix(in srgb, var(--haze) 70%, transparent); }

.input-z:focus {
    outline: none;
    border-color: var(--hue);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue) 25%, transparent);
}

.input-z.invalid { border-color: var(--stop); }
.input-z.mono { font-family: var(--mono); }

select.input-z { appearance: auto; }

/* Joined input: "zaq.to/" prefix + code + action button. */
.affix {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--edge);
    border-radius: var(--r);
    background: var(--void);
    overflow: hidden;
}

.affix:focus-within { border-color: var(--hue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue) 25%, transparent); }
.affix.invalid { border-color: var(--stop); }

.affix .prefix {
    display: grid;
    place-items: center;
    padding: 0 4px 0 14px;
    color: var(--haze);
    font-family: var(--mono);
    font-size: var(--t-small);
}

.affix input {
    flex: 1;
    min-width: 0;
    min-height: var(--tap);
    padding: 0 6px;
    border: 0;
    background: transparent;
    color: var(--flash);
    font-family: var(--mono);
    outline: none;
}

.affix .icon-btn { margin: 3px; }

/* Toggle switch. */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: var(--tap);
    cursor: pointer;
    font-weight: 600;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch .track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: var(--r-pill);
    background: var(--edge);
    transition: background var(--press);
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--flash);
    transition: transform var(--land);
}

.switch input:checked + .track { background: var(--hue); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--void); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--hue) 35%, transparent); }

/* Segmented control. */
.segmented {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--edge);
    border-radius: var(--r);
    background: var(--void);
}

.segmented button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 14px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--haze);
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--press), background var(--press), color var(--press);
}

.segmented button:active:not(:disabled) { transform: translateY(var(--press-y)); }
.segmented button.on { background: var(--riser); color: var(--flash); box-shadow: inset 0 -2px 0 var(--hue); }
.segmented button:disabled { opacity: .35; cursor: not-allowed; }

/* Filter chips. */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--edge);
    border-radius: var(--r-pill);
    background: transparent;
    color: var(--haze);
    font-size: var(--t-small);
    font-weight: 700;
    cursor: pointer;
    transition: transform var(--press);
}

.chip:active { transform: translateY(var(--press-y)); }
.chip.on { border-color: var(--hue); color: var(--flash); background: color-mix(in srgb, var(--hue) 12%, transparent); }

/* Tag chips (removable). */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 10px;
    border-radius: var(--r-pill);
    background: var(--edge);
    color: var(--flash);
    font-size: var(--t-small);
    font-weight: 600;
}

.tag button {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--haze);
    cursor: pointer;
}

.tag button:hover { color: var(--flash); background: var(--void); }

/* ---- status pills: reserved colours, always with a label ---------------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: var(--r-pill);
    font-family: var(--mono);
    font-size: var(--t-micro);
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid currentColor;
}

.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill.live { color: var(--ok); }
.pill.expiring { color: var(--warn); }
.pill.expired { color: var(--stop); }
.pill.paused { color: var(--haze); }
.pill.blocked { color: var(--stop); }

/* ---- plan usage meter --------------------------------------------------- */

.meter { display: grid; gap: 6px; }

.meter .line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: var(--t-small);
    color: var(--haze);
}

.meter .line b { color: var(--flash); font-family: var(--mono); font-weight: 600; }

.meter .track { height: 6px; border-radius: var(--r-pill); background: var(--edge); overflow: hidden; }
.meter .fill { height: 100%; border-radius: inherit; background: var(--hue); transition: width var(--land); }
.meter.full .fill { background: var(--warn); }

/* ---- notices ------------------------------------------------------------ */

.notice {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    border: 1px solid var(--edge);
    border-left: 3px solid var(--hue);
    border-radius: var(--r);
    background: var(--riser);
}

.notice.warn { border-left-color: var(--warn); }
.notice.stop { border-left-color: var(--stop); }

/* ---- the signature: long becomes short ----------------------------------
   Used at full volume on the landing page and at low volume on create/copy.
   The long URL squeezes out (--snap), the short one lands (--land).        */

.collapse-z { display: grid; }

.collapse-z > * { grid-area: 1 / 1; }

.collapse-z .long {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--haze);
    transform-origin: left center;
    animation: z-squeeze var(--snap) .45s both;
}

.collapse-z .short {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--hue);
    animation: z-land var(--land) .7s both;
}

@keyframes z-squeeze {
    from { opacity: 1; transform: scaleX(1); letter-spacing: 0; }
    to { opacity: 0; transform: scaleX(.15); letter-spacing: -.3em; }
}

@keyframes z-land {
    from { opacity: 0; transform: translateY(8px) scale(.9); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .collapse-z .long { display: none; }
    .collapse-z .short { animation: none; }
}

/* ---- framework bits ----------------------------------------------------- */

.blazor-error-boundary {
    padding: 1rem 1.25rem;
    border-radius: var(--r);
    background: color-mix(in srgb, var(--stop) 20%, var(--riser));
    color: var(--flash);
}

.blazor-error-boundary::after { content: "Something went wrong on this part of the page."; }

.darker-border-checkbox.form-check-input { border-color: var(--haze); }

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder { text-align: start; }

/* ---- boards ----------------------------------------------------------------
   The dashboard library styles itself from Bootstrap variables; point those at
   the zaq.to surfaces inside board pages so cells sit on the same riser/edge
   ground as every other card. */

.dbx-grid, .dbx-grid-editing, .dbx-palette, .dbx-settings-panel {
    --bs-body-bg: var(--riser);
    --bs-tertiary-bg: var(--void);
    --bs-secondary-bg: var(--edge);
    --bs-border-color: var(--edge);
    --bs-secondary-color: var(--haze);
    --bs-primary: var(--hue);
    color: var(--flash);
}

/* The library paints the editor's drag strip pale indigo for light pages; on zaq.to's dark
   ground that read as a white bar across every widget. */
.dbx-cell-toolbar { background: var(--edge); border-bottom-color: var(--edge); color: var(--haze); }
.dbx-cell-selected .dbx-cell-toolbar { background: color-mix(in srgb, var(--hue) 25%, var(--edge)); }

/* zaq.to's own widgets (.zw-*): a figure, a bar chart, a ranked list. Global rather than
   scoped because the library renders them through DynamicComponent in its own markup. */

.zw { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 12px 14px; min-width: 0; }
.zw-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 10px; }
.zw-label { color: var(--flash); font-weight: 700; font-size: var(--t-small); }
.zw-sub { color: var(--haze); font-family: var(--mono); font-size: var(--t-micro); }
.zw-empty { margin: auto 0; color: var(--haze); font-size: var(--t-small); }

.zw-stat { justify-content: center; }
.zw-number { font-family: var(--display); font-size: clamp(32px, 6cqi, 56px); font-weight: 800; line-height: 1; color: var(--flash); }

.zw-bars {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    align-items: end;
    gap: 2px;
    min-height: 80px;
    padding-top: 18px;            /* room for the peak label above the tallest bar */
    border-bottom: 1px solid var(--edge);
}

.zw-col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.zw-bar { position: relative; display: block; width: 100%; max-width: 24px; margin: 0 auto; border-radius: 4px 4px 0 0; background: var(--sec-boards); }
.zw-bar i {
    position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
    color: var(--flash); font: 600 var(--t-micro) var(--mono); font-style: normal; white-space: nowrap;
}

.zw-ranked ol { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.zw-ranked li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; font-size: var(--t-small); }
.zw-row-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--flash); }
.zw-row-num { color: var(--flash); font-family: var(--mono); }
.zw-track { grid-column: 1 / -1; height: 5px; border-radius: var(--r-pill); background: var(--edge); overflow: hidden; }
.zw-track > span { display: block; height: 100%; min-width: 4px; border-radius: inherit; background: var(--sec-boards); }

/* Link rows (Recent links, Expiring soon, Folders). */
.zw-links { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; overflow-y: auto; min-height: 0; }
.zw-links li,
.zw-folder { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 34px; font-size: var(--t-small); }
.zw-folder { grid-column: 1 / -1; width: 100%; padding: 0; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.zw-folder:hover { background: color-mix(in srgb, var(--edge) 60%, transparent); }
.zw-folder:focus-visible { outline: 2px solid var(--hue); outline-offset: 1px; }
.zw-glyph { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--void); color: var(--haze); }
.zw-link-text { display: grid; min-width: 0; }
.zw-link-code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--haze); font-family: var(--mono); font-size: var(--t-micro); }
.zw-soon { color: var(--warn); font-weight: 600; }
.zw-folders .zw-head { justify-content: flex-start; align-items: center; }
.zw-back { display: grid; place-items: center; width: 26px; height: 26px; padding: 0; border: 1px solid var(--edge); border-radius: 7px; background: none; color: var(--flash); cursor: pointer; }

/* Busiest hours: 7 × 24 cells, one hue in four steps. */
.zw-heat-grid { flex: 1; display: grid; grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 2px; align-content: center; }
.zw-heat-day,
.zw-heat-hour { color: var(--haze); font-family: var(--mono); font-size: 10px; line-height: 1; }
.zw-heat-day { padding-right: 6px; align-self: center; }
.zw-heat-cell { aspect-ratio: 1; min-height: 6px; border-radius: 2px; background: var(--edge); }
.zw-heat-cell[data-l="1"] { background: color-mix(in srgb, var(--sec-boards) 30%, var(--edge)); }
.zw-heat-cell[data-l="2"] { background: color-mix(in srgb, var(--sec-boards) 55%, var(--edge)); }
.zw-heat-cell[data-l="3"] { background: color-mix(in srgb, var(--sec-boards) 80%, var(--edge)); }
.zw-heat-cell[data-l="4"] { background: var(--sec-boards); }

/* Spotlight: a figure over a small bar strip. */
.zw-spot .zw-number { margin-top: 4px; }
.zw-spark { min-height: 36px; padding-top: 4px; }

/* QR code: as large as the cell allows, always on its own light square. */
.zw-qr { align-items: center; justify-content: center; }
.zw-qr-code { flex: 1; display: grid; place-items: center; width: 100%; min-height: 0; }
.zw-qr-code svg { width: auto; height: 100%; max-width: 100%; max-height: 100%; aspect-ratio: 1; border-radius: 8px; }
.zw-qr-caption { color: var(--flash); font-family: var(--mono); font-size: var(--t-small); font-weight: 600; text-align: center; }

/* Shortcuts. */
.zw-actions-grid { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; align-content: center; }
.zw-actions-grid a {
    display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 12px;
    border: 1px solid var(--edge); border-radius: var(--r); background: var(--void);
    color: var(--flash); font-size: var(--t-small); font-weight: 600; text-decoration: none;
}
.zw-actions-grid a:hover { border-color: var(--sec-boards); }
