/* ===========================================================================
   Finperiti — application design system
   Petrol/teal brand, Manrope type. Replaces Bootstrap entirely.
   Tokens come from tokens.css (mirrors new-brandbook/tokens.css).
   =========================================================================== */

/* Design tokens (colours, radii, shadows, type, motion, themes) live in the shared tokens.css, loaded before this file. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { color: var(--heading); line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: 2rem; margin: 0 0 .5rem; font-weight: 800; }
/* Blazor's FocusOnNavigate focuses the route <h1> on every navigation (good for screen readers), but the
   <h1> isn't interactive, so the browser's focus ring just looks like a stray highlight. Suppress it while
   keeping the element focusable/announced. */
h1:focus, h1:focus-visible { outline: none; }
h2 { font-size: 1.4rem; margin: 0 0 .75rem; font-weight: 700; }
h3 { font-size: 1.12rem; margin: 1.5rem 0 .6rem; font-weight: 700; }
p { margin: 0 0 1rem; }
.lead { font-size: 1.12rem; color: var(--ink-soft); max-width: 70ch; margin: 0 0 1.75rem; }
.my-cases-intro strong { overflow-wrap: anywhere; }
.my-cases-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1rem; margin: 1rem 0; }
.my-case { min-width: 0; margin: 0; }
.my-case h2 { margin: 0 0 1rem; overflow-wrap: anywhere; }
.my-case dl { display: grid; gap: .7rem; margin: 0 0 1.25rem; }
.my-case dl > div { display: grid; grid-template-columns: minmax(5rem, 7rem) minmax(0, 1fr); gap: .75rem; }
.my-case dt { color: var(--ink-soft); font-size: .85rem; }
.my-case dd { margin: 0; overflow-wrap: anywhere; }
.my-case > a { display: inline-flex; min-height: 2.75rem; align-items: center; font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
a:hover { text-decoration: none; }

code, .mono { font-family: var(--font-mono); font-size: .86em; }

/* ---------- Cards ---------- */
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin: 1.5rem 0; }

.card {
  display: block;
  padding: 1.4rem 1.5rem;
  margin: 0 0 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
}
.cards .card { margin: 0; transition: transform .12s, box-shadow .12s, border-color .12s; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); text-decoration: none; }
.card h2, .card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

/* ---------- Forms ---------- */
.field { margin: 0 0 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .3rem; }
.field small { display: block; margin-top: .35rem; font-size: .8rem; color: var(--ink-soft); }

/* Text-like form controls. Checkboxes/radios are excluded so they keep their native box. */
input:not([type=checkbox]):not([type=radio]), select, textarea {
  font: inherit;
  width: 100%;
  max-width: 32rem;
  padding: .55rem .7rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--teal-deep);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 22%, transparent);
}

/* Checkboxes & radios: native size, brand accent, and a clickable label row. */
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent-ink); cursor: pointer; }
.check {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: .5rem;
  margin: 0 0 1rem;
  font-size: .95rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.check input { margin: 0; }

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--on-accent);
  transition: background .12s, box-shadow .12s;
}
button:hover, .btn:hover { background: var(--accent-hover); }
button:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* :not(...) excludes .button-primary/-secondary/-danger — those own their full colour story (see components.css) and a same-or-higher-specificity generic rule here would otherwise clobber it, especially on hover. */
button[type="button"]:not(.button-primary):not(.button-secondary):not(.button-danger) { background: var(--surface-2); color: var(--ink); border-color: var(--border-strong); }
button[type="button"]:not(.button-primary):not(.button-secondary):not(.button-danger):hover { background: var(--border); } /* was var(--mist), a constant (non-theme-aware) tint that broke dark-mode text contrast */

/* ---------- Tables ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: 1rem 0;
}
th, td { text-align: left; padding: .8rem .95rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); font-weight: 700; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* Required-field marker: a red asterisk after the label, instead of the word "required". */
label.required::after { content: " *"; color: var(--red); font-weight: 700; }

/* ---------- Validation ---------- */
.valid.modified:not([type=checkbox]) { border-color: var(--green); }
.invalid { border-color: var(--red); }
.validation-message { color: var(--red); font-size: .85rem; }

/* ---------- Country coverage (signup) ----------
   The flag and map visuals live in the Finperiti.Geography component library; these are just the
   page-level layout (legend + flag wrapping) and the brand theming of the library's CSS variables. */
.coverage-legend { display: flex; flex-wrap: wrap; gap: 1.25rem; font-size: .85rem; color: var(--ink-soft); margin: .25rem 0 1rem; }
.coverage-legend .dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.coverage-legend .dot-ok { background: var(--green); }
.coverage-legend .dot-no { background: var(--ink-faint); }

.flag-grid { display: flex; flex-wrap: wrap; gap: .35rem; margin: .25rem 0 1.25rem; }

/* Data-boundary selection table (signup): checkbox + per-boundary coverage in one grid. */
.boundary-table td:nth-child(4), .boundary-table th:nth-child(4),
.boundary-table td:nth-child(5), .boundary-table th:nth-child(5) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.boundary-table td { vertical-align: middle; }
.boundary-table tbody tr.is-selected { background: color-mix(in srgb, var(--green) 8%, var(--surface)); }
.boundary-table tbody tr.is-selected:hover { background: color-mix(in srgb, var(--green) 12%, var(--surface)); }
.boundary-table input[type=checkbox] { width: 1.05rem; height: 1.05rem; }

/* Theme the reusable map to the brand palette. */
.coverage-map-host {
  --fpg-map-bg: var(--surface-2);
  --fpg-map-border: var(--border);
  --fpg-map-land: var(--border-strong);
  --fpg-map-highlight: var(--teal);
  --fpg-map-hover: var(--petrol);
  --fpg-map-credit: var(--ink-faint);
}

/* ---------- Blazor error UI ---------- */
.blazor-error-boundary {
  background: var(--red);
  padding: 1rem 1.25rem;
  color: var(--on-danger-bar);
  border-radius: var(--radius-sm);
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* Blazor moves focus to the page heading after each navigation (FocusOnNavigate) so screen readers announce
   the new page; that focus is programmatic (tabindex=-1), so it must not draw a highlight box for everyone. */
h1[tabindex="-1"]:focus, h1:focus:not(:focus-visible) { outline: none; } /* focus-on-navigate */
