/* CCA UI Profile v2 — layered on pinned GOV.UK Frontend 6.4.0.
   Palette and responsive boundaries follow the fleet profile. */

:root {
  color-scheme: light;
  --cca-blue: #1d70b8;
  --cca-blue-dark: #003078;
  --cca-green: #00703c;
  --cca-red: #d4351c;
  --cca-orange: #f47738;
  --cca-yellow: #ffdd00;
  --cca-ink: #0b0c0c;
  --cca-muted: #505a5f;
  --cca-border: #b1b4b6;
  --cca-bg: #f3f2f1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--cca-ink);
  background: #fff;
  font-family: "GDS Transport", arial, sans-serif;
  line-height: 1.55;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 15px;
}

a { color: var(--cca-blue); }
a:hover { color: var(--cca-blue-dark); }

a:focus,
button:focus,
input:focus,
select:focus {
  outline: 3px solid transparent;
  color: var(--cca-ink);
  background-color: var(--cca-yellow);
  box-shadow: 0 -2px var(--cca-yellow), 0 4px var(--cca-ink);
  text-decoration: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  padding: 10px 15px;
  background: var(--cca-yellow);
  color: var(--cca-ink);
  font-weight: 700;
}
.skip-link:focus {
  position: static;
  left: auto;
  display: block;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header and footer ------------------------------------------------------- */

.site-header {
  background: var(--cca-ink);
  border-bottom: 10px solid var(--cca-blue);
  padding: 10px 0;
}
.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand {
  display: flex;
  flex-direction: column;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.brand-organization { font-size: 0.85rem; opacity: 0.85; font-weight: 400; }
.brand-product { font-size: 1.25rem; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 15px; }
.site-header nav a { color: #fff; text-decoration: none; padding: 4px 0; }
.site-header nav a:hover { text-decoration: underline; }
.site-header nav a[aria-current="page"] {
  border-bottom: 3px solid var(--cca-blue);
  font-weight: 700;
}

.site-footer {
  margin-top: 50px;
  padding: 25px 0;
  border-top: 1px solid var(--cca-border);
  background: var(--cca-bg);
  color: var(--cca-muted);
  font-size: 0.95rem;
}
.site-footer nav { display: flex; flex-wrap: wrap; gap: 15px; margin-top: 10px; }

/* Content ----------------------------------------------------------------- */

main { padding: 30px 0 10px; }

h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 15px; }
.lead { font-size: 1.15rem; color: var(--cca-muted); margin: 0 0 20px; }
.section-heading {
  font-size: 1.4rem;
  margin: 35px 0 12px;
  padding-top: 15px;
  border-top: 2px solid var(--cca-blue);
}
.muted { color: var(--cca-muted); }

.breadcrumb { margin-bottom: 15px; color: var(--cca-muted); font-size: 0.95rem; }

.prose-list { padding-left: 20px; }
.prose-list li { margin-bottom: 8px; }

.notice {
  border-left: 5px solid var(--cca-blue);
  background: var(--cca-bg);
  padding: 15px 20px;
  margin: 20px 0;
}
.notice-warning { border-left-color: var(--cca-orange); }
.notice h2 { margin-top: 0; font-size: 1.15rem; }
.notice p:last-child { margin-bottom: 0; }

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

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: flex-end;
  margin: 20px 0 30px;
  padding: 20px;
  background: var(--cca-bg);
  border: 1px solid var(--cca-border);
}
.field { display: flex; flex-direction: column; flex: 1 1 260px; }
.field-narrow { flex: 0 1 200px; }
.field-wide { flex: 1 1 100%; }
.field label { font-weight: 700; margin-bottom: 5px; }
.field input,
.field select {
  padding: 8px 10px;
  border: 2px solid var(--cca-ink);
  font-size: 1rem;
  font-family: inherit;
}
.hint { color: var(--cca-muted); font-size: 0.9rem; margin: 5px 0 0; }

button[type="submit"] {
  background: var(--cca-green);
  border: 2px solid transparent;
  box-shadow: 0 2px 0 #002d18;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  padding: 9px 20px;
}
button[type="submit"]:hover { background: #005a30; }

/* Results ----------------------------------------------------------------- */

.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--cca-border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}
.tag {
  background: var(--cca-blue);
  color: #fff;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 2px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 15px;
  margin: 25px 0;
}
.stat {
  border: 1px solid var(--cca-border);
  border-top: 5px solid var(--cca-blue);
  padding: 15px;
  text-align: center;
}
.stat strong { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--cca-muted); font-size: 0.9rem; }

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
}
.data-table th,
.data-table td {
  border-bottom: 1px solid var(--cca-border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.data-table thead th {
  border-bottom: 2px solid var(--cca-ink);
  font-weight: 700;
}
.data-table tbody th { font-weight: 400; }
.comparison-table td { text-align: right; }
.comparison-table th[scope="col"]:not(:first-child) { text-align: right; }
.comparison-table .leader {
  font-weight: 700;
  background: rgba(0, 112, 60, 0.08);
}

/* Responsive boundaries match the fleet profile --------------------------- */

@media (max-width: 640px) {
  h1 { font-size: 1.7rem; }
  .site-header .container { flex-direction: column; align-items: flex-start; }
  .data-table,
  .data-table thead,
  .data-table tbody,
  .data-table tr,
  .data-table th,
  .data-table td { display: block; }
  .data-table thead { display: none; }
  .data-table tr {
    border-bottom: 2px solid var(--cca-ink);
    margin-bottom: 12px;
  }
  .data-table td { border-bottom: none; padding-top: 0; }
  .comparison-table td { text-align: left; }
}

@media (min-width: 641px) {
  main { padding-top: 40px; }
}

@media (min-width: 768px) {
  .container { padding: 0 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Operations dashboard ---------------------------------------------------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}
.badge-ok   { background: var(--cca-green); }
.badge-info { background: var(--cca-blue); }
.badge-warn { background: var(--cca-orange); color: var(--cca-ink); }
.badge-bad  { background: var(--cca-red); }

/* Scaled to D1's 10 GB hard cap so headroom is shown against the real limit. */
.capacity-bar {
  position: relative;
  height: 14px;
  margin-top: 6px;
  background: #e8e6e4;
  border: 1px solid var(--cca-border);
  overflow: hidden;
}
.capacity-fill { height: 100%; }
.fill-ok   { background: var(--cca-green); }
.fill-warn { background: var(--cca-orange); }
.fill-bad  { background: var(--cca-red); }
.capacity-mark {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--cca-ink);
}
.capacity-mark-hard { background: var(--cca-red); }

.reason {
  max-width: 320px;
  font-size: 0.9rem;
  color: var(--cca-muted);
  word-break: break-word;
}
