@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   Design Tokens
   ========================================================================== */

:root {
  /* Brand */
  --brand: #1a365d;
  --brand-600: #2c5282;
  --brand-500: #3182ce;
  --brand-300: #63b3ed;
  --brand-100: #bee3f8;

  /* Accent */
  --accent: #fbbf24;
  --accent-dark: #f59e0b;

  /* Text */
  --text: #1a1a1a;
  --text-heading: #2d3748;
  --text-body: #4a5568;
  --text-muted: #718096;
  --text-subtle: #a0aec0;

  /* Surfaces */
  --surface: #f5f7fa;
  --surface-card: #ffffff;
  --surface-muted: #edf2f7;
  --surface-stripe: #f7fafc;
  --surface-dark: #1a202c;

  /* Border */
  --border: #e2e8f0;

  /* Error */
  --error: #9b2c2c;
  --error-bg: #fed7d7;
  --error-border: #feb2b2;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 50px;

  /* Font */
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Easing */
  --ease-out: cubic-bezier(0.25, 1, 0.5, 1);
}

/* ==========================================================================
   Base
   ========================================================================== */

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

body {
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: var(--brand-500);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  background: linear-gradient(180deg, var(--brand) 0, var(--brand-600) 100%);
  padding: 16px;
  text-align: center;
  position: relative;
}

.site-header::after {
  content: '';
  position: absolute;
  bottom: -30px;
  left: 0;
  right: 0;
  height: 30px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 60' preserveAspectRatio='none'%3E%3Cpath fill='%232c5282' d='M0,0 L1440,0 L1440,30 Q1080,60 720,30 Q360,0 0,30 Z'/%3E%3C/svg%3E") no-repeat bottom center;
  background-size: 100% 100%;
  z-index: 1;
}

.site-header .logo {
  height: 72px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.site-header nav {
  margin-top: 12px;
}

.site-header nav a {
  color: rgba(255, 255, 255, 0.85);
  margin: 0 12px;
  font-size: 0.9rem;
}

.site-header nav a:hover {
  color: #fff;
  text-decoration: none;
}

/* ==========================================================================
   Page Hero
   ========================================================================== */

.page-hero {
  background: linear-gradient(180deg, var(--brand-600) 0, var(--brand-500) 50%, var(--brand-300) 100%);
  padding: 60px 20px 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.page-hero::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 120' preserveAspectRatio='none'%3E%3Cpath fill='%234a5568' d='M0,120L0,100L180,70L360,90L540,50L720,80L900,40L1080,70L1260,30L1440,60L1440,120Z'/%3E%3Cpath fill='%232d3748' fill-opacity='0.8' d='M0,120L0,90L120,70L240,85L360,55L480,75L600,45L720,65L840,35L960,55L1080,25L1200,50L1320,20L1440,40L1440,120Z'/%3E%3Cpath fill='%23f5f7fa' d='M0,120L0,110L1440,110L1440,120Z'/%3E%3C/svg%3E") no-repeat bottom center;
  background-size: 100% 100%;
}

.page-hero h1 {
  color: #fff;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.page-hero .subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.1rem;
  margin-top: 12px;
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   Quick Answer
   ========================================================================== */

.quick-answer {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 20px 28px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: inline-block;
  margin-top: 24px;
  position: relative;
  z-index: 2;
}

.quick-answer .value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--brand);
}

.quick-answer .label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

/* ==========================================================================
   CTA Button
   ========================================================================== */

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand);
  background: linear-gradient(135deg, var(--accent) 0, var(--accent-dark) 100%);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(251, 191, 36, 0.4);
  transition: all 0.3s var(--ease-out);
  text-decoration: none;
  margin-top: 20px;
  position: relative;
  z-index: 2;
}

.cta-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(251, 191, 36, 0.5);
  text-decoration: none;
}

/* ==========================================================================
   Main Content
   ========================================================================== */

.main-content {
  background: var(--surface);
  padding: 40px 20px;
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

/* ==========================================================================
   Article Content
   ========================================================================== */

.article-content {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.article-content h2 {
  color: var(--brand);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 32px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.article-content h2:first-child {
  margin-top: 0;
}

.article-content h3 {
  color: var(--text-heading);
  font-size: 1.2rem;
  margin-top: 24px;
  margin-bottom: 12px;
}

.article-content p {
  color: var(--text-body);
  margin-bottom: 16px;
}

.article-content ol,
.article-content ul {
  color: var(--text-body);
  margin-bottom: 16px;
  padding-left: 24px;
}

.article-content li {
  margin-bottom: 8px;
}

.article-content strong {
  color: var(--text-heading);
}

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.article-content th {
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
}

.article-content td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
}

.article-content tr:nth-child(2n) {
  background: var(--surface-stripe);
}

.article-content tr:hover {
  background: var(--surface-muted);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 24px;
}

.card {
  background: var(--surface-card);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  transition: all 0.2s var(--ease-out);
}

.card:hover {
  border-color: var(--brand-500);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.card h3 {
  color: var(--brand);
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.card h3 a {
  color: var(--brand);
}

.card h3 a:hover {
  color: var(--brand-500);
  text-decoration: none;
}

.card .altitude {
  color: var(--brand-500);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
}

.card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
  margin-bottom: 40px;
}

.section-title {
  color: var(--brand);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  background: var(--surface-dark);
  color: var(--text-subtle);
  padding: 32px 16px;
  text-align: center;
}

footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px 24px;
  margin-bottom: 20px;
}

footer a {
  color: var(--text-subtle);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s var(--ease-out);
  display: inline-block;
  padding: 8px 4px;
}

footer a:hover {
  color: #fff;
  text-decoration: none;
}

footer .copyright {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* ==========================================================================
   Search Autocomplete
   ========================================================================== */

.search-container {
  margin-top: 24px;
  position: relative;
  z-index: 10;
}

.search-wrapper {
  position: relative;
  max-width: 400px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  border: none;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  outline: none;
  transition: box-shadow 0.2s var(--ease-out);
}

.search-input:focus {
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.search-input::placeholder {
  color: var(--text-subtle);
}

.suggestions-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface-card);
  border-radius: var(--radius-md);
  margin-top: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: none;
  overflow: hidden;
  z-index: 100;
}

.suggestion-item {
  padding: 12px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s var(--ease-out);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--surface-muted);
}

.suggestion-item.no-result {
  color: var(--text-muted);
  cursor: default;
  justify-content: center;
}

.suggestion-item.no-result:hover {
  background: var(--surface-card);
}

.suggestion-name {
  font-weight: 600;
  color: var(--text-heading);
}

.suggestion-details {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Result Section
   ========================================================================== */

.result-section {
  margin-bottom: 40px;
}

.result-card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  text-align: center;
  margin-bottom: 24px;
}

.result-header {
  margin-bottom: 20px;
}

.result-header h2 {
  color: var(--brand);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.result-postal {
  color: var(--text-muted);
  font-size: 1rem;
}

.result-altitude {
  margin: 24px 0;
}

.result-altitude .altitude-value {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--brand);
  display: block;
  letter-spacing: -0.02em;
  line-height: 1;
}

.result-altitude .altitude-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.result-coords {
  color: var(--text-subtle);
  font-size: 0.9rem;
}

.map-container {
  margin-top: 24px;
}

.map-container #map {
  width: 100%;
  height: clamp(260px, 35vh, 320px);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.search-again {
  text-align: center;
  margin-top: 24px;
}

.cta-center {
  text-align: center;
  margin-top: 32px;
}

/* ==========================================================================
   Example Cards
   ========================================================================== */

.example-card {
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}

.example-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-500);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Error Message
   ========================================================================== */

.error-message {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  font-weight: 500;
  text-align: center;
}

/* ==========================================================================
   Skip Navigation
   ========================================================================== */

.skip-nav {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 100;
  padding: 12px 24px;
  background: var(--brand);
  color: white;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
}

.skip-nav:focus {
  top: 0;
}

/* ==========================================================================
   Focus Visible
   ========================================================================== */

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.cta-button:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}

footer a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.search-input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.suggestion-item:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: -2px;
}

.card:focus-visible {
  outline: 3px solid var(--brand-500);
  outline-offset: 2px;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Desktop
   ========================================================================== */

@media (min-width: 768px) {
  .site-header .logo {
    height: 96px;
  }

  .page-hero {
    padding: 80px 24px 100px;
  }

  .page-hero h1 {
    font-size: 2.6rem;
  }

  .quick-answer .value {
    font-size: 2.8rem;
  }

  .main-content {
    padding: 60px 24px;
  }

  .article-content {
    padding: 48px 40px;
  }

  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .search-wrapper {
    max-width: 500px;
  }

  .search-input {
    font-size: 1.2rem;
    padding: 18px 24px;
  }

  .map-container #map {
    height: clamp(350px, 40vh, 500px);
  }

  .result-altitude .altitude-value {
    font-size: 5rem;
  }
}

/* ==========================================================================
   Large Screens
   ========================================================================== */

@media (min-width: 1024px) {
  .container {
    max-width: 900px;
  }

  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .page-hero {
    padding: 100px 32px 120px;
  }

  .page-hero h1 {
    font-size: 3rem;
  }

  .main-content {
    padding: 60px 32px;
  }

  .map-container #map {
    max-width: 900px;
    margin: 0 auto;
  }
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #63b3ed;
    --brand-600: #4299e1;
    --brand-500: #90cdf4;
    --brand-300: #bee3f8;
    --brand-100: #e9f2ff;
    --text: #e2e8f0;
    --text-heading: #f7fafc;
    --text-body: #cbd5e0;
    --text-muted: #a0aec0;
    --text-subtle: #718096;
    --surface: #1a202c;
    --surface-card: #2d3748;
    --surface-muted: #2d3748;
    --surface-stripe: #2a3444;
    --surface-dark: #131720;
    --border: #4a5568;
    --error: #fc8181;
    --error-bg: #3b1a1a;
    --error-border: #742a2a;
  }

  body {
    color-scheme: dark;
  }

  /* Keep gradient backgrounds dark */
  .site-header {
    background: linear-gradient(180deg, #1a365d 0, #2c5282 100%);
  }

  .page-hero {
    background: linear-gradient(180deg, #2c5282 0, #3182ce 50%, #63b3ed 100%);
  }

  /* CTA button text stays dark on amber */
  .cta-button {
    color: #1a365d;
  }

  /* Table header stays dark */
  .article-content th {
    background: #1a365d;
    color: #e2e8f0;
  }

  /* Skip nav stays readable */
  .skip-nav {
    background: #2c5282;
  }

  /* Search input */
  .search-input {
    background: var(--surface-card);
    color: var(--text);
  }

  /* Card borders */
  .card {
    border-color: var(--border);
  }

  /* Image filter for dark bg */
  .site-header .logo,
  .logo {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5)) brightness(1.1);
  }
}
