/* bootstrap-icons CSS was previously loaded here via @import. Moved to a
   <link rel="stylesheet" integrity="..."> tag in layout.html so SRI can
   actually apply — @import statements ignore the integrity attribute. */

:root {
    --base-fonts: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Arial, sans-serif;
    /* Design tokens */
    --color-primary:      #72226d;
    --color-secondary:    #2980b9;
    --color-bg: #f6f5f3;
    --color-text:         #232323;
    --color-text-muted:   #606060;
    --color-text-faint:   #6d6d6d;   /* third text rank; AA ≥4.5:1 on #fff & #f6f5f3 */
    --color-text-inverse: #ffffff;
    --color-surface:      #ffffff;
    --color-border:       #e4e4e4;
    --color-danger:       #b32525;
    --focus-ring-color:   var(--color-primary);  /* shared keyboard focus ring (see Focus block) */
    /* Status palette — promoted de-facto values; each is AA (≥4.5:1) as text
       on white AND on its own tint. Use instead of one-off greens/reds. */
    --color-success:      #3a6d2b;
    --color-success-bg:   #eef6ee;
    --color-warning:      #9a5b12;
    --color-warning-bg:   #fff3d6;
    --color-danger-bg:    #fef2f2;
    --color-info:         #1f6391;  /* AA dark blue (the secondary #2980b9 fails as text) */
    --color-info-bg:      #eaf1f6;
    /* Spacing scale (4px base). Usable in any property (vars can't be used in
       @media — for breakpoints follow the documented 640/896/1024 standard). */
    --space-xs:  4px;
    --space-sm:  8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;
    --space-2xl: 48px;
    /* Chrome geometry (PLAN-site-shell C4). --chrome-top is the line page
       content clears below a frame's fixed chrome. Its 88px cleared the
       legacy navbar until C13 (nav.css, deleted in C13b); it now sets the
       voter pages' top, and plain.css and shell.css set their own
       (RULING-site-shell-13-0 R1).
       <main>'s top padding, sticky tops, anchor scroll margins, panes sized to
       the viewport and the flash bar read it, so a frame with other chrome
       moves them by setting one value. Not on it: the .content-* tiers' 112px
       (page rhythm, not clearance).
       --rail-w is the width of a left rail, none here; the fixed overlays
       centre past it. Keep its unit: with a unitless 0, calc(50% + 0 / 2) is
       invalid, and a var() that makes a value invalid falls back to the
       property's initial value, not to an earlier declaration.
       Guard: test_chrome_tokens.py. */
    --chrome-top: 88px;
    --rail-w: 0px;
    /* Legacy (keep for compatibility) */
    --dark1: #232323;
    --dark2: #606060;
    --dark3: #6b6b6b;
    --light4: #eaeaea;
    --light5: #dadada;
    --default-link: #232323;
    --default-link-hover: #72226d;
    --link-hover-color: #72226d;
    --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

body, html {
    min-height: 100vh;
    scrollbar-gutter: stable;
}

body {
    font-family: var(--base-fonts), sans-serif;
    font-weight: 400;
    font-style: normal;
    font-size: 1.125rem; /* 18px */
    color: var(--color-text);
    /*background-color: var(--color-bg);*/
    background: linear-gradient(
180deg in oklch,
  oklch(0.99 0 0) 0%,
  oklch(0.97 0.01 237) 100%
    );
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* The layout's top-level <main> gets top padding below the chrome line:
   the line plus 8px, 96px by default. It cleared the legacy navbar until
   C13 and now sets the voter pages' top (RULING-site-shell-13-0 R1);
   plain.css zeroes it, and the shell's <main> is not a child of <body>.
   `body > main`
   scopes this to the outer element only — nested <main> elements inside
   pages (qrs-main) must not inherit it. */
body > main {
    padding-top: calc(var(--chrome-top) + 8px);
}

footer {
    margin-top: auto;
}

/* Stacking contexts for main + footer. This originally lifted them above the
   fixed ambient .stage backdrop (retired 2026-09-22), and was kept because the
   legacy navbar (fixed, z-index 50) lived inside <main> via base.html until
   C13b, so its stacking against the footer, dropdowns and page dialogs was
   scoped by this rule. It keeps <main> one level above <footer>: with equal
   z-indexes the footer, being later in the page, painted over everything fixed
   inside <main>, the navbar's mobile menu included (REVIEW-site-shell-2). What
   it does on plain and voter pages since C13 isn't measured, so removing the
   rule is a separate change that needs its own visual check
   (RULING-site-shell-13e §9). */
main, footer {
    position: relative;
    z-index: 1;
}
main {
    z-index: 2;
}

@layer base {
    a:link, a:visited {
        color: var(--default-link);
        text-decoration: none;
    }

    a:hover {
        color: var(--default-link-hover);
    }
}

p:last-child {
    padding-bottom: unset;
    margin-bottom: unset;
}

h1, h2, h3, h4, h5 {
    font-family: var(--base-fonts) sans-serif;
    font-weight: 800;
    font-style: normal;
    color: var(--dark1);
}

h4 {
    color: var(--dark2);
}

/* ── CUBE: Composition ─────────────────────────────────────────────────── */

.center-page {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 24px;
}

.content-narrow {
    max-width: 768px;
    margin: 0 auto;
    padding: 64px 24px;
}

.content-sm {
    max-width: 672px;
    margin: 0 auto;
    padding: 112px 24px;
}

.content-md {
    max-width: 896px;
    margin: 0 auto;
    padding: 112px 24px;
}

.content-wide {
    max-width: 1024px;
    margin: 0 auto;
    padding: 112px 24px;
}

.content-xwide {
    max-width: 1280px;
    margin: 0 auto;
    padding: 112px 24px;
}

/* The widest tier, for workbenches and tables that use the room
   (RULING-site-shell-0 D5a). */
.content-full {
    max-width: 1440px;
    margin: 0 auto;
    padding: 112px 24px;
}

.flow > * + * {
    margin-top: 24px;
}

/* ── CUBE: Utility ─────────────────────────────────────────────────────── */

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--color-text-muted); }
.text-faint  { color: var(--color-text-faint); }
.text-subtle { color: var(--dark3); }
.text-sm     { font-size: 14px; }
.text-xs     { font-size: 12px; }
.text-lg     { font-size: 18px; }
.w-full      { width: 100%; }
.font-bold   { font-weight: 700; }

.mt-2  { margin-top: 8px; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.mt-8  { margin-top: 32px; }
.mt-10 { margin-top: 40px; }
.mb-2  { margin-bottom: 8px; }
.mb-4  { margin-bottom: 16px; }
.mb-8  { margin-bottom: 32px; }
.mb-10 { margin-bottom: 40px; }
.pt-2  { padding-top: 8px; }

.uppercase      { text-transform: uppercase; }
.tracking-wide  { letter-spacing: 0.1em; }

/* ── CUBE: Block — Card ────────────────────────────────────────────────── */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 32px;
}

/* ── CUBE: Block — Prose ───────────────────────────────────────────────── */

.prose h2, .prose h3, .prose h4, .prose h5 {
    margin-top: 1.8em;
    margin-bottom: 0.6em;
}

.prose p {
    line-height: 1.7;
    margin-bottom: 1em;
    color: var(--color-text-muted);
}

.prose a {
    color: var(--color-primary);
    text-decoration: underline;
}

.prose a:hover {
    opacity: 0.8;
}

/* ── CUBE: Block — Tool write-up ───────────────────────────────────────── */

.tool-writeup {
    margin-top: 50px;
    padding-top: 50px;
    border-top: 1px solid var(--color-border);
}

.tool-writeup p {
    line-height: 1.7;
    color: var(--color-text-muted);
    margin-bottom: 1em;
}

.tool-writeup p:first-of-type {
    font-size: 1.0625rem;
    color: var(--color-text);
}

.tool-writeup h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 2.5em 0 1em;
}

.tool-writeup ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 20px;
}

.tool-writeup li {
    padding-left: 20px;
    position: relative;
    color: var(--color-text-muted);
    line-height: 1.6;
}

.tool-writeup li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
}

.tool-writeup li strong {
    display: block;
    margin-bottom: 4px;
    color: var(--color-text);
    font-weight: 700;
}

/* ── CUBE: Block — Form field ──────────────────────────────────────────── */

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    border-radius: var(--radius);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-family: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s;
}

select.form-input {
    padding-right: 48px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b6b68' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 18px center;
}

.form-input:focus {
    border-color: var(--color-primary);
}

.form-error {
    color: var(--color-primary);
    font-size: 14px;
    margin-top: 6px;
}

/* ── CUBE: Block — Button ──────────────────────────────────────────────── */

.btn {
    display: inline-block;
    font-family: inherit;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 9999px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s, color 0.15s;
    text-align: center;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}
.btn-primary:hover {
    background: #601d5c;
    color: var(--color-text-inverse);
}

.btn-secondary {
    background: var(--color-text);
    color: var(--color-text-inverse);
}
.btn-secondary:hover {
    background: #404040;
    color: var(--color-text-inverse);
}

.btn-ghost {
    border: 1px solid var(--color-text);
    color: var(--color-text);
    background: none;
}
.btn-ghost:hover {
    background: var(--color-text);
    color: var(--color-text-inverse);
}

.btn-danger {
    background: #dc2626;
    color: var(--color-text-inverse);
}
.btn-danger:hover {
    background: #b91c1c;
    color: var(--color-text-inverse);
}

.btn-lg {
    padding: 16px 24px;
}

/* Compact variant for dense tool panels (blog, decks, list-prep use it). */
.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── CUBE: Block — Focus ring (shared) ─────────────────────────────────────
   One keyboard-focus system for the whole site. These element-level
   :focus-visible selectors sit at (0,1,1) specificity: high enough to beat
   bare `outline: none` resets (.form-input, .qrs-input, the per-tool input
   resets) and element hover styles, but low enough that any component with
   its OWN class-based focus treatment (text_tools .tool-*, file_drop, nav,
   watcher .field, label_reflow .lr-profile-*,
   and per-page input :focus rules) still wins and keeps its bespoke
   indicator. Unlayered, so it also beats the `@layer base` link rules above.

   Net effect: every custom button family that previously styled only :hover
   (qr, image tools, campaigns, watcher, list-prep, …) now gets a visible
   keyboard-focus ring for free, with zero per-page edits. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[tabindex="0"]:focus-visible {
    outline: 2px solid var(--focus-ring-color);
    outline-offset: 2px;
}

/* A scroll box (a named region that is a tab stop; test_scroll_regions.py)
   brings a control that Tab moves focus to inside it clear of its edge, focus
   ring and all: form_guards.js scrolls the control into view, and this padding
   is the room it leaves (RULING-site-shell-11d Q5). */
[role="region"][tabindex="0"] {
    scroll-padding-inline: 0.5rem;
}

/* Pill buttons: nudge the ring clear of the fully-rounded edge so it reads as
   a halo rather than hugging the fill. */
.btn:focus-visible {
    outline-offset: 3px;
}

/* ── CUBE: Block — Alert ───────────────────────────────────────────────── */

/* Status alerts. .alert-error keeps its shape; its text now uses
   --color-danger (#b32525, AA on the tint) instead of the old #d94e5a, which
   failed contrast (3.7:1) on its own #fef2f2 background. */
.alert-error,
.alert-success,
.alert-warning,
.alert-empty {
    margin-bottom: 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    padding: 12px 16px;
    font-size: 14px;
}

.alert-error {
    background: var(--color-danger-bg);
    border-color: #fecaca;
    color: var(--color-danger);
}

.alert-success {
    background: var(--color-success-bg);
    border-color: #cfe6cc;
    color: var(--color-success);
}

.alert-warning {
    background: var(--color-warning-bg);
    border-color: #f0dca5;
    color: var(--color-warning);
}

.alert-empty {
    background: var(--color-bg);
    border-style: dashed;
    border-color: var(--color-border);
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-muted);
}

.alert-error p,
.alert-success p,
.alert-warning p,
.alert-empty p { color: inherit; }

.alert-error ul,
.alert-success ul,
.alert-warning ul {
    list-style: none;
    padding: 0;
    margin: 4px 0 0;
}

/* ── CUBE: Block — Spinner ─────────────────────────────────────────────────
   Inherits size from font-size (1em) and colour from currentColor, so it
   adapts to any context: `<span class="spinner"></span>`. */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: -0.125em;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 1.6s; }
}

/* ── CUBE: Block — Error page ──────────────────────────────────────────── */

.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 96px 24px;
}

.error-page img {
    max-width: 300px;
    margin-bottom: 32px;
}

.error-page h1 {
    font-size: 96px;
    font-weight: 800;
}

.error-page h2 {
    font-size: 24px;
    font-weight: 700;
    margin-top: 8px;
    margin-bottom: 16px;
}

.error-page p {
    color: var(--color-text-muted);
    max-width: 448px;
}

.error-page a {
    color: var(--color-primary);
}

.error-page a:hover {
    text-decoration: underline;
}

/* ── CUBE: Block — Badge ───────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-radius: 9999px;
}

.badge-active {
    background: #dcfce7;
    color: #15803d;
}

.badge-inactive {
    background: #fef2f2;
    color: var(--color-primary);
}

/* ── CUBE: Block — Page header ─────────────────────────────────────────── */

.page-sub {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}

.page-title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.page-desc {
    font-size: 18px;
    color: var(--color-text-muted);
}

/* ── CUBE: Block — List card ───────────────────────────────────────────── */

.list-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
}

.list-row + .list-row {
    border-top: 1px solid #f0f0f0;
}

.list-empty {
    padding: 32px 24px;
    text-align: center;
    color: var(--color-text-muted);
}

/* ── CUBE: Block — Danger zone ─────────────────────────────────────────── */

.danger-zone {
    background: var(--color-surface);
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 32px;
    margin-top: 24px;
}

.danger-zone .page-sub {
    color: var(--color-primary);
}

/* ── CUBE: Utility — Links ─────────────────────────────────────────────── */

.link-back {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-muted);
}

.link-back:hover {
    text-decoration: underline;
    color: var(--color-text-muted);
}

.link-accent {
    color: var(--color-primary);
    font-weight: 600;
}

.link-accent:hover {
    text-decoration: underline;
    color: var(--color-primary);
}

/* ── CUBE: Utility — Layout helpers ────────────────────────────────────── */

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.flex-row {
    display: flex;
    align-items: center;
}

.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.font-mono { font-family: 'DM Mono', 'Fira Code', monospace; }
.shrink-0 { flex-shrink: 0; }
.min-w-0 { min-width: 0; }
.flex-1 { flex: 1; }

@media (max-width: 639px) {
    .sm-hidden { display: none; }
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 639px) {
    .grid-2 { grid-template-columns: 1fr; }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── CUBE: Block — Pagination (shared macros/pagination.html) ──────────── */

.pagination {
    display: flex;
    flex-wrap: wrap;            /* wrap many page links on narrow screens */
    justify-content: center;
    align-items: center;
    gap: 8px;                   /* was Tailwind gap-2 */
    margin-top: 24px;           /* was mt-6 */
    font-size: 14px;            /* was text-sm */
    font-weight: 700;           /* was font-bold */
}

.pagination a,
.pagination span {
    padding: 4px 12px;          /* was px-3 py-1 */
    border-radius: 6px;         /* project standard radius for small controls */
    color: var(--color-text-faint);
}

.pagination a { text-decoration: none; }
.pagination a:hover { color: var(--color-primary); }            /* was hover:text-[#c73737] */
.pagination .pagination-current { color: var(--color-primary); } /* active page marker */

/* ── Utilities ─────────────────────────────────────────────────────────── */

.hidden { display: none !important; }

/* ── Flash messages ────────────────────────────────────────────────────── */

.flash-bar {
  position: fixed;
  top: var(--chrome-top);
  /* Centred on the workspace: past a left rail, when the frame has one. */
  left: calc(50% + var(--rail-w) / 2);
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, calc(100vw - var(--rail-w) - 24px));
  pointer-events: none;
}

.flash-msg {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 12px 18px;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
  pointer-events: auto;
  animation: flash-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.flash-msg.is-leaving {
  animation: flash-out 180ms ease-in forwards;
}

.flash-text {
  flex: 1;
  min-width: 0;
}

.flash-close {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 120ms ease, background-color 120ms ease;
}

.flash-close:hover,
.flash-close:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
  outline: none;
}

/* Restore a visible keyboard-focus ring (the rule above zeroes the outline for
   the shared hover case; keyboard users need it back). currentColor tracks the
   flash text colour so it contrasts on every flash variant. */
.flash-close:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.flash-danger {
  background: #fef2f2;
  color: #b32525;
  border-color: #fecaca;
}

.flash-info {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #c7dbff;
}

.flash-success {
  background: #f0fdf4;
  color: #15803d;
  border-color: #bbf7d0;
}

@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes flash-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-8px); }
}

@media (prefers-reduced-motion: reduce) {
  .flash-msg,
  .flash-msg.is-leaving { animation: none; }
}

/* ── Footer ────────────────────────────────────────────────────────────── */

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 64px 24px;
}

.footer-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.footer-logo {
  display: flex;
  align-items: center;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.footer-logo:hover { color: var(--color-text); }

.footer-logo img {
  height: 56px;
  width: auto;
  max-width: none;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.footer-col--end {
  align-items: flex-end;
}

.footer-col hr {
  width: 100%;
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--color-border);
}

.footer-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.footer-links a {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--color-text); }

.footer-cookie-row {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.footer-link-beer {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: color 0.15s;
}

.footer-link-beer:hover { color: var(--color-text); }

.footer-copy {
  font-size: .88rem;
  margin: 0;
  color: var(--color-text-faint);
}

@media (max-width: 767px) {
  .footer-row {
    /*flex-direction: column;*/
    text-align: center;
  }
}
