/*
 * Heatrail partner portal: components.
 * ---------------------------------------------------------------------------
 * Every colour, size, radius and face comes from public/css/tokens.css. This
 * file names no colour of its own, so a change to the design system happens in
 * one place. Self-contained, no build step, so the portal renders anywhere.
 *
 * It used to open with its own dark palette (--bg: #0b0f17, --panel, --text)
 * and to redefine --warn and --bad, two values tokens.css already held. That
 * is why a redesign could not be done in tokens.css alone. Both are gone.
 *
 * NO INLINE STYLE ANYWHERE, and no inline script: the portal ships a strict
 * CSP with no 'unsafe-inline' (App\Http\Middleware\SecurityHeaders), so a
 * style="" attribute is silently dropped. Everything visual lives here.
 */

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-text);
    font-size: var(--step-0);
    line-height: var(--leading-body);
    font-synthesis-weight: none;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a { color: var(--focus); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
::selection { background: var(--accent-wash); color: var(--ink); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 var(--space-5); }

.skip-link {
    position: absolute; left: var(--space-4); top: var(--space-4); z-index: 50;
    transform: translateY(-200%); background: var(--surface);
    border: 1px solid var(--rule-strong); border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4); font-size: var(--step--1);
}
.skip-link:focus { transform: translateY(0); }

/* The masthead carries the one gradient, exactly as the homepage does, so a
   partner arriving from heatrail.eu lands on a surface they recognise. */
.topbar { background: var(--band); border-bottom: 1px solid var(--rule); }
.topbar .wrap { display: flex; align-items: center; gap: var(--space-5); min-height: 60px; flex-wrap: wrap; }
.brand { font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.brand span { color: var(--accent); }
.nav { display: flex; gap: var(--space-4); margin-left: auto; align-items: center; flex-wrap: wrap; }
.signout { margin-left: var(--space-2); }
.nav a { display: inline-flex; align-items: center; min-height: 2.5rem; padding-inline: var(--space-1); color: var(--ink-muted); font-size: var(--step--1); font-weight: 500; }
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.active {
    color: var(--ink);
    text-decoration: underline; text-decoration-color: var(--accent);
    text-decoration-thickness: 2px; text-underline-offset: 0.45em;
}

main { padding: var(--space-7) 0 var(--space-8); }

h1 { font-size: var(--step-3); line-height: var(--leading-tight); letter-spacing: -0.02em; margin: 0 0 var(--space-1); font-weight: 700; text-wrap: balance; }
h2 { font-size: var(--step-1); line-height: var(--leading-tight); letter-spacing: -0.01em; margin: 0 0 var(--space-3); font-weight: 600; }
h3 { font-size: var(--step-0); margin: 0 0 var(--space-2); font-weight: 600; }
.sub { color: var(--ink-muted); margin: 0 0 var(--space-6); font-size: var(--step--1); max-width: 80ch; }
.eyebrow {
    font-family: var(--font-mono); font-size: var(--step--2); font-weight: 500;
    letter-spacing: 0.11em; text-transform: uppercase; color: var(--ink-faint);
    margin: 0 0 var(--space-2);
}

/* --- Cards and the headline strip ---------------------------------------- */

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--space-4); }

.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.stat .label { color: var(--ink-faint); font-size: var(--step--2); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }
.stat .value { font-size: var(--step-4); font-weight: 600; margin-top: var(--space-2); letter-spacing: -0.02em; color: var(--ink); line-height: 1.1; }
.stat .value small { font-size: var(--step--1); color: var(--ink-faint); font-weight: 400; }
.stat .value .value-empty { font-size: var(--step--1); color: var(--ink-faint); font-weight: 500; letter-spacing: 0; font-family: var(--font-text); }
.stat .foot { margin-top: var(--space-2); font-size: var(--step--2); color: var(--ink-faint); }
.stat .tag {
    display: inline-block; font-size: var(--step--2); text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ink-faint); border: 1px solid var(--rule-strong); border-radius: var(--radius-pill);
    padding: 1px 8px; margin-left: 6px; vertical-align: middle; font-weight: 500;
}

/* --- Tables --------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: var(--step--1); }
th, td { text-align: left; padding: var(--space-3); border-bottom: 1px solid var(--rule); }
th {
    color: var(--ink-faint); font-weight: 600; font-size: var(--step--2);
    text-transform: uppercase; letter-spacing: 0.06em; background: var(--surface-sunk);
}
tbody tr:last-child td { border-bottom: 0; }

/* --- Buttons -------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; min-height: 2.5rem;
    border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent);
    padding: 0.55rem 1.05rem; border-radius: var(--radius-md);
    font-family: inherit; font-size: var(--step--1); font-weight: 500;
    box-shadow: var(--shadow-sm);
    transition: background-color 120ms ease, border-color 120ms ease;
}
.btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); text-decoration: none; color: var(--on-accent); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); }
.btn.secondary:hover { background: var(--surface-sunk); border-color: var(--ink-faint); color: var(--ink); }
.btn:disabled, .btn.disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-sm { padding: 0.3rem 0.8rem; font-size: var(--step--2); min-height: 2.25rem; }
.nav .btn-sm, .signout .btn-sm { min-height: 2.5rem; }

/* --- Forms ---------------------------------------------------------------- */

label { display: block; font-size: var(--step--1); color: var(--ink); font-weight: 500; margin: var(--space-4) 0 var(--space-2); }
input, select, textarea {
    width: 100%; min-height: 2.75rem; background: var(--surface); border: 1px solid var(--rule-strong);
    color: var(--ink); border-radius: var(--radius-md); padding: 0.55rem 0.75rem;
    font-family: inherit; font-size: var(--step-0);
}
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--focus);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* --- Alerts --------------------------------------------------------------- *
 * The text stays --ink rather than the semantic colour: the tinted ground and
 * the border already carry the state, and navy on a pale wash reads better at
 * 13px than dark red on pale red.                                            */
.alert { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); margin-bottom: var(--space-4); font-size: var(--step--1); border: 1px solid; color: var(--ink); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.alert.warn { background: var(--heat-medium-bg); border-color: var(--heat-medium-line); }
.alert.bad { background: var(--heat-high-bg); border-color: var(--heat-high-line); }

/* --- Badges, and the heat semantics --------------------------------------- */

.badge {
    display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill);
    font-size: var(--step--2); font-weight: 600; border: 1px solid var(--rule-strong);
    color: var(--ink-faint); background: var(--surface-sunk);
}
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.badge.warn { color: var(--heat-medium); background: var(--heat-medium-bg); border-color: var(--heat-medium-line); }
.badge.bad { color: var(--heat-high); background: var(--heat-high-bg); border-color: var(--heat-high-line); }
.badge.muted { color: var(--ink-faint); }
.badge.heat-high { color: var(--heat-high); background: var(--heat-high-bg); border-color: var(--heat-high-line); }
.badge.heat-medium { color: var(--heat-medium); background: var(--heat-medium-bg); border-color: var(--heat-medium-line); }
.badge.heat-neutral { color: var(--heat-neutral); background: var(--heat-neutral-bg); border-color: var(--heat-neutral-line); }
.badge.status-pending { color: var(--status-pending); background: var(--heat-medium-bg); border-color: var(--heat-medium-line); }
.badge.status-active { color: var(--status-active); background: var(--heat-high-bg); border-color: var(--heat-high-line); }
.badge.status-withdrawn { color: var(--status-withdrawn); background: var(--heat-neutral-bg); border-color: var(--heat-neutral-line); }

/* --- One-time values and code --------------------------------------------- */

.secret {
    font-family: var(--font-mono); font-size: var(--step--1);
    background: var(--surface-sunk); border: 1px dashed var(--accent);
    padding: var(--space-3); border-radius: var(--radius-md);
    word-break: break-all; color: var(--ink);
}
pre {
    background: var(--surface-sunk); border: 1px solid var(--rule); border-radius: var(--radius-md);
    padding: var(--space-4); overflow-x: auto; font-family: var(--font-mono);
    font-size: var(--step--2); color: var(--ink); line-height: 1.5;
}
code {
    font-family: var(--font-mono); font-size: 0.9em;
    background: var(--surface-sunk); border: 1px solid var(--rule);
    border-radius: var(--radius-sm); padding: 0.05em 0.3em;
}
pre code { background: none; border: 0; padding: 0; }
.prompt {
    width: 100%; min-height: 320px; resize: vertical;
    font-family: var(--font-mono); font-size: var(--step--2); line-height: 1.45;
    background: var(--surface-sunk); border: 1px solid var(--rule-strong);
    color: var(--ink); border-radius: var(--radius-md); padding: var(--space-4); white-space: pre;
}

/* --- Text utilities -------------------------------------------------------- */

.muted { color: var(--ink-faint); }
.small { font-size: var(--step--1); }
.center { max-width: 30rem; margin: var(--space-8) auto; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.error { color: var(--heat-high); font-size: var(--step--1); margin-top: var(--space-2); }
.unknown { color: var(--ink-faint); font-style: italic; font-size: var(--step--2); }
.headline { font-size: var(--step-1); font-weight: 600; margin: var(--space-1) 0 var(--space-2); }

/* --- Layout utilities (review fix: no inline style attributes in views) ---- */

.spacer { height: var(--space-2); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.inline { display: inline; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.grid-form { grid-template-columns: 1.3fr 1fr; align-items: start; }
.row-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-top: var(--space-3); }
.check-row { display: flex; gap: var(--space-2); align-items: flex-start; margin-top: var(--space-4); color: var(--ink); font-size: var(--step--1); }
.check-row input { width: 1.25rem; height: 1.25rem; flex: none; margin-top: 0.1em; }
.check-row { min-height: 2.5rem; }

@media (max-width: 52rem) {
    /* Two rows: brand and Sign out share the first, the section links get a
       full-width row that scrolls sideways instead of wrapping to three. */
    .topbar .wrap { padding-block: var(--space-2); }
    .signout { order: 2; margin-left: auto; }
    .nav {
        order: 3; flex-basis: 100%; margin-left: 0; flex-wrap: nowrap;
        overflow-x: auto; scrollbar-width: none; gap: var(--space-3);
        margin-inline: calc(-1 * var(--space-5)); padding-inline: var(--space-5);
    }
    .nav::-webkit-scrollbar { display: none; }
    .nav a { white-space: nowrap; }
    .grid-2, .grid-3, .grid-form { grid-template-columns: minmax(0, 1fr); }
    .card { overflow-x: auto; }
    .tabs a { padding-block: 0.65rem; }
    main { padding-top: var(--space-5); }
    h1 { font-size: var(--step-2); }
}

/* --- Merchant dashboard (design 2026-09-02) -------------------------------- */

.sparkline { display: block; width: 100%; height: 36px; margin-top: var(--space-3); }
.sparkline-line { stroke: var(--spark-line); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sparkline-area { fill: var(--spark-area); }

.tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-4); border-bottom: 1px solid var(--rule); flex-wrap: wrap; }
.tabs a { padding: var(--space-2) var(--space-4); color: var(--ink-faint); font-size: var(--step--1); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.chip {
    display: inline-flex; gap: var(--space-2); align-items: center; font-size: var(--step--1);
    background: var(--surface-sunk); border: 1px solid var(--rule); border-radius: var(--radius-pill);
    padding: var(--space-1) var(--space-3); margin-bottom: var(--space-4);
}
.chip a { font-size: var(--step--2); }

.reasons { margin: 0; padding-left: var(--space-4); font-size: var(--step--1); color: var(--ink-muted); }
.reasons li { margin: 2px 0; }
.group-title { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-6) 0 var(--space-3); }
.group-title .count { color: var(--ink-faint); font-size: var(--step--1); font-weight: 400; }
.pager { display: flex; gap: var(--space-3); align-items: center; justify-content: flex-end; font-size: var(--step--1); color: var(--ink-faint); margin-top: var(--space-3); }

.pipeline { border-color: var(--rule-strong); }
.pipeline table td { padding: var(--space-2) var(--space-3); }
.pipeline .bar { width: 100%; height: 8px; display: block; }
.pipeline .bar rect.track { fill: var(--pipe-track); }
.pipeline .bar rect.fill { fill: var(--pipe-bar); }
.pipeline .total { text-align: right; color: var(--ink-faint); font-size: var(--step--1); margin-top: var(--space-2); }

.graph-wrap { position: relative; }
.graph-canvas {
    display: block; width: 100%; height: 480px; background: var(--graph-canvas);
    border: 1px solid var(--rule); border-radius: var(--radius-lg); cursor: default;
}
.legend { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--step--2); color: var(--ink-faint); margin-top: var(--space-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.legend i.square { border-radius: 2px; }
.legend i.heat-high { background: var(--heat-high); }
.legend i.heat-medium { background: var(--heat-medium); }
.legend i.heat-neutral { background: var(--heat-neutral); }
.legend i.order { background: var(--graph-order); }
.legend i.glyph { background: transparent; border: 1px dashed var(--graph-edge-other); }
.cluster-links a { margin-right: var(--space-3); font-size: var(--step--1); }

/* --- The install chooser ---------------------------------------------------- */

.card .choice { display: block; }
.choice h3 { margin: 0 0 var(--space-2); font-size: var(--step-0); }
.choice .tag {
    display: inline-block; font-size: var(--step--2); text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ok); border: 1px solid var(--ok-line); background: var(--ok-bg);
    border-radius: var(--radius-pill); padding: 2px 8px; margin-bottom: var(--space-2); font-weight: 600;
}
.choice.selected { border-color: var(--accent); box-shadow: var(--shadow-md); }

/* --- Footer ------------------------------------------------------------------ */

.portal-footer { border-top: 1px solid var(--rule); margin-top: var(--space-8); padding: var(--space-5) 0; }
.portal-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--space-4); font-size: var(--step--2); color: var(--ink-faint); }
.portal-footer a { color: var(--ink-faint); display: inline-block; padding-block: 0.6rem; }
.portal-footer .wrap { align-items: center; }
.portal-footer span { padding-block: 0.6rem; }

/* --- The registration language switch ---------------------------------------- *
 * The portal's ONE non-English surface. A native <details>, so it opens with no
 * JavaScript and needs nothing from the strict CSP. Twenty four entries do not
 * fit a column, so the menu is a grid: three tracks on a desk, two on a phone.
 * The switch sits above the heading, right aligned, and is the first thing in
 * the flow after the masthead, because somebody who cannot read the page needs
 * to find it before they read anything else.                                   */

.reg-lang { position: relative; margin: 0 0 var(--space-3); display: flex; justify-content: flex-end; }

.reg-lang summary {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 2.75rem; min-height: 2.5rem; padding-inline: var(--space-3);
    border: 1px solid var(--rule-strong); border-radius: var(--radius-md);
    background: var(--surface); font-family: var(--font-mono); font-size: var(--step--2);
    letter-spacing: 0.08em; color: var(--ink-muted); cursor: pointer; list-style: none;
    user-select: none;
}
.reg-lang summary::-webkit-details-marker { display: none; }
.reg-lang summary:hover, .reg-lang[open] summary { color: var(--ink); border-color: var(--ink-faint); }

.reg-lang-menu {
    position: absolute; right: 0; top: calc(100% + var(--space-2)); z-index: 50;
    margin: 0; padding: var(--space-2); list-style: none;
    background: var(--surface); border: 1px solid var(--rule);
    border-radius: var(--radius-md); box-shadow: var(--shadow-md);
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px 2px;
    width: max-content; max-width: min(92vw, 32rem);
    max-height: min(70vh, 30rem); overflow-y: auto; overscroll-behavior: contain;
}
.reg-lang-menu a {
    display: flex; align-items: baseline; gap: var(--space-2);
    padding: 0.5rem var(--space-2); border-radius: var(--radius-sm);
    font-size: var(--step--1); color: var(--ink-muted); text-decoration: none; white-space: nowrap;
}
.reg-lang-menu a:hover { background: var(--surface-sunk); color: var(--ink); }
.reg-lang-menu a[aria-current='true'] { color: var(--ink); font-weight: 600; }
.reg-lang-code { font-family: var(--font-mono); font-size: var(--step--2); letter-spacing: 0.06em; color: var(--ink-faint); flex: none; }
.reg-lang-menu a:hover .reg-lang-code { color: var(--ink-muted); }
.reg-lang-menu a[aria-current='true'] .reg-lang-code { color: var(--accent); }

@media (max-width: 40rem) {
    .reg-lang-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: min(94vw, 22rem); }
    .reg-lang-menu a { min-height: 2.25rem; align-items: center; }
}

/* The one-line English gloss under a consent checkbox. Its own line, and
   quieter than the sentence above it, because on a translated registration
   screen it is the only English in a German or Greek paragraph and it should
   read as a quotation of the document rather than as the end of our sentence. */
.check-row-summary {
    display: block;
    margin-top: 0.25rem;
    font-size: var(--step--2);
    color: var(--ink-faint);
}
