/* Mary Breckinridge's Wendover - Tour App Styles */

:root {
  --color-bg: #faf8f5;
  --color-primary: #2d1b0e;
  --color-secondary: #5c4033;
  --color-accent: #8b6914;
  --color-text: #333;
  --color-text-light: #666;
  --color-border: #d4c8b8;
  --color-card: #fff;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

/* Skip Link - visible only on focus for keyboard users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-accent);
  color: #000;
  padding: 1rem 2rem;
  border-radius: 0 0 8px 8px;
  font-weight: bold;
  z-index: 1000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: none;
}

/* Focus indicators - WCAG 2.1 requirement */
*:focus {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

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

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

html, body {
  height: 100%;
  overflow: hidden;
}

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

#app {
  height: 100%;
  overflow: hidden;
}

/* Screens */
.screen {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom);
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* Welcome Screen */
#welcome-screen {
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-secondary) 100%);
  color: #fff;
}

.welcome-content {
  max-width: 400px;
}

#welcome-screen h1 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: normal;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 1.5rem;
}

.welcome-image {
  width: 100%;
  max-width: 300px;
  margin: 0 auto 1.5rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.welcome-image img {
  width: 100%;
  height: auto;
  display: block;
}

.intro {
  font-size: 1rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.btn-primary, .btn-secondary {
  display: block;
  width: 100%;
  padding: 1rem 2rem;
  margin-bottom: 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

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

.btn-secondary {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.5);
}

.btn-primary:active, .btn-secondary:active {
  transform: scale(0.98);
}

.offline-badge {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,100,0,0.8);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s;
}

.offline-badge.visible {
  opacity: 1;
}

/* Header */
header {
  display: flex;
  align-items: center;
  padding: 1rem;
  background: var(--color-primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

header h2 {
  flex: 1;
  font-family: var(--font-serif);
  font-size: 1.2rem;
  font-weight: normal;
  text-align: center;
}

.back-btn, .map-toggle {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  padding: 0.5rem;
  cursor: pointer;
  min-width: 50px;
}

.stop-badge {
  font-size: 0.8rem;
  opacity: 0.8;
}

/* Stops List */
.stops-list {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.stops-list.active {
  display: block;
}

.stop-card {
  display: flex;
  align-items: center;
  background: var(--color-card);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stop-card:active {
  transform: scale(0.98);
}

.stop-card-number {
  width: 40px;
  height: 40px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  margin-right: 1rem;
  flex-shrink: 0;
}

.stop-card-info h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--color-primary);
}

.stop-card-info p {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.stop-card.visited .stop-card-number {
  background: var(--color-accent);
}

/* Map View */
.stops-map {
  display: none;
  flex: 1;
  padding: 1rem;
}

.stops-map.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-placeholder {
  text-align: center;
  color: var(--color-text-light);
}

.map-placeholder p {
  margin-bottom: 0.5rem;
}

.hint {
  font-size: 0.85rem;
  opacity: 0.7;
}

/* Stop Detail Screen */
.stop-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.stop-image {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
  background: var(--color-border);
}

.stop-image img {
  width: 100%;
  height: auto;
  display: block;
  min-height: 150px;
  object-fit: cover;
}

/* Audio Player */
.audio-player {
  background: var(--color-card);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.play-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.play-btn:active {
  background: var(--color-secondary);
}

.progress-container {
  flex: 1;
}

.progress-bar {
  height: 12px;
  background: var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

/* Larger touch target overlay */
.progress-bar::before {
  content: '';
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: 0;
  right: 0;
}

.progress {
  height: 100%;
  background: var(--color-accent);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 6px;
}

.progress-bar:focus {
  outline-offset: 4px;
}

.time-display {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 0.5rem;
}

/* Transcript */
.transcript {
  background: var(--color-card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.transcript-toggle {
  width: 100%;
  padding: 1rem;
  background: none;
  border: none;
  text-align: left;
  font-size: 0.9rem;
  color: var(--color-secondary);
  cursor: pointer;
}

.transcript-text {
  display: none;
  padding: 0 1rem 1rem;
  font-family: var(--font-serif);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--color-text);
}

.transcript-text.visible {
  display: block;
}

.transcript-text p {
  margin-bottom: 1rem;
}

/* Stop Navigation */
.stop-nav {
  display: flex;
  padding: 1rem;
  gap: 1rem;
  background: var(--color-bg);
  border-top: 1px solid var(--color-border);
}

.nav-btn {
  flex: 1;
  padding: 0.75rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

.nav-btn:active {
  background: var(--color-border);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* QR Scanner */
.scanner-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: var(--color-bg);
  overflow-y: auto;
}

#qr-reader {
  width: 100%;
  max-width: 500px;
  border: none;
}

#qr-reader video {
  border-radius: 8px;
}

.scanner-hint {
  color: var(--color-text);
  text-align: center;
  margin-top: 1rem;
  opacity: 0.8;
}

/* Style the scanner UI */
#qr-reader__scan_region {
  background: transparent !important;
}

#qr-reader__dashboard {
  padding: 0.5rem !important;
}

#qr-reader button {
  background: var(--color-primary) !important;
  border: none !important;
  padding: 0.75rem 1.5rem !important;
  border-radius: 8px !important;
  color: #fff !important;
  font-size: 1rem !important;
  cursor: pointer !important;
}

#qr-reader select {
  padding: 0.5rem !important;
  border-radius: 4px !important;
  font-size: 1rem !important;
}

#qr-reader__dashboard_section_swaplink {
  text-decoration: underline;
  color: var(--color-accent);
}

/* Welcome Animation */
.fade-in {
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tour Duration */
.tour-duration {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 1.5rem;
  text-align: center;
  max-width: 100%;
  padding: 0 0.5rem;
}

/* Welcome Links */
.welcome-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 0.5rem;
}

/* Text Buttons */
.btn-text {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  padding: 0.5rem;
  cursor: pointer;
}

.btn-text:hover {
  color: #fff;
}

/* Help Modal */
.help-section {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.help-section:last-of-type {
  border-bottom: none;
  margin-bottom: 1rem;
}

.help-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  width: 2rem;
  text-align: center;
}

.help-section h3 {
  font-size: 1rem;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}

.help-section p {
  font-size: 0.9rem;
  color: var(--color-text-light);
  line-height: 1.5;
}

.help-tip {
  background: var(--color-bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Donate Section */
.donate-section {
  background: linear-gradient(135deg, #2d1b0e 0%, #5c4033 100%);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1rem 0;
  text-align: center;
}

.donate-section.hidden {
  display: none;
}

.donate-content p {
  color: rgba(255,255,255,0.9);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.donate-btn {
  display: inline-block;
  background: #c0392b;
  color: #fff;
  padding: 0.875rem 2rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: 500;
  transition: background 0.2s, transform 0.2s;
}

.donate-btn:hover {
  background: #e74c3c;
}

.donate-btn:active {
  transform: scale(0.98);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--color-card);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin: 0 0 1.5rem 0;
  color: var(--color-primary);
  font-family: var(--font-serif);
}

.setting-group {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.setting-group:last-of-type {
  border-bottom: none;
}

.setting-group h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--color-text-light);
  margin: 0 0 1rem 0;
  letter-spacing: 0.5px;
}

.setting-info {
  font-size: 0.9rem;
  color: var(--color-text);
  margin-bottom: 1rem;
}

/* Toggle Switch */
.toggle-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  cursor: pointer;
}

.toggle-setting span:first-child {
  font-size: 1rem;
  color: var(--color-text);
}

.toggle-setting input {
  display: none;
}

.toggle-slider {
  width: 50px;
  height: 28px;
  background: var(--color-border);
  border-radius: 14px;
  position: relative;
  transition: background 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-setting input:checked + .toggle-slider {
  background: var(--color-accent);
}

.toggle-setting input:checked + .toggle-slider::after {
  transform: translateX(22px);
}

/* Danger Button */
.btn-danger {
  width: 100%;
  padding: 0.75rem;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.btn-danger:active {
  background: #a93226;
}

/* Accessibility: Large Text (WCAG 2.1 compliant)
   Base: 16px → Large: 20px (125% scale)
   Ensures readability for users with low vision */
.large-text {
  font-size: 20px !important;
}

.large-text h1 {
  font-size: 1.8rem !important;
}

.large-text h2 {
  font-size: 1.4rem !important;
}

.large-text .welcome-content {
  text-align: center;
  padding: 0 1rem;
}

.large-text .intro,
.large-text .subtitle {
  font-size: 1.1rem !important;
}

.large-text .tour-duration {
  font-size: 1rem;
  word-wrap: break-word;
  white-space: normal;
  max-width: 100%;
}

.large-text .btn-primary,
.large-text .btn-secondary {
  font-size: 1.2rem;
  padding: 1.1rem 2rem;
}

.large-text .stop-card {
  padding: 1.25rem;
}

.large-text .stop-card-info h3 {
  font-size: 1.25rem;
}

.large-text .stop-card-info p {
  font-size: 1rem;
}

.large-text .transcript-text {
  font-size: 1.2rem;
  line-height: 1.9;
}

.large-text .transcript-toggle {
  font-size: 1.1rem;
}

.large-text .time-display {
  font-size: 0.95rem;
}

.large-text .nav-btn {
  font-size: 1.1rem;
  padding: 1rem;
}

/* Accessibility: High Contrast (WCAG AAA target: 7:1 contrast) */
.high-contrast {
  --color-bg: #000;
  --color-primary: #000;
  --color-secondary: #333;
  --color-text: #fff;
  --color-text-light: #ccc;
  --color-card: #111;
  --color-border: #444;
  --color-accent: #ffcc00;
}

.high-contrast .stop-card {
  border: 2px solid #fff;
}

.high-contrast .btn-primary,
.high-contrast .play-btn {
  background: #ffcc00;
  color: #000;
}

.high-contrast header {
  background: #000;
  border-bottom: 2px solid #ffcc00;
}

.high-contrast header h2,
.high-contrast header .stop-badge,
.high-contrast #stop-title {
  color: #fff !important;
}

.high-contrast .stop-card-info h3 {
  color: #fff;
}

.high-contrast .stop-card-info p {
  color: #ccc;
}

.high-contrast .transcript-toggle {
  color: #ffcc00;
}

.high-contrast .modal-content {
  background: #111;
  border: 2px solid #ffcc00;
}

.high-contrast .modal-content h2,
.high-contrast .setting-group h3 {
  color: #ffcc00;
}

.high-contrast *:focus-visible {
  outline: 3px solid #ffcc00;
  outline-offset: 2px;
}

.high-contrast .skip-link {
  background: #ffcc00;
  color: #000;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  header {
    padding-top: calc(1rem + env(safe-area-inset-top));
  }
}
