@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@300;400;600;700&family=Source+Serif+4:wght@400;600&display=swap');

/* ── TOKENS ── */
:root {
  --uw-purple:      #32006e;
  --uw-purple-mid:  #543481;
  --uw-purple-light:#9663a8;
  --uw-purple-pale: #d6c8e1;
  --uw-gold:        #FFC700;
  --uw-gold-light:  #fff4cc;
  --uw-teal:        #008895;
  --uw-blue:        #2C6ACE;
  --uw-gray-dark:   #333347;
  --uw-gray-mid:    #566069;
  --uw-gray-light:  #a6acb1;
  --uw-gray-pale:   #d1d4d7;
  --uw-gray-bg:     #f4f5f6;
  --uw-white:       #ffffff;
  --uw-red:         #D24310;
  --gradient:       linear-gradient(135deg, #76236C 0%, #32006e 75%);

  /* Base font size — all rem values scale from here */
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Source Sans 3', Arial, sans-serif;
  font-size: 1rem; /* 16px */
  background: var(--uw-gray-bg);
  color: var(--uw-gray-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

/* ── HEADER ── */
header {
  background: var(--gradient);
  color: white;
  padding: 0;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: white;
}
.logo-text {
  display: flex;
  flex-direction: column;
}
.logo-title {
  font-size: 1.375rem; /* 22px */
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.1;
}
.logo-subtitle {
  font-size: 0.625rem; /* 10px — decorative, not content */
  font-weight: 400;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: 0.85;
}
.logo-divider {
  width: 1px;
  height: 36px;
  background: rgba(255,255,255,0.35);
}
.logo-app-name {
  font-size: 0.875rem; /* 14px */
  font-weight: 300;
  letter-spacing: 0.5px;
  opacity: 0.9;
}

/* Site selector in header */
.site-selector-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-selector-header label {
  font-size: 0.875rem; /* 14px */
  opacity: 0.85;
  white-space: nowrap;
}
.site-select {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  padding: 6px 28px 6px 10px;
  border-radius: 4px;
  font-size: 0.875rem; /* 14px */
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: background-color 0.2s;
}
.site-select:hover  { background-color: rgba(255,255,255,0.25); }
.site-select option { background: var(--uw-purple); color: white; }

/* ── DOWNTIME BANNER ── */
.downtime-banner {
  background: var(--uw-gold);
  color: var(--uw-gray-dark);
  text-align: center;
  padding: 8px 16px;
  font-size: 0.875rem; /* 14px */
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.downtime-banner svg { flex-shrink: 0; }

/* ── MAIN ── */
main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  padding: 32px 24px;
}

/* ── GATE OVERLAY ── */
#gate-overlay {
  position: fixed;
  inset: 0;
  background: rgba(50, 0, 110, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.gate-card {
  background: white;
  border-radius: 10px;
  padding: 44px 40px;
  max-width: 460px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.gate-logo {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.gate-logo-title {
  font-size: 1.625rem; /* 26px */
  font-weight: 700;
  color: var(--uw-purple);
  letter-spacing: -0.3px;
}
.gate-logo-sub {
  font-size: 0.625rem; /* 10px — decorative */
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--uw-gray-mid);
  font-weight: 400;
}
.gate-divider {
  width: 48px;
  height: 3px;
  background: var(--uw-gold);
  margin: 18px auto;
  border-radius: 2px;
}
.gate-card h2 {
  font-size: 1.25rem; /* 20px */
  font-weight: 700;
  color: var(--uw-purple);
  margin-bottom: 8px;
}
.gate-card p {
  font-size: 0.9375rem; /* 15px */
  color: var(--uw-gray-mid);
  margin-bottom: 28px;
  line-height: 1.6;
}
.gate-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gate-option {
  border: 2px solid var(--uw-gray-pale);
  background: white;
  border-radius: 7px;
  padding: 14px 20px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.18s;
  font-family: inherit;
}
.gate-option:hover          { border-color: var(--uw-purple); background: #f7f3fc; }
.gate-option.selected       { border-color: var(--uw-purple); background: #f0eaf8; }
.gate-option-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--uw-gray-pale);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.18s;
}
.gate-option.selected .gate-option-dot {
  border-color: var(--uw-purple);
  background: var(--uw-purple);
}
.gate-option.selected .gate-option-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: white;
}
.gate-option-info { flex: 1; }
.gate-option-name {
  font-size: 1rem; /* 16px */
  font-weight: 700;
  color: var(--uw-gray-dark);
}
.gate-option-code {
  font-size: 0.8125rem; /* 13px — secondary metadata */
  color: var(--uw-gray-mid);
  margin-top: 2px;
}
.gate-btn {
  margin-top: 24px;
  width: 100%;
  padding: 13px;
  background: var(--uw-purple);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem; /* 16px */
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.2px;
}
.gate-btn:hover:not(:disabled) { background: #4a0090; }
.gate-btn:disabled              { opacity: 0.45; cursor: not-allowed; }

/* ── SEARCH ── */
.search-section { margin-bottom: 28px; }
.search-label {
  font-size: 0.8125rem; /* 13px — uppercase label, decorative role */
  font-weight: 700;
  color: var(--uw-gray-mid);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  display: block;
}
.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 16px;
  color: var(--uw-gray-light);
  pointer-events: none;
  display: flex;
}
.search-input {
  width: 100%;
  padding: 15px 48px 15px 48px;
  border: 2px solid var(--uw-gray-pale);
  border-radius: 8px;
  font-size: 1rem; /* 16px */
  font-family: inherit;
  color: var(--uw-gray-dark);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.search-input:focus {
  border-color: var(--uw-purple);
  box-shadow: 0 0 0 3px rgba(50,0,110,0.1);
}
.search-clear {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--uw-gray-light);
  display: none;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s;
}
.search-clear:hover    { color: var(--uw-gray-dark); }
.search-clear.visible  { display: flex; }

/* ── SITE BADGE ── */
.site-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--uw-purple);
  color: white;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.875rem; /* 14px */
  font-weight: 600;
  margin-bottom: 20px;
}

/* ── RESULTS ── */
.results-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.results-count {
  font-size: 0.9375rem; /* 15px */
  color: var(--uw-gray-mid);
}
.results-count strong { color: var(--uw-gray-dark); }

.result-card {
  background: white;
  border: 1px solid var(--uw-gray-pale);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.result-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.09); }

.result-card-header {
  padding: 16px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-bottom: 1px solid var(--uw-gray-bg);
}
.result-type-badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem; /* 12px — intentionally small pill label */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.badge-fp   { background: #e8f4e8; color: #1a6b1a; border: 1px solid #b8ddb8; }
.badge-fifo { background: #e8f0fc; color: #1a4a8a; border: 1px solid #b8cef0; }
.badge-home { background: #fff3e0; color: #8a4a00; border: 1px solid #f0d0a0; }

.result-title { flex: 1; }
.result-item-desc {
  font-size: 1.0625rem; /* 17px */
  font-weight: 700;
  color: var(--uw-gray-dark);
  line-height: 1.3;
  margin-bottom: 3px;
}
.result-item-num {
  font-size: 0.875rem; /* 14px */
  color: var(--uw-gray-mid);
}

.result-card-body {
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px 24px;
}
.result-field label {
  display: block;
  font-size: 0.6875rem; /* 11px — uppercase eyebrow label */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--uw-gray-light);
  margin-bottom: 4px;
}
.result-field span {
  font-size: 1rem; /* 16px */
  font-weight: 600;
  color: var(--uw-gray-dark);
}
.result-field span.location-value {
  font-size: 1.25rem; /* 20px — primary data, deserves emphasis */
  color: var(--uw-purple);
  font-family: 'Source Serif 4', serif;
}
.result-field span.pyxis-value {
  font-size: 1.0625rem; /* 17px */
  color: var(--uw-teal);
}
.result-field span.empty {
  color: var(--uw-gray-light);
  font-weight: 400;
  font-size: 0.875rem; /* 14px */
  font-style: italic;
}

/* ── STATES ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--uw-gray-mid);
}
.empty-state svg      { margin-bottom: 16px; opacity: 0.3; }
.empty-state h3       { font-size: 1.125rem; font-weight: 700; color: var(--uw-gray-dark); margin-bottom: 6px; }
.empty-state p        { font-size: 0.9375rem; /* 15px */ }

.loading-state {
  text-align: center;
  padding: 40px;
  color: var(--uw-gray-mid);
  font-size: 0.9375rem; /* 15px */
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--uw-gray-pale);
  border-top-color: var(--uw-purple);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner {
  background: #fdf0ec;
  border: 1px solid #f4c2b0;
  border-radius: 6px;
  padding: 14px 16px;
  font-size: 0.9375rem; /* 15px */
  color: #8b2500;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.55;
}

.idle-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--uw-gray-mid);
}
.idle-state svg { margin: 0 auto 16px; display: block; opacity: 0.18; }
.idle-state p   { font-size: 0.9375rem; /* 15px */ }

/* ── DEBUG LOG ── */
.debug-toggle-btn {
  font-size: 0.75rem; /* 12px — utility control */
  cursor: pointer;
  background: none;
  border: 1px solid var(--uw-gray-pale);
  border-radius: 3px;
  padding: 3px 10px;
  color: var(--uw-gray-mid);
  margin-left: auto;
  font-family: inherit;
}
.debug-toggle-btn:hover { border-color: var(--uw-gray-mid); }
.debug-wrap { display: none; margin-bottom: 12px; }
.debug-panel {
  font-size: 0.6875rem; /* 11px — developer log, intentionally dense */
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 12px;
  border-radius: 6px;
  overflow: auto;
  max-height: 280px;
  white-space: pre-wrap;
  font-family: 'Courier New', monospace;
}

/* ── FOOTER ── */
footer {
  background: var(--uw-gray-dark);
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 14px;
  font-size: 0.8125rem; /* 13px — fine print */
  letter-spacing: 0.2px;
}
footer strong { color: rgba(255,255,255,0.85); }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .gate-card    { padding: 32px 24px; }
  main          { padding: 20px 16px; }
  .result-card-body { grid-template-columns: 1fr 1fr; }
}
