/* ============================================================
   main.css — Design system, layout, toolbar, responsive
   ============================================================ */

:root {
  /* Brand defaults (overridden by tourbook.json branding) */
  --color-primary: #1A3A5C;
  --color-secondary: #E8913A;
  --color-accent: #2ECC71;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;

  /* Fixed design tokens */
  --color-bg: #FFFFFF;
  --color-text: #1A1A2E;
  --color-text-muted: #6B7280;
  --color-border: #E5E7EB;
  --color-surface: #F9FAFB;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.18);

  --card-width: 420px;
  --header-height: 56px;
  --transition-speed: 0.3s;
}

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

body {
  font-family: var(--font-family);
  color: var(--color-text);
  background: var(--color-bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- App shell --- */
#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* --- Toolbar --- */
.toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.toolbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.toolbar__logo {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.toolbar__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:hover {
  filter: brightness(1.15);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--secondary:hover {
  background: var(--color-border);
}

.btn--icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 16px;
}

.btn--icon:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* --- Map container --- */
#map-container {
  position: absolute;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

/* --- Card container (overlay region) — lives outside #app for iOS compat --- */
#card-container {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: var(--card-width);
  z-index: 9999;
  pointer-events: none;
}

#card-container.card-active {
  pointer-events: auto;
}

/* --- Print container (hidden on screen) --- */
#print-container {
  display: none;
}

/* --- Loading spinner --- */
.loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  gap: 16px;
}

.loading__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading__text {
  font-size: 14px;
  color: var(--color-text-muted);
}

.loading--hidden {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Error display --- */
.error-banner {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  background: #FEE2E2;
  color: #991B1B;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid #FECACA;
  font-size: 14px;
  max-width: 500px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  :root {
    --card-width: 380px;
  }
}

@media (max-width: 768px) {
  :root {
    --card-width: 100vw;
  }

  .toolbar__title {
    font-size: 13px;
  }

  #card-container {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: auto;
  }
}

@media (max-width: 480px) {
  .toolbar {
    padding: 0 10px;
  }

  .toolbar__logo {
    height: 26px;
  }
}
