/* LuccaEvents 0.6.0 alpha3 - mobile density hotfix. CSS only. */
@media (max-width: 700px) {
  #today-alpha3-view {
    width: 100%;
    max-width: none;
    padding: 0 12px calc(92px + env(safe-area-inset-bottom));
    box-sizing: border-box;
  }

  /* Hide duplicate desktop chrome only while the Today view exists. */
  body:has(#today-alpha3-view) #breadcrumbs,
  body:has(#today-alpha3-view) .breadcrumbs,
  body:has(#today-alpha3-view) .breadcrumb,
  body:has(#today-alpha3-view) #page-title,
  body:has(#today-alpha3-view) #active-filters {
    display: none !important;
  }

  .today-head {
    display: block;
    margin: 0 0 12px;
  }

  .today-head small {
    display: block;
    margin-bottom: 2px;
    font-size: 12px;
    line-height: 1.25;
    letter-spacing: .08em;
  }

  .today-head h1 {
    margin: 0 0 12px;
    font-size: clamp(34px, 10vw, 44px);
    line-height: 1;
    letter-spacing: -.035em;
  }

  .today-days {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 46px auto;
    gap: 8px;
    margin: 0;
    align-items: stretch;
  }

  .today-days button,
  .today-days input {
    min-width: 0;
    min-height: 48px;
    padding: 8px 10px;
    border-radius: 12px;
    font-size: 16px;
  }

  .today-days input {
    width: 100%;
  }

  /* Compact test mode: controls stay usable but no longer dominate the page. */
  .today-simulation,
  .today-simulation.active {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-width: 1px;
    border-radius: 14px;
  }

  .today-simulation > div:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .today-simulation small {
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: .04em;
  }

  .today-simulation > div:first-child b {
    font-size: 13px;
    text-align: right;
  }

  .sim-controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    margin: 8px 0 0;
  }

  .sim-controls input {
    grid-column: 1 / -1;
    width: 100%;
  }

  .sim-controls input,
  .sim-controls button {
    min-width: 0;
    min-height: 40px;
    padding: 7px 5px;
    border-radius: 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  .today-simulation p {
    display: none;
  }

  .today-favourites-toggle {
    gap: 8px;
    margin: 0 0 12px;
    padding: 9px 11px;
    border-radius: 11px;
    font-size: 13px;
    line-height: 1.25;
  }

  .today-favourites-toggle input {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
  }

  .today-hero {
    margin: 0 0 12px;
    padding: 18px;
    border-radius: 18px;
    box-shadow: 0 10px 24px #1118271f;
  }

  .today-hero > small {
    font-size: 12px;
    letter-spacing: .07em;
  }

  .today-hero h2 {
    margin: 6px 0 10px;
    font-size: clamp(24px, 7vw, 31px);
    line-height: 1.2;
  }

  .today-hero p {
    margin: 7px 0;
  }

  .hero-time {
    font-size: 17px;
  }

  .today-countdown {
    margin: 12px 0 0;
    padding: 11px 12px;
    border-radius: 11px;
    font-size: 15px;
    line-height: 1.4;
  }

  .today-list {
    padding: 12px;
    border-radius: 16px;
  }

  .today-list > h2 {
    margin: 4px 4px 12px;
    font-size: 24px;
    line-height: 1.15;
  }

  .today-event {
    grid-template-columns: 66px minmax(0, 1fr);
    gap: 10px;
    padding: 11px 8px;
    border-radius: 12px;
  }

  .today-event.conflict-option {
    margin: 4px 0;
  }

  .event-clock {
    font-size: 16px;
    line-height: 1.15;
  }

  .event-clock small {
    margin-top: 4px;
    font-size: 13px;
  }

  .today-event h3 {
    margin: 0 0 4px;
    font-size: 17px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .today-event p {
    font-size: 14px;
    line-height: 1.3;
  }

  .today-badge {
    margin-top: 7px;
    padding: 3px 8px;
    font-size: 11px;
  }

  .today-conflict-head {
    gap: 3px;
    margin: 8px 0 6px;
    padding: 9px 11px;
    border-left-width: 4px;
    font-size: 13px;
    line-height: 1.3;
  }

  .today-leg {
    gap: 3px;
    margin: 5px 2px;
    padding: 9px 11px;
    border-left-width: 4px;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.32;
  }

  .today-leg b,
  .today-leg strong {
    font-size: 14px;
  }

  .today-leg.ambiguous {
    padding-top: 9px;
    padding-bottom: 9px;
  }

  /* Existing global navigation becomes one horizontal row instead of three. */
  .layout > nav {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 2px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap !important;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom)) !important;
    min-height: 64px;
    max-height: 76px;
  }

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

  .layout > nav button {
    flex: 0 0 64px !important;
    min-width: 64px !important;
    min-height: 54px !important;
    padding: 5px 3px !important;
    border-radius: 12px !important;
    scroll-snap-align: start;
  }

  .layout > nav button span {
    max-width: 62px;
    font-size: 10px !important;
    line-height: 1.1;
    white-space: normal;
  }

  body:has(#today-alpha3-view) .layout > nav button.active,
  body:has(#today-alpha3-view) .layout > nav button[data-v6="today"] {
    background: #fff1f2 !important;
    color: #991b1b !important;
  }

  body:has(#today-alpha3-view) .layout > nav button[data-page="home"].active {
    background: transparent !important;
    color: inherit !important;
  }
}

@media (max-width: 370px) {
  #today-alpha3-view { padding-inline: 8px; }
  .today-days { grid-template-columns: 42px minmax(0, 1fr) 42px; }
  .today-days [data-today] { grid-column: 1 / -1; }
  .sim-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sim-controls input { grid-column: 1 / -1; }
  .today-event { grid-template-columns: 60px minmax(0, 1fr); }
}

/* Second mobile pass: narrow date row, compact empty state, collapsible simulation, calendar pan. */
@media (max-width: 700px) {
  body > #app > header,
  #app > header {
    min-height: 0;
    padding: 12px 16px;
    gap: 10px;
  }
  #app > header .header-brand strong { font-size: 24px; line-height: 1.05; }
  #app > header .header-brand small { font-size: 12px; line-height: 1.35; }
  #app > header .header-actions { gap: 6px; }
  #app > header .header-actions button { min-height: 40px; padding: 7px 10px; font-size: 13px; }
  #refresh-now { max-width: 96px; }

  .today-hero.empty { padding: 18px 14px; text-align: center; }
  .today-hero.empty h2 {
    max-width: 320px;
    margin: 7px auto 9px;
    font-size: clamp(24px, 7.2vw, 29px);
    line-height: 1.12;
  }
  .today-hero.empty p { margin: 0 auto; font-size: 15px; }

  .today-simulation { position: relative; }
  .today-simulation > div:first-child { padding-right: 82px; }
  .today-sim-toggle {
    position: absolute;
    top: 7px;
    right: 8px;
    min-height: 32px;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    background: #fff;
    padding: 4px 8px;
    color: #334155;
    font-size: 11px;
    font-weight: 800;
  }
  .today-simulation:not(.expanded) .sim-controls,
  .today-simulation:not(.expanded) > p { display: none !important; }
  .today-simulation:not(.expanded) { min-height: 46px; }
  .today-simulation.expanded .sim-controls { display: grid; }

  #calendar-view {
    width: 100%;
    max-width: 100%;
    overflow-x: auto !important;
    overflow-y: visible;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 8px;
  }
  #calendar-view > * {
    min-width: 720px;
  }
  #calendar-view::before {
    content: "Scorri lateralmente per vedere gli eventi sovrapposti";
    display: block;
    position: sticky;
    left: 0;
    width: fit-content;
    max-width: calc(100vw - 32px);
    margin: 0 0 8px;
    border-radius: 999px;
    background: #f1f5f9;
    padding: 5px 9px;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
  }
}

@media (max-width: 430px) {
  .today-days {
    grid-template-columns: 46px minmax(0, 1fr) 46px;
  }
  .today-days [data-today] {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 40px;
  }
  .today-days input[type="date"] {
    min-width: 0;
    font-size: 15px;
    padding-inline: 8px;
  }
}

/* Calendar rollback: restore the original responsive geometry. */
@media (max-width: 700px) {
  #calendar-view {
    width: auto !important;
    max-width: none !important;
    overflow-x: visible !important;
    overflow-y: visible !important;
    overscroll-behavior-x: auto !important;
    padding-bottom: 0 !important;
    scrollbar-width: auto !important;
  }

  #calendar-view > * {
    min-width: 0 !important;
  }

  #calendar-view::before {
    content: none !important;
    display: none !important;
  }
}
