/* Chiang Mai Trip — mobile-first static site */

:root {
  --bg: #faf8f4;
  --bg-alt: #f0ebe3;
  --surface: #ffffff;
  --text: #1c2b26;
  --text-muted: #5a6b64;
  --primary: #1a4d3e;
  --primary-light: #2d6b58;
  --accent: #c9a227;
  --accent-soft: #f5ecd4;
  --border: #ddd5c8;
  --timeline: #2d6b58;
  --shadow: 0 2px 12px rgba(26, 77, 62, 0.08);
  --radius: 12px;
  --nav-h: 48px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Header / Nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 0;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 8px;
  min-height: var(--nav-h);
  align-items: center;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav-link {
  flex-shrink: 0;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--primary);
}

.nav-link.active {
  color: var(--primary);
  border-bottom-color: var(--accent);
}

/* Weather modal */
body.weather-modal-open {
  overflow: hidden;
}

.weather-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.weather-modal[hidden] {
  display: none;
}

.weather-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(28, 43, 38, 0.45);
}

.weather-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(26, 77, 62, 0.2);
  padding: 20px;
  animation: weather-in 0.25s ease;
}

@keyframes weather-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .weather-modal-dialog {
    animation: none;
  }
}

.weather-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.weather-modal-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--primary);
}

.weather-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-alt);
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
}

.weather-modal-body {
  margin-bottom: 16px;
}

.weather-loading,
.weather-error {
  margin: 0;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

.weather-date {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.weather-main {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.weather-icon {
  font-size: 3rem;
  line-height: 1;
}

.weather-now {
  margin: 0 0 4px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.weather-temp {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.weather-feels {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.weather-details {
  list-style: none;
  margin: 0 0 14px;
  padding: 12px 14px;
  background: var(--bg-alt);
  border-radius: 10px;
}

.weather-details li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  font-size: 0.9rem;
}

.weather-details li span {
  color: var(--text-muted);
}

.weather-details li strong {
  text-align: right;
  font-weight: 600;
}

.weather-tip {
  margin: 0;
  padding: 10px 12px;
  font-size: 0.875rem;
  color: var(--primary);
  background: var(--accent-soft);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.btn-weather-ok {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

.btn-weather-ok:hover,
.btn-weather-ok:focus-visible {
  background: var(--primary-light);
}

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

.section {
  padding: 40px 0;
}

.section-alt {
  background: var(--bg-alt);
}

.section-title {
  margin: 0 0 20px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
}

.section-desc {
  margin: -8px 0 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Hero */
.hero {
  background: linear-gradient(160deg, var(--primary) 0%, #2d6b58 55%, #3d8570 100%);
  color: #fff;
  padding: 48px 20px 56px;
}

.hero-inner {
  max-width: 720px;
  margin: 0 auto;
}

.hero-eyebrow {
  margin: 0 0 8px;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}

.hero-title {
  margin: 0 0 12px;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
}

.hero-subtitle {
  margin: 0 0 24px;
  font-size: 1rem;
  opacity: 0.92;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}

/* Flights */
.flight-cards {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.flight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.flight-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.flight-date {
  font-weight: 600;
  color: var(--primary);
}

.flight-no {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 6px;
}

.flight-route {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.flight-time {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background 0.15s, color 0.15s;
}

.btn-outline {
  color: var(--primary);
  background: var(--surface);
  border: 2px solid var(--primary);
}

.btn-outline:hover,
.btn-outline:focus-visible {
  background: var(--primary);
  color: #fff;
}

/* Day sections */
.day-section {
  margin-bottom: 48px;
  scroll-margin-top: calc(var(--nav-h) + 12px);
}

.day-section:last-child {
  margin-bottom: 0;
}

.day-header {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
}

.day-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
}

/* Timeline */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--timeline);
  opacity: 0.35;
  border-radius: 1px;
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: -24px;
  top: 10px;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border: 2px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--timeline);
}

.timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.period-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  padding: 4px 10px;
  border-radius: 6px;
}

.location-badge {
  font-size: 0.8rem;
  color: var(--primary-light);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 6px;
}

.timeline-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.timeline-content {
  margin: 0;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.timeline-content:empty {
  display: none;
}

/* Sub-timeline (nested steps within a slot) */
.sub-timeline {
  position: relative;
  padding-left: 20px;
  margin-top: 4px;
}

.sub-timeline::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--primary-light);
  opacity: 0.25;
  border-radius: 1px;
}

.sub-step {
  position: relative;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--border);
}

.sub-step:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.sub-step::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 8px;
  width: 8px;
  height: 8px;
  background: var(--primary-light);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.sub-step-tip::before {
  background: var(--accent);
}

.sub-step-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.sub-step-time {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 5px;
}

.sub-step-tip .sub-step-time {
  background: var(--accent);
  color: var(--text);
}

.sub-step-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.sub-step-subtitle {
  margin: 0 0 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.sub-step-meta {
  margin: 0 0 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.sub-step-meta strong {
  color: var(--text);
}

.sub-step-mustbuy {
  color: var(--primary);
}

.sub-step-mustbuy strong {
  color: var(--primary);
}

.sub-step-content {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  line-height: 1.55;
}

.sub-step .venues {
  margin-top: 10px;
}

.sub-step .venue-card {
  background: var(--surface);
}

.timeline-item-has-sub .timeline-body {
  padding-bottom: 12px;
}

/* Venue cards */
.venues {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.venue-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}

.venue-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.venue-summary::-webkit-details-marker {
  display: none;
}

.venue-summary::after {
  content: "+";
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--primary);
  background: var(--accent-soft);
  border-radius: 6px;
  transition: transform 0.2s;
}

.venue-card[open] .venue-summary::after {
  content: "−";
}

.venue-details {
  padding: 0 14px 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.venue-field {
  margin-bottom: 8px;
}

.venue-field:last-child {
  margin-bottom: 0;
}

.venue-field strong {
  color: var(--text);
  font-weight: 600;
}

/* Checklist */
.checklist-categories {
  display: grid;
  gap: 12px;
}

.checklist-category {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.checklist-category summary {
  padding: 14px 18px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.checklist-category summary::-webkit-details-marker {
  display: none;
}

.checklist-category summary::after {
  content: "+";
  font-size: 1.2rem;
  color: var(--text-muted);
}

.checklist-category[open] summary::after {
  content: "−";
}

.checklist-items {
  padding: 0 18px 14px;
  border-top: 1px solid var(--border);
}

.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

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

.checklist-item input[type="checkbox"] {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.checklist-item.checked .checklist-label {
  text-decoration: line-through;
  color: var(--text-muted);
}

.checklist-label {
  flex: 1;
  font-weight: 500;
}

.checklist-note {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}

.checklist-link {
  color: var(--primary-light);
  word-break: break-all;
}

/* Budget */
.budget-table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border-collapse: collapse;
}

.budget-table th,
.budget-table td {
  padding: 14px 18px;
  text-align: left;
}

.budget-table thead {
  background: var(--primary);
  color: #fff;
}

.budget-table tbody tr {
  border-top: 1px solid var(--border);
}

.budget-table tbody tr.total-row {
  background: var(--accent-soft);
  font-weight: 700;
}

.budget-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Footer */
.site-footer {
  padding: 32px 20px calc(32px + var(--safe-bottom));
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
}

/* Desktop tweaks */
@media (min-width: 600px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .flight-cards {
    grid-template-columns: 1fr 1fr;
  }

  .section {
    padding: 56px 0;
  }
}
