/* Home Page Styles */

.home-page {
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
  padding-bottom: calc(var(--space-8) + var(--safe-area-bottom));
  scroll-padding-bottom: calc(var(--space-8) + var(--safe-area-bottom));
  background: linear-gradient(135deg, var(--color-ocean-dark) 0%, var(--color-ocean-deep) 100%);
  overflow-y: auto;
}

.home-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: var(--max-width-xl);
  margin: 0 auto;
}

.home-top-section {
  padding: var(--space-4) var(--space-4);
  z-index: var(--z-sticky);
}

/* Welcome Block */
.welcome-block {
  margin-bottom: var(--space-6);
  color: var(--color-text-light);
}

.welcome-block__greeting {
  font-size: var(--font-size-base);
  opacity: 0.9;
  margin-bottom: var(--space-1);
}

.welcome-block__title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  margin: 0;
  line-height: 1.1;
}

.welcome-block__subtitle {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-bold);
  opacity: 0.8;
  margin: var(--space-2) 0 0 0;
}

/* Panels Container */
.home-panels-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.home-panel {
  background: rgba(13, 59, 102, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(109, 213, 231, 0.2);
  border-radius: var(--radius-4);
  padding: var(--space-4);
  color: var(--color-text-light);
  box-shadow: 0 8px 32px rgba(13, 59, 102, 0.1), inset 0 -2px 8px rgba(255, 255, 255, 0.1);
  /* Pre-existing CSS Grid bug found during the Fase 8 Parte 2 responsive
     audit (375-414px, 2-column .home-panels-container): grid items
     default to min-width: auto, so the .course-circle's fixed 120px
     content forced this panel wider than its actual grid track,
     overflowing the viewport by ~25-52px. Not introduced by this part —
     verified the old and new circle markup render at an identical
     120x120 footprint — but fixed here since it's directly adjacent to
     code this part already touches. */
  min-width: 0;
}

.home-panel__header {
  margin-bottom: var(--space-3);
}

.home-panel__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin: 0;
}

.home-panel__content {
  font-size: var(--font-size-base);
}

/* Streak Panel */
.home-panel--streak .home-panel__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.streak-number {
  font-size: 2.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-warning);
}

.streak-label {
  margin: 0;
  font-size: var(--font-size-sm);
  opacity: 0.8;
}

.streak-week {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  margin: var(--space-2) 0;
  width: 100%;
}

/* The 7 circles used to have a hard 28px width, so .streak-week always
   demanded 244px regardless of its actual grid column - at the 2-column
   .home-panels-container breakpoints (375-767px) that column is only
   ~130-150px wide, so the row overflowed its own card and bled into the
   neighboring panel. flex:1 1 0 + min-width:0 makes each circle share
   whatever width the row actually has, capped at the original 28px
   design size so it never grows beyond it in the roomier 1-column/
   3-column layouts - this can never overflow by construction, no
   per-breakpoint tuning needed. */
.streak-day {
  flex: 1 1 0;
  max-width: 28px;
  aspect-ratio: 1 / 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  font-size: var(--font-size-base);
  color: rgba(255, 255, 255, 0.5);
  overflow: hidden;
}

.streak-day--active {
  background: rgba(243, 156, 18, 0.3);
  color: var(--color-warning);
}

.streak-day__flame {
  width: 57%;
  height: 57%;
}

.streak-best {
  margin: 0;
  font-size: var(--font-size-sm);
  opacity: 0.8;
}

/* Course Progress Panel */
.home-panel--progress .home-panel__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.course-level {
  margin: 0;
  font-size: var(--font-size-base);
  opacity: 0.9;
}

/* .course-circle is now just a sizing wrapper — the ring itself is
   js/components/progress.js createCircularProgress() (Fase 8 Parte 2),
   using .circular-progress* classes from css/components.css. The old
   .course-circle__svg/.course-circle__progress rules (raw literal
   stroke colors, no aria) were removed with the migration. */
.course-circle {
  width: 120px;
  max-width: 100%;
  height: 120px;
  position: relative;
}

.course-lessons {
  margin: 0;
  font-size: var(--font-size-base);
  opacity: 0.8;
}

/* Missions Panel */
.home-panel--missions .home-panel__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.missions-progress {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.missions-count {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-success);
}

.missions-label {
  font-size: var(--font-size-base);
  opacity: 0.8;
}

.missions-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.missions-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-success) 0%, var(--color-primary) 100%);
  transition: width 0.5s ease;
}

.missions-btn {
  width: 100%;
  font-size: var(--font-size-base);
}

/* Journey Map Container */
.home-map-container {
  flex: 1;
  position: relative;
  padding: var(--space-4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.journey-map {
  width: 100%;
  height: 100%;
  position: relative;
}

.journey-map__svg {
  width: 100%;
  height: 100%;
  aspect-ratio: 200 / 1360;
}

/* City Nodes */
.city-node {
  cursor: pointer;
}

.city-node--locked {
  cursor: not-allowed;
}

.city-node__circle {
  transition: all 0.3s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.city-node:hover:not(.city-node--locked) .city-node__circle {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
  r: 12;
}

.city-node__pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    r: 13;
    opacity: 0.4;
  }
  50% {
    r: 18;
    opacity: 0;
  }
}

.city-node__check,
.city-node__lock,
.city-node__number {
  font-size: 6px;
  font-weight: bold;
  pointer-events: none;
}

/* City Labels */
.city-label {
  font-size: 3px;
  transition: opacity 0.3s ease;
}

.city-label text {
  pointer-events: none;
}

/* Route */
.city-route__completed {
  animation: routeAnimation 3s ease-in-out infinite;
}

@keyframes routeAnimation {
  0%, 100% {
    stroke-dashoffset: 0;
  }
  50% {
    stroke-dashoffset: 6;
  }
}

/* Modals */
.city-detail-modal,
.city-locked-modal,
.missions-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  z-index: var(--z-modal);
}

.city-detail-modal__overlay,
.city-locked-modal__overlay,
.missions-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.city-detail-modal__content,
.city-locked-modal__content,
.missions-modal__content {
  position: relative;
  background: var(--color-bg-primary);
  border-radius: var(--radius-5) var(--radius-5) 0 0;
  padding: var(--space-6);
  max-height: 80vh;
  overflow-y: auto;
  width: 100%;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.city-detail-modal__close,
.city-locked-modal__close,
.missions-modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: transparent;
  border: none;
  font-size: var(--font-size-xl);
  cursor: pointer;
  padding: var(--space-2);
}

/* City Detail */
.city-detail__header {
  text-align: center;
  margin-bottom: var(--space-4);
}

.city-detail__icon {
  font-size: 3rem;
}

.city-detail__info {
  text-align: center;
  margin-bottom: var(--space-4);
}

.city-detail__title {
  font-size: var(--font-size-3xl);
  margin: 0 0 var(--space-2) 0;
}

.city-detail__status {
  margin: 0 0 var(--space-2) 0;
  font-weight: var(--font-weight-semibold);
}

.city-detail__description {
  margin: 0;
  opacity: 0.7;
}

.city-detail__content {
  margin-bottom: var(--space-6);
}

.city-detail__stat {
  display: flex;
  justify-content: space-between;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-bg-secondary);
}

.city-detail__stat-label {
  font-weight: var(--font-weight-semibold);
}

.city-detail__stat-value {
  opacity: 0.8;
}

.city-detail__action {
  width: 100%;
}

/* City Locked Modal */
.city-locked-modal__icon {
  text-align: center;
  font-size: 3rem;
  margin-bottom: var(--space-4);
}

.city-locked-modal__title {
  font-size: var(--font-size-2xl);
  text-align: center;
  margin: 0 0 var(--space-3) 0;
}

.city-locked-modal__message {
  text-align: center;
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-2) 0;
}

.city-locked-modal__description {
  text-align: center;
  opacity: 0.7;
  margin: 0 0 var(--space-6) 0;
}

.city-locked-modal__close {
  width: 100%;
}

/* Missions Modal */
.missions-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.missions-modal__title {
  margin: 0;
}

.missions-modal__close {
  background: transparent;
  border: none;
  font-size: var(--font-size-xl);
  cursor: pointer;
}

.missions-modal__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.mission-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-3);
}

.mission-item__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  color: var(--color-primary);
}

.mission-icon {
  width: 24px;
  height: 24px;
  color: inherit;
}

.mission-item__title {
  flex: 1;
  font-weight: var(--font-weight-medium);
}

.mission-item__xp {
  font-weight: var(--font-weight-bold);
  color: var(--color-xp);
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, rgba(13, 59, 102, 0.8) 0%, rgba(10, 20, 40, 0.8) 100%);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(109, 213, 231, 0.1);
  padding: var(--safe-area-top) var(--space-4) var(--space-3);
  position: sticky;
  top: 0;
  z-index: var(--z-fixed);
}

.app-header__content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width-xl);
  margin: 0 auto;
}

.app-header__logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-light);
}

.app-header__menu-btn {
  background: transparent;
  border: none;
  color: var(--color-text-light);
  cursor: pointer;
  padding: var(--space-2);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header__menu-icon {
  width: 24px;
  height: 24px;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-lg);
}

.app-header__airplane-icon {
  width: 24px;
  height: 24px;
}

.app-header__logo-text {
  display: none;
}

.app-header__stats {
  display: flex;
  gap: var(--space-2);
}

/* Padding/gap tightened from --space-3 to --space-2 (measured real
   deficit at a true 320px viewport: 3 pills + gaps needed 231px, only
   200px were available next to the logo) - this is the header's default
   at every width, not just mobile, since there's no reason for it to be
   less compact once there happens to be more screen space. */
.stat-pill {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  background: rgba(255, 255, 255, 0.1);
  padding: var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.stat-pill__icon-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.stat-pill__value {
  min-width: 20px;
  text-align: right;
}

/* Side Drawer */
.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  display: flex;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.side-drawer--open {
  opacity: 1;
}

.side-drawer--closing {
  opacity: 0;
}

.side-drawer__overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.side-drawer__content {
  position: relative;
  background: var(--color-bg-primary);
  width: 80%;
  max-width: 280px;
  height: 100%;
  display: flex;
  flex-direction: column;
  animation: slideInLeft 0.3s ease-out;
  box-shadow: var(--shadow-xl);
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

.side-drawer__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-bg-secondary);
}

.side-drawer__title {
  margin: 0;
}

.side-drawer__close {
  background: transparent;
  border: none;
  font-size: var(--font-size-xl);
  cursor: pointer;
  padding: var(--space-2);
  min-width: 44px;
  min-height: 44px;
}

.side-drawer__nav {
  flex: 1;
  padding: var(--space-4) 0;
}

.side-drawer__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.side-drawer__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-primary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.side-drawer__item--active {
  background: var(--color-bg-secondary);
  border-left-color: var(--color-primary);
  color: var(--color-primary);
}

.side-drawer__item[data-route]:hover {
  background: var(--color-bg-secondary);
}

.side-drawer__item--future {
  color: var(--color-text-secondary);
  cursor: default;
}

.side-drawer__future-badge {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--color-bg-secondary);
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.side-drawer__footer {
  padding: var(--space-4);
  border-top: 1px solid var(--color-bg-secondary);
  text-align: center;
}

.side-drawer__version {
  margin: 0;
  font-size: var(--font-size-sm);
  opacity: 0.6;
}

/* Responsive */
@media (min-width: 375px) {
  .home-panels-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .home-panel--missions {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) {
  /* The "AirEnglish" wordmark next to the airplane icon was previously
     shown from 375px, together with all 3 stat pills (streak/XP/gems) -
     measured real overflow at true 375-430px viewports (an iframe with
     an exact CSS width, not the visually-similar-but-scaled preview
     window): logo+stats needed ~396px but only had ~350px available.
     The airplane icon alone remains the brand mark on every mobile
     width; the wordmark only reappears once the header actually has
     room, at the same 768px tier where #app gets more padding. */
  .app-header__logo-text {
    display: inline;
  }

  .home-panels-container {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
  }

  .home-panel--missions {
    grid-column: auto;
  }

  .home-top-section {
    padding: var(--space-6);
  }

  .welcome-block {
    margin-bottom: var(--space-8);
  }

  .welcome-block__title {
    font-size: var(--font-size-5xl);
  }

  .app-header {
    padding: var(--safe-area-top) var(--space-6) var(--space-4);
  }

  .city-detail-modal__content,
  .city-locked-modal__content,
  .missions-modal__content {
    border-radius: var(--radius-5);
    max-width: 500px;
    margin: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .city-node__pulse,
  :root:not([data-motion="full"]) .city-route__completed,
  :root:not([data-motion="full"]) .slideUp,
  :root:not([data-motion="full"]) .slideInLeft {
    animation: none;
  }

  :root:not([data-motion="full"]) .city-detail-modal__content,
  :root:not([data-motion="full"]) .city-locked-modal__content,
  :root:not([data-motion="full"]) .missions-modal__content {
    animation: none;
  }

  :root:not([data-motion="full"]) .side-drawer__content {
    animation: none;
  }
}
