/* CRS.Codes — custom design, no GOV.UK Frontend */

:root {
  --c-bg: #f4f5f7;
  --c-surface: #ffffff;
  --c-border: #d0d3db;
  --c-border-light: #e5e7eb;
  --c-text: #1a1a1a;
  --c-text-secondary: #5c5f6a;
  --c-accent: #e9640a;
  --c-accent-dark: #c2510a;
  --c-navy: #1a1f35;
  --c-navy-hover: #252c47;
  --c-link: #1856b4;
  --c-link-hover: #0e3d8a;
  --c-success: #0a7c42;
  --c-warning: #c45400;
  --c-danger: #b91c1c;
  --c-tag-bg: #eef0f5;
  --c-tag-text: #3a3d4a;
  --c-crs-bg: #dbeafe;
  --c-crs-text: #1e40af;
  --c-tiploc-bg: #fef3c7;
  --c-tiploc-text: #92400e;
  --c-rtt-bg: #dcfce7;
  --c-rtt-text: #14532d;
  --c-tiger-bg: #ffe4e1;
  --c-tiger-text: #7f1d1d;
  --c-depot-bg: #f3f4f6;
  --c-depot-text: #374151;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

a { color: var(--c-link); text-decoration: underline; }
a:hover { color: var(--c-link-hover); }

/* Skip link */
.skip-link {
  position: absolute;
  top: -9999px;
  left: 0;
  background: var(--c-accent);
  color: #fff;
  padding: .5rem 1rem;
  font-weight: 600;
  z-index: 9999;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { top: 0; }

/* ---- Header ---- */
.site-header {
  background: var(--c-navy);
  color: #fff;
  border-bottom: 3px solid var(--c-accent);
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.site-logo span { color: var(--c-accent); }
.site-logo:hover { color: #f0f0f0; }

.site-nav {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  display: block;
  padding: .35rem .7rem;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.site-nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

/* ---- Main wrapper ---- */
.page-wrapper {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.25rem;
}

/* ---- Footer ---- */
.site-footer {
  background: var(--c-navy);
  color: rgba(255,255,255,.65);
  font-size: .85rem;
  padding: 1.25rem;
  text-align: center;
  margin-top: auto;
  border-top: 2px solid rgba(255,255,255,.05);
}
.site-footer strong { color: rgba(255,255,255,.85); }

/* ---- Typography ---- */
h1, h2, h3, h4 {
  margin: 0 0 .75rem;
  line-height: 1.25;
  font-weight: 700;
}
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

ul, ol { margin: 0 0 1rem; padding-left: 1.5rem; }
li { margin-bottom: .25rem; }

/* ---- Forms ---- */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: .4rem;
  font-size: .95rem;
}

.hint {
  color: var(--c-text-secondary);
  font-size: .875rem;
  margin-bottom: .4rem;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="search"] {
  display: block;
  width: 100%;
  padding: .6rem .8rem;
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--c-surface);
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="email"]:focus,
input[type="search"]:focus {
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(233,100,10,.15);
}

/* Checkboxes */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.5rem;
  margin-top: .5rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  cursor: pointer;
  font-size: .95rem;
}

.checkbox-item input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--c-accent);
  cursor: pointer;
}

.fieldset-legend {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .5rem;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--c-accent);
  color: #fff;
}
.btn-primary:hover { background: var(--c-accent-dark); color: #fff; }

.btn-secondary {
  background: var(--c-tag-bg);
  color: var(--c-text);
}
.btn-secondary:hover { background: var(--c-border); }

.btn-danger {
  background: var(--c-danger);
  color: #fff;
}
.btn-danger:hover { background: #991b1b; color: #fff; }

/* ---- Pills / Tags ---- */
.pill {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  line-height: 1.4;
  text-decoration: none;
  border: none;
  cursor: default;
  font-family: inherit;
}

.pill-crs {
  background: var(--c-crs-bg);
  color: var(--c-crs-text);
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, monospace;
}
.pill-tiploc {
  background: var(--c-tiploc-bg);
  color: var(--c-tiploc-text);
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, monospace;
}
.pill-rtt {
  background: var(--c-rtt-bg);
  color: var(--c-rtt-text);
  cursor: pointer;
}
a.pill-rtt:hover { background: #bbf7d0; color: var(--c-rtt-text); text-decoration: none; }

.pill-tiger {
  background: var(--c-tiger-bg);
  color: var(--c-tiger-text);
  cursor: pointer;
}
a.pill-tiger:hover, button.pill-tiger:hover { background: #fecaca; text-decoration: none; }

.pill-airport {
  background: #e0e7ff;
  color: #3730a3;
  cursor: pointer;
}
a.pill-airport:hover { background: #c7d2fe; text-decoration: none; }

.pill-depot {
  background: var(--c-depot-bg);
  color: var(--c-depot-text);
}
.pill-sidings {
  background: #f0fdf4;
  color: #166534;
}
.pill-default {
  background: var(--c-tag-bg);
  color: var(--c-tag-text);
}

button.pill {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.pillbar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
}

/* ---- Result count ---- */
.result-count {
  color: var(--c-text-secondary);
  font-size: .875rem;
  margin-top: .4rem;
  min-height: 1.4em;
}

/* ---- Station list ---- */
.station-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.station-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: .45rem;
}

.station-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.station-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--c-text);
  text-decoration: none;
}
.station-name:hover { color: var(--c-accent); text-decoration: underline; }
a.station-name { cursor: pointer; }

.station-hint {
  color: var(--c-text-secondary);
  font-size: .9rem;
  padding: .75rem 1rem;
}

/* ---- Station detail page ---- */
.station-detail-header {
  margin-bottom: 1.25rem;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
  margin-top: 1.25rem;
}
.summary-table th,
.summary-table td {
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--c-border-light);
  text-align: left;
  vertical-align: top;
}
.summary-table th {
  width: 35%;
  font-weight: 600;
  color: var(--c-text-secondary);
  background: var(--c-bg);
}
.summary-table tr:last-child th,
.summary-table tr:last-child td {
  border-bottom: none;
}
.summary-table tbody tr:hover td,
.summary-table tbody tr:hover th {
  background: #fafafa;
}

/* ---- Cards (TOCs, Performance) ---- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .85rem 1.1rem;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border-light);
  flex-wrap: wrap;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
}

.card-body {
  padding: .85rem 1.1rem;
}

/* TOC grid */
.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: .75rem;
}

/* ---- Status tags ---- */
.status-tag {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 4px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-green  { background: #dcfce7; color: #14532d; }
.status-orange { background: #ffedd5; color: #7c2d12; }
.status-red    { background: #fee2e2; color: #7f1d1d; }
.status-grey   { background: var(--c-tag-bg); color: var(--c-tag-text); }
.status-blue   { background: var(--c-crs-bg); color: var(--c-crs-text); }

/* ---- Inset / warning ---- */
.inset {
  border-left: 4px solid var(--c-border);
  background: var(--c-bg);
  padding: .75rem 1rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1rem;
  font-size: .95rem;
}

.warning-box {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  font-size: .95rem;
  color: #7c2d12;
}
.warning-box .warning-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
}

.danger-box {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  font-size: .95rem;
  color: #7f1d1d;
}
.danger-box .warning-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
}

/* ---- Admin UI ---- */
.admin-nav {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--c-border-light);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}
.data-table th {
  text-align: left;
  padding: .6rem .85rem;
  background: var(--c-bg);
  border-bottom: 2px solid var(--c-border);
  font-weight: 700;
  color: var(--c-text-secondary);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--c-border-light);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #fafafa; }

.code-mono {
  font-family: ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, monospace;
  font-size: .875rem;
}

/* ---- Popover (Tiger menu) ---- */
.app-popover {
  position: fixed;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  min-width: 220px;
  max-width: 280px;
  overflow: hidden;
}

.app-popover__title {
  padding: .6rem .85rem;
  font-size: .8rem;
  font-weight: 700;
  color: var(--c-text-secondary);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border-light);
  text-transform: uppercase;
  letter-spacing: .03em;
}

.app-popover__list {
  list-style: none;
  padding: .35rem 0;
  margin: 0;
}

.app-popover__list li a {
  display: block;
  padding: .45rem .85rem;
  color: var(--c-link);
  text-decoration: none;
  font-size: .9rem;
  transition: background .1s;
}
.app-popover__list li a:hover {
  background: var(--c-bg);
  color: var(--c-link-hover);
}

/* ---- Util ---- */
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-secondary { color: var(--c-text-secondary); }
.text-sm { font-size: .875rem; }
.two-thirds { max-width: 700px; }

/* ---- Taxi calculator ---- */
.taxi-result-card {
  margin-top: 1.25rem;
  padding: 1.1rem 1.25rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 6px;
}

.taxi-route {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: .85rem;
}

.taxi-times {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.taxi-time {
  padding: .7rem .9rem;
  border: 1px solid var(--c-border);
  border-radius: 5px;
  background: var(--c-bg);
}

.taxi-time--active {
  border-color: var(--c-link);
  background: color-mix(in srgb, var(--c-link) 8%, var(--c-bg));
}

.taxi-time__label {
  display: block;
  font-size: .8rem;
  color: var(--c-text-secondary);
  margin-bottom: .2rem;
}

.taxi-time__window {
  font-size: .75rem;
}

.taxi-time__value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
}

.taxi-notes {
  margin: .85rem 0 0;
  padding: 0 0 0 1.1rem;
  font-size: .85rem;
  color: var(--c-text-secondary);
}

.taxi-notes li { margin-bottom: .3rem; }
.taxi-notes strong { color: var(--c-text); }

/* ---- Depot/station rules ---- */
.depot-card {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 6px;
}

.depot-card__name {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 .6rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--c-border-light);
}

.depot-card__lines {
  list-style: none;
  margin: 0;
  padding: 0;
}

.depot-card__lines li {
  padding: .25rem 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--c-border-light);
}

.depot-card__lines li:last-child {
  border-bottom: none;
}

.depot-card__lines mark {
  background: #fef08a;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .header-inner { gap: .75rem; }
  .site-logo { font-size: 1.1rem; }
  .page-wrapper { padding: 1.25rem .875rem; }
  .summary-table th { width: 40%; }
  .toc-grid { grid-template-columns: 1fr; }
}
