/* AirportInfo — single hand-written stylesheet, no framework. */

:root {
  --ink: #1a2330;
  --muted: #5b6878;
  --line: #d8dee7;
  --bg: #f6f8fa;
  --card: #ffffff;
  --accent: #0b5fa5;
  --accent-ink: #ffffff;
  --warn-bg: #fff7e0;
  --warn-line: #e3c15a;
  --gap-bg: #fdeeee;
  --gap-line: #d99;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

main {
  max-width: 96rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.site-header {
  background: var(--ink);
  color: #fff;
  padding: 0.8rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.tagline { color: #aab6c5; font-size: 0.85rem; }

.site-footer {
  max-width: 96rem;
  margin: 0 auto;
  padding: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--line);
}

a { color: var(--accent); }

h1 { font-size: 1.5rem; margin: 0.5rem 0 0.25rem; }
h2 { font-size: 1rem; margin: 0 0 0.5rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Forms */
.search { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.search input[type="search"] { flex: 2 1 16rem; }
.search select { flex: 1 1 10rem; }

/* Admin: create-key form (label + expiry controls on one wrapping row). */
.key-create-form { display: flex; gap: 0.6rem 1rem; flex-wrap: wrap; align-items: center; margin: 1rem 0 0.5rem; }
.key-create-form input[type="text"] { flex: 2 1 16rem; }
.expiry-choice { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; }
.expiry-choice label { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 0.9rem; }
.expiry-choice input[type="number"] { width: 4rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }

input, select, button {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
}
button {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
/* Search results column sizing (scoped so admin tables are untouched). Columns:
   1 Code, 2 ICAO, 3 IATA, 4 Name, 5 City, 6 Country, 7 Timezone. The code columns
   (Code/ICAO/IATA) stay narrow at their default nowrap width. Name (col 4): the
   most-read column — give it room so names wrap to one or two lines instead of
   three-plus. City (col 5): allow wrapping with some room. Country (col 6): cap
   the width so a long name wraps to an extra line rather than stretching the
   table; ~18rem fits "Congo, Democratic Republic of the" on a single line. */
.results th:nth-child(4), .results td:nth-child(4) { white-space: normal; min-width: 20rem; }
.results th:nth-child(5), .results td:nth-child(5) { white-space: normal; min-width: 9rem; }
.results th:nth-child(6), .results td:nth-child(6) { white-space: normal; max-width: 18rem; }
th { background: var(--bg); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: none; }

/* Dim the results briefly while a search-as-you-type fetch is in flight. */
#search-results[aria-busy="true"] { opacity: 0.55; transition: opacity 0.1s ease-in; }

.result-count { color: var(--muted); }
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; }
.pager span { color: var(--muted); }

/* Detail page */
.crumbs { margin-top: 1rem; font-size: 0.9rem; }
.codes { margin: 0 0 1rem; }
.code {
  display: inline-block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  margin-right: 0.5rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9rem;
}

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.clock { font-size: 2rem; font-family: ui-monospace, "SF Mono", Menlo, monospace; margin: 0.25rem 0; }
.clock-meta { color: var(--muted); margin: 0; font-size: 0.9rem; }

dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0; }
dt { color: var(--muted); }
dd { margin: 0; }

/* Sun & civil-twilight card */
.sun-date { color: var(--muted); margin: 0 0 0.6rem; font-size: 0.9rem; }
.sun-times dd { font-variant-numeric: tabular-nums; }
.sun-utc { color: var(--muted); font-size: 0.85rem; margin-left: 0.35rem; }
.sun-note { color: var(--muted); margin: 0.6rem 0 0; font-size: 0.9rem; }
.resolved-solar { margin-top: 1.25rem; }
.resolved-solar h3 { margin: 0 0 0.15rem; font-size: 1rem; }

.timetool-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.timetool-row .field { display: grid; gap: 0.2rem; }
.field-label { font-size: 0.8rem; color: var(--muted); }
.help-link { text-decoration: none; font-weight: 700; }

/* Time-tool explainer */
.tz-help p { max-width: 46rem; }
.tz-help ul { max-width: 46rem; margin: 0.5rem 0; padding-left: 1.2rem; }
.tz-help ul li { margin: 0.35rem 0; }
.tz-help-list { grid-template-columns: max-content 1fr; gap: 0.5rem 1rem; margin: 0.75rem 0; align-items: baseline; }
.tz-help-list dt { color: var(--ink); font-weight: 700; }
.tz-help-list dd { max-width: 40rem; }
.tz-help-tag {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.02rem 0.3rem;
  vertical-align: middle;
}
.tz-help-note { color: var(--muted); font-size: 0.9rem; }

/* API key request form */
.key-request-form { display: grid; gap: 0.9rem; max-width: 34rem; }
.key-request-form textarea {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  resize: vertical;
}
.key-request-form button { justify-self: start; }
.opt { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
/* Honeypot: kept in the DOM for bots but off-screen for people. */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Notices for gap/fold resolutions */
.notice { border: 1px solid var(--line); border-radius: 6px; padding: 0.75rem 1rem; margin: 1rem 0; }
.notice-fold { background: var(--warn-bg); border-color: var(--warn-line); }
.notice-gap { background: var(--gap-bg); border-color: var(--gap-line); }
.notice-error { background: var(--gap-bg); border-color: var(--gap-line); }

.resolved { margin-top: 1rem; }

.intro { color: var(--muted); max-width: 40rem; }

/* Landing / API guide */
h3 { font-size: 0.95rem; margin: 1.5rem 0 0.4rem; }
.landing h1 { margin-top: 0.25rem; }
.lead { color: var(--muted); max-width: 46rem; font-size: 1.05rem; margin: 0 0 1.5rem; }

.api-card h3:first-of-type { margin-top: 0.5rem; }
/* Let paragraphs fill the card (which already sits in the readable main column)
   rather than wrapping in a narrower 46rem sub-column. */
.api-card p { max-width: none; }
.api-card p code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.02rem 0.28rem;
}
.api-card .url { word-break: break-all; }

.endpoint-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.8rem; }
.endpoint {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
}
.method { color: var(--accent); font-weight: 700; }
.ep-desc { display: block; color: var(--muted); font-size: 0.9rem; margin-top: 0.3rem; }

.code-block {
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  padding: 0.7rem 0.9rem;
  margin: 0.4rem 0 0;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  white-space: pre;
}

/* Collapsible per-endpoint examples under "Try it". */
.examples { margin: 0.5rem 0 0; }
.examples > summary {
  cursor: pointer;
  width: fit-content;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.2rem 0;
}
.examples[open] > summary { margin-bottom: 0.4rem; }
.example { margin-top: 0.8rem; }
.example-label { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.25rem; }
.example-label code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.9em;
}

/* Admin */
.admin-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  margin: 1rem 0;
}
.admin-nav form { margin-left: auto; }

.inline { display: inline; }
.linklike {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 0;
  cursor: pointer;
}
.linklike.danger { color: #b23; }
.danger-button { background: #b23; border-color: #b23; }

.button-link {
  display: inline-block;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  text-decoration: none;
}

.bignum { font-size: 2.2rem; font-weight: 700; margin: 0; }

.login-form { display: grid; gap: 0.75rem; max-width: 22rem; }
.login-form label { display: grid; gap: 0.25rem; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.75rem; }
.form-grid label { display: grid; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); }
.form-grid input { color: var(--ink); }
.form-grid input[readonly] { background: var(--bg); }

.notice-ok { background: #eaf6ec; border-color: #9c9; }
.token-reveal .token {
  display: block;
  margin: 0.5rem 0;
  padding: 0.5rem;
  background: var(--ink);
  color: #fff;
  border-radius: 6px;
  font-size: 1rem;
  overflow-x: auto;
}
.row-actions { display: flex; gap: 0.5rem; }
.codes-list { line-height: 1.9; }

/* Usage settings form */
.settings-form { display: grid; gap: 1rem; max-width: 32rem; }
.settings-form .field { display: grid; gap: 0.2rem; }
.settings-form input { color: var(--ink); }

/* Abuse flag on the API-keys list */
.badge-flag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  background: #b23;
  border-radius: 4px;
  padding: 0.02rem 0.35rem;
  vertical-align: middle;
}
