/* Palette mirrors joelberman.net's landing page (homelab-gateway/landing/
   styles.css) so this tool looks like it belongs on the same homelab —
   dark navy gradient, blurred glass cards, blue accent, Inter + JetBrains
   Mono. */
:root {
  color-scheme: dark;
  --bg-1: #060b14;
  --bg-2: #0b1324;
  --bg-3: #121a2e;

  --card: rgba(18, 25, 43, 0.62);
  --card-strong: rgba(16, 23, 38, 0.84);

  --text: #edf4ff;
  --text-soft: #c5d1e4;
  --muted: #8fa0b9;

  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent: #3a86ff;
  --accent-strong: #5b9bff;
  --on-accent: #ffffff;
  --accent-soft: rgba(58, 134, 255, 0.13);
  --accent-border: rgba(58, 134, 255, 0.28);
  --ring: rgba(58, 134, 255, 0.35);
  --link: #8fc1ff;

  --radius: 20px;
  --radius-sm: 12px;
  --max-width: 1400px;
  --mono: "JetBrains Mono", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: dark; /* the homepage this matches has no light variant */
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.45;
  background:
    radial-gradient(circle at 10% 14%, rgba(58, 134, 255, 0.16), transparent 24%),
    radial-gradient(circle at 84% 10%, rgba(58, 134, 255, 0.16), transparent 22%),
    radial-gradient(circle at 50% 100%, rgba(58, 134, 255, 0.08), transparent 26%),
    linear-gradient(140deg, var(--bg-1) 0%, var(--bg-2) 52%, var(--bg-3) 100%);
  background-attachment: fixed;
}

.page-shell { padding: 20px 16px 40px; }

.page {
  width: min(100%, var(--max-width));
  margin: 0 auto;
}

.hero {
  margin: 12px 8px 22px;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: #ffffff;
  text-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  text-transform: lowercase;
}

.hero h1 span { color: var(--accent); }

.hero-text {
  max-width: 42rem;
  margin: 10px 0 0;
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.55;
}

/* The search form is a single row of cards on wide screens, wrapping down
   to fewer columns as the viewport narrows. */
#search-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 1rem;
  margin: 0 8px;
}

fieldset {
  margin: 0;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012)),
    var(--card);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 10px 26px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  padding: 0.6rem 1rem 1rem;
}

legend {
  padding: 0 0.4rem;
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

label {
  display: block;
  margin: 0.6rem 0 0.3rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

input[type="text"],
input[type="date"],
input[type="number"] {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  font: inherit;
}

select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  font: inherit;
  padding: 0.15rem;
}

select option { padding: 0.25rem 0.4rem; background: var(--bg-2); }

/* A selected <option> in a multi-listbox page (start port, end port, via
   ports, results) must stay visibly highlighted even after focus moves to
   a different listbox — otherwise it looks like the selection was lost.
   The flat background above wins over the browser's native "selected but
   unfocused" shading, and Chromium in particular ignores a plain
   background-color on option:checked, so the linear-gradient trick is
   needed to force it through. */
select option:checked {
  background: linear-gradient(0deg, var(--accent-soft) 0%, var(--accent-soft) 100%);
  color: #ffffff;
  font-weight: 600;
}

input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 0.75rem;
}

.grid-2 > div { min-width: 0; }

.suggestions { margin-top: 0.3rem; font-size: 0.85rem; }

.hint { font-size: 0.76rem; color: var(--muted); margin: 0.5rem 0 0; }

.via-add-row { display: flex; gap: 0.5rem; }
.via-add-row input { flex: 1; }

button {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0)), var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
  margin-top: 0.5rem;
  box-shadow: 0 8px 24px rgba(58, 134, 255, 0.22);
}

button:hover { background: var(--accent-strong); transform: translateY(-2px); }
button:disabled { opacity: 0.65; cursor: wait; transform: none; }

button[type="button"] {
  background: rgba(255,255,255,0.04);
  color: var(--link);
  border-color: var(--border);
  box-shadow: none;
}

button[type="button"]:hover { background: var(--accent-soft); transform: none; }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
}

#search-button {
  min-width: 340px;
  padding: 0.75rem 1.5rem;
  font-size: 1.02rem;
}

/* --- results --- */
.results { margin: 1.75rem 8px 0; }

.results-placeholder {
  color: var(--muted);
  text-align: center;
  padding: 2rem 0;
}

.results-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  padding: 0.7rem 1rem;
  margin: 0 0 1rem;
}

.results-panel {
  display: grid;
  grid-template-columns: minmax(300px, 430px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .results-panel { grid-template-columns: 1fr; }
}

#results-list {
  background: var(--card);
  border-color: var(--border);
  font-size: 0.9rem;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
}

#results-list option {
  padding: 0.45rem 0.5rem;
  white-space: normal;
}

.detail-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.012)),
    var(--card);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), 0 10px 26px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  padding: 1rem 1.5rem;
}

.detail-pane h3 { margin: 0.25rem 0 0.5rem; color: #ffffff; }

.legs { padding-left: 1.25rem; margin: 0.5rem 0 0; }

.legs li { margin-bottom: 0.7rem; }

.legs li.layover {
  list-style: none;
  margin-left: -1.25rem;
  font-style: italic;
  color: var(--muted);
}

.legs a {
  color: var(--link);
  word-break: break-all;
  font-size: 0.85rem;
}

.portcalls {
  margin: 0.35rem 0 0.15rem;
  font-size: 0.85rem;
}

.portcalls summary {
  cursor: pointer;
  color: var(--link);
}

.portcalls ul {
  margin: 0.3rem 0 0.2rem;
  padding-left: 1.15rem;
}

.portcalls li {
  margin-bottom: 0.15rem;
  list-style: disc;
}

.source-link {
  font-size: 0.8rem;
  word-break: normal;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: #ffd9b0;
  background: rgb(217 130 43 / 0.16);
  border: 1px solid rgb(217 130 43 / 0.45);
  border-radius: 5px;
  padding: 0.05rem 0.45rem;
  margin-left: 0.3rem;
  vertical-align: 1px;
}

.note { font-style: italic; color: var(--muted); }

.banner {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin: 0 8px 1rem;
}

.banner-error {
  color: #ffd7d2;
  background: rgb(217 68 53 / 0.14);
  border: 1px solid rgb(217 68 53 / 0.45);
}

@media (max-width: 640px) {
  .page-shell { padding: 14px 10px 24px; }
  .hero { margin: 8px 4px 16px; }
  #search-form, .results { margin-left: 0; margin-right: 0; }
  .banner { margin-left: 0; margin-right: 0; }
}
