/* ═══════════════════════════════════════════════════════════
   MERIDIAN — Shipment Tracker
   Design language: warm parchment · deep navy · gold accent
═══════════════════════════════════════════════════════════ */

/* ── Custom Properties ──────────────────────────────────── */
:root {
  --bg:           #F4F1EB;
  --bg-alt:       #EDE9E0;
  --surface:      #FFFFFF;
  --surface-dim:  #FAF8F4;
  --border:       #E2DDD3;
  --border-light: #EDE9E1;

  --navy:         #1B3252;
  --navy-mid:     #254573;
  --navy-light:   #EBF0F8;

  --gold:         #A87830;
  --gold-light:   #F5E8CF;

  --text-1:       #1A1714;
  --text-2:       #6B6460;
  --text-3:       #A09894;

  --status-transit:    #1B3252;
  --status-delivered:  #1A5C3A;
  --status-exception:  #8B1C1C;
  --status-pickup:     #7C4A00;
  --status-pending:    #5A5450;
  --status-outfor:     #1D5F6B;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05);
  --shadow-lg:  0 12px 32px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);

  --header-h:   60px;
  --max-w:      1100px;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans:  'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

/* ── Header ─────────────────────────────────────────────── */
#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(244, 241, 235, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.wordmark-symbol {
  color: var(--gold);
  font-size: 18px;
  line-height: 1;
}
.wordmark-text {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -.3px;
}

/* Header inline search */
.header-search { flex: 1; max-width: 420px; margin-left: 40px; }
.search-form-inline { display: flex; align-items: center; gap: 0; }
.search-input-inline {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  background: var(--surface);
  padding: 0 14px;
  font-size: 13.5px;
  color: var(--text-1);
  outline: none;
  transition: border-color .15s;
  font-family: var(--font-sans);
  letter-spacing: .3px;
}
.search-input-inline:focus { border-color: var(--navy-mid); }
.search-btn-inline {
  height: 36px;
  width: 38px;
  background: var(--navy);
  border: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.search-btn-inline:hover { background: var(--navy-mid); }

/* ── Main / Views ───────────────────────────────────────── */
#app { flex: 1; }
.view { min-height: calc(100vh - var(--header-h) - 52px); }

/* ── Landing ────────────────────────────────────────────── */
#view-landing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 80px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(27,50,82,.055) 0%, transparent 70%),
    var(--bg);
}
.landing-content {
  max-width: 600px;
  width: 100%;
  text-align: center;
}
.landing-eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 18px;
}
.landing-title {
  font-family: var(--font-serif);
  font-size: clamp(32px, 5vw, 50px);
  font-weight: 600;
  color: var(--navy);
  line-height: 1.15;
  letter-spacing: -.5px;
  margin-bottom: 18px;
}
.landing-sub {
  font-size: 13.5px;
  color: var(--text-2);
  margin-bottom: 40px;
  letter-spacing: .1px;
}

/* Hero search */
.search-form-hero { width: 100%; }
.search-wrap {
  display: flex;
  height: 54px;
  box-shadow: var(--shadow-lg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.search-input-hero {
  flex: 1;
  border: none;
  outline: none;
  padding: 0 22px;
  font-size: 15px;
  color: var(--text-1);
  background: transparent;
  letter-spacing: .4px;
}
.search-input-hero::placeholder { color: var(--text-3); }
.search-btn-hero {
  height: 100%;
  padding: 0 28px;
  background: var(--navy);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-sans);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .15s;
  border-radius: 0 10px 10px 0;
  margin: 1px 1px 1px 0;
}
.search-btn-hero:hover { background: var(--navy-mid); }

/* Recent searches */
.recent-searches {
  margin-top: 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.recent-chip {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  letter-spacing: .3px;
}
.recent-chip:hover {
  border-color: var(--navy);
  color: var(--navy);
  background: var(--navy-light);
}

/* ── Loading ────────────────────────────────────────────── */
#view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-wrap { text-align: center; }
.loader-ring {
  width: 40px;
  height: 40px;
  border: 2.5px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text {
  font-size: 14px;
  color: var(--text-2);
  letter-spacing: .3px;
}

/* ── Error ──────────────────────────────────────────────── */
#view-error {
  display: flex;
  align-items: center;
  justify-content: center;
}
.error-wrap { text-align: center; max-width: 420px; padding: 24px; }
.error-icon {
  font-size: 48px;
  color: var(--text-3);
  margin-bottom: 16px;
  line-height: 1;
}
.error-title {
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--navy);
  margin-bottom: 10px;
}
.error-msg { font-size: 14.5px; color: var(--text-2); margin-bottom: 28px; line-height: 1.6; }
.btn-back {
  padding: 10px 22px;
  background: transparent;
  border: 1px solid var(--navy);
  border-radius: var(--radius-sm);
  color: var(--navy);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
}
.btn-back:hover { background: var(--navy); color: #fff; }

/* ── Result ─────────────────────────────────────────────── */
#view-result { min-height: unset; }

/* Status bar */
.status-bar {
  max-width: var(--max-w);
  margin: 32px auto 0;
  padding: 22px 32px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  box-shadow: var(--shadow-sm);
}
.status-bar-left { display: flex; flex-direction: column; gap: 10px; }
.tracking-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tracking-number-display {
  font-family: 'Courier New', monospace;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-1);
}
.carrier-pill {
  padding: 3px 10px;
  background: var(--navy-light);
  color: var(--navy);
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
}

/* Status badge */
.status-badge {
  display: inline-block;
  padding: 5px 13px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .9px;
  text-transform: uppercase;
}
.status-badge.transit    { background: var(--navy-light); color: var(--status-transit); }
.status-badge.delivered  { background: #E6F4EC; color: var(--status-delivered); }
.status-badge.exception  { background: #FCE8E8; color: var(--status-exception); }
.status-badge.outfor     { background: #E3F4F6; color: var(--status-outfor); }
.status-badge.pickup     { background: var(--gold-light); color: var(--status-pickup); }
.status-badge.pending    { background: var(--bg-alt); color: var(--status-pending); }

/* ETA block */
.status-bar-right { text-align: right; flex-shrink: 0; }
.eta-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 4px;
}
.eta-date {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--navy);
  white-space: nowrap;
}
.eta-location {
  font-size: 12.5px;
  color: var(--text-2);
  margin-top: 3px;
}

/* ── Map ────────────────────────────────────────────────── */
.map-container {
  max-width: var(--max-w);
  margin: 20px auto 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
}
#map { height: 380px; }

/* Leaflet overrides */
.leaflet-container { background: #EEE9DF !important; }
.leaflet-control-attribution { font-size: 10px !important; }
.leaflet-control-zoom a {
  color: var(--navy) !important;
  border-color: var(--border) !important;
}

/* Custom marker */
.map-marker-current {
  width: 16px; height: 16px;
  background: var(--navy);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.map-marker-origin {
  width: 12px; height: 12px;
  background: var(--gold);
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.map-marker-dest {
  width: 12px; height: 12px;
  background: var(--status-delivered);
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}

.map-overlay-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(244,241,235,.85));
  padding: 20px 20px 14px;
  pointer-events: none;
  font-size: 12px;
  color: var(--text-2);
  letter-spacing: .2px;
}

/* ── Result Body ────────────────────────────────────────── */
.result-body {
  max-width: var(--max-w);
  margin: 24px auto 48px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 20px;
}

/* ── Timeline ───────────────────────────────────────────── */
.timeline-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
}

.timeline { position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 10px; bottom: 10px;
  width: 1px;
  background: var(--border);
}

.timeline-event {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 0 18px;
  padding: 0 0 28px;
  position: relative;
}
.timeline-event:last-child { padding-bottom: 0; }

.timeline-dot {
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  margin-top: 3px;
  flex-shrink: 0;
  z-index: 1;
  position: relative;
  transition: all .2s;
}
.timeline-event.latest .timeline-dot {
  background: var(--navy);
  border-color: var(--navy);
  box-shadow: 0 0 0 4px var(--navy-light);
}

.timeline-content {}
.timeline-time {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: .4px;
  margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}
.timeline-message {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-1);
  margin-bottom: 2px;
  line-height: 1.45;
}
.timeline-location {
  font-size: 12.5px;
  color: var(--text-2);
}

/* ── Details Sidebar ────────────────────────────────────── */
.details-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}
.detail-row:first-child { padding-top: 0; }
.detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.detail-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--text-3);
}
.detail-value {
  font-size: 14px;
  color: var(--text-1);
  font-weight: 500;
}
.detail-value.mono {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  letter-spacing: .8px;
}

.refresh-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.refresh-note {
  font-size: 11.5px;
  color: var(--text-3);
}
.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-2);
  font-family: var(--font-sans);
  transition: all .15s;
}
.btn-refresh:hover {
  border-color: var(--navy);
  color: var(--navy);
  background: var(--navy-light);
}

/* ── Footer ─────────────────────────────────────────────── */
#site-footer {
  border-top: 1px solid var(--border);
  padding: 14px 32px;
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 10px;
  align-items: center;
}
.footer-sep { opacity: .4; }

/* ── No API Key banner ──────────────────────────────────── */
.api-notice {
  max-width: var(--max-w);
  margin: 24px auto 0;
  padding: 16px 22px;
  background: var(--gold-light);
  border: 1px solid #E5C87A;
  border-radius: var(--radius);
  font-size: 13.5px;
  color: #7C4A00;
  line-height: 1.6;
}
.api-notice code {
  background: rgba(0,0,0,.08);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12.5px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 780px) {
  #site-header { padding: 0 18px; }
  .status-bar {
    margin: 16px 16px 0;
    padding: 18px 18px 16px;
    flex-direction: column;
    gap: 14px;
  }
  .status-bar-right { text-align: left; }
  .map-container { margin: 16px 16px 0; border-radius: var(--radius); }
  #map { height: 280px; }
  .result-body {
    grid-template-columns: 1fr;
    margin: 16px 16px 32px;
    gap: 16px;
  }
  .timeline-section { padding: 20px 18px; }
  .detail-card { padding: 18px; }
}
@media (max-width: 520px) {
  .landing-content { padding: 0 8px; }
  .search-btn-hero { padding: 0 20px; }
  #site-header { padding: 0 14px; }
  .wordmark-text { font-size: 17px; }
}
