/* V1.3 – clean responsive / mobile-first overrides */

@media (max-width: 820px) {
  html,
  body {
    width: 100%;
    overflow-x: hidden;
  }

  body {
    padding-top: 58px;
  }

  .site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 58px;
    padding: 0 12px;
    gap: 10px;
  }

  .brand {
    min-width: 0;
    flex: 1 1 auto;
    gap: 9px;
  }

  .brand-profile {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
  }

  .brand-copy {
    min-width: 0;
  }

  .brand-copy strong {
    display: block;
    max-width: 210px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    letter-spacing: .08em;
  }

  .brand-copy small,
  .brand-road {
    display: none;
  }







  .map-shell {
    height: calc(100dvh - 58px);
    min-height: 620px;
    scroll-margin-top: 58px;
  }

  .route-browser {
    position: absolute;
    top: 12px;
    left: 10px;
    width: calc(100% - 20px);
    max-height: 282px;
    padding: 12px;
    overflow: hidden;
    border-radius: 16px;
  }

  .route-browser::before {
    left: 12px;
    width: 50px;
  }

  .browser-heading {
    display: block;
  }

  .browser-heading h1 {
    margin: 0 0 9px;
    font-size: 17px;
    line-height: 1;
    letter-spacing: -.01em;
  }

  .search-box {
    height: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 11px;
  }

  .search-box svg {
    width: 18px;
    flex: 0 0 18px;
  }

  .search-box input {
    min-width: 0;
    font-size: 15px;
  }

  .search-box input::placeholder {
    font-size: 14px;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-top: 9px;
  }

  .filter-chip {
    min-width: 0;
    min-height: 34px;
    padding: 0 6px;
    font-size: 12px;
    white-space: nowrap;
  }

  .result-summary {
    margin: 10px 2px 7px;
    font-size: 11px;
  }

  .text-button {
    font-size: 11px;
  }

  .route-list {
    max-height: 126px;
    overflow-y: auto;
    padding-right: 2px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .route-list-item {
    min-height: 74px;
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
  }

  .route-list-thumb {
    width: 84px;
    border-radius: 8px;
  }

  .route-list-copy {
    min-width: 0;
  }

  .route-list-title {
    font-size: 13px;
  }

  .route-list-meta {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 10px;
  }

  .route-list-description {
    display: none;
  }

  .route-card {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: 52dvh;
    padding: 17px;
    overflow-y: auto;
    border-radius: 18px;
  }

  .route-card-media {
    margin: -17px -17px 14px;
    aspect-ratio: 16 / 8.5;
  }

  .route-card-play {
    width: 46px;
    height: 46px;
    font-size: 16px;
  }

  .route-card h2 {
    margin-right: 38px;
    font-size: 21px;
  }

  .route-location {
    font-size: 12px;
  }

  .route-stats {
    gap: 22px;
    margin: 14px 0;
    padding: 12px 0;
  }

  #route-card-description {
    font-size: 12px;
  }

  .route-card-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
  }

  .button {
    min-height: 42px;
    font-size: 12px;
  }

  .map-legend {
    display: none;
  }

  .about-section {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 56px 18px;
    scroll-margin-top: 58px;
  }

  .about-text h2 {
    font-size: clamp(34px, 10vw, 48px);
  }

  .about-image img {
    min-height: 260px;
  }
}

@media (max-width: 390px) {
  .brand-copy strong {
    max-width: 170px;
    font-size: 11px;
  }

  .route-browser {
    max-height: 268px;
  }

  .filter-chip {
    font-size: 11px;
  }

  .route-list-item {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .route-list-thumb {
    width: 76px;
  }

  .route-card {
    max-height: 50dvh;
  }

  .route-card-actions {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (max-width: 950px) {
  .site-header {
    height: 54px;
  }

  .main-nav {
    top: 54px;
  }

  .map-shell {
    height: calc(100dvh - 54px);
    min-height: 430px;
  }

  .route-browser {
    width: min(460px, calc(100% - 20px));
    max-height: calc(100% - 24px);
  }

  .route-list {
    max-height: 94px;
  }

  .route-card {
    width: min(390px, calc(100% - 20px));
    max-height: calc(100% - 20px);
  }
}


@media (max-width: 820px) {
  .site-header {
    gap: 8px;
  }

  .brand {
    flex: 1 1 auto;
  }

  .brand-copy strong {
    max-width: 155px;
  }

  .main-nav {
    position: static;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .main-nav a {
    display: block;
    padding: 18px 0 14px;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    border: 0;
  }

  .main-nav a:hover,
  .main-nav a.active {
    color: var(--text);
  }

  .main-nav a.active::after {
    content: "";
    display: block;
    height: 2px;
    margin-top: 6px;
    background: var(--accent);
  }

  .about-section.active-view {
    display: grid;
    min-height: calc(100dvh - 58px);
  }
}

@media (max-width: 460px) {
  .brand-profile {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .brand-copy strong {
    max-width: 118px;
    font-size: 10px;
    letter-spacing: .06em;
  }

  .main-nav {
    gap: 9px;
  }

  .main-nav a {
    font-size: 11px;
  }
}


@media (max-width: 820px) {
  .browser-heading h1 {
    color: var(--accent);
  }

  .route-card-nav {
    margin-top: 12px;
    padding-top: 10px;
  }

  .route-nav-button {
    min-height: 32px;
    font-size: 10px;
  }
}


/* V1.4 – mobil som trinnvis arbeidsflyt */
@media (max-width: 820px) {
  .route-browser {
    max-height: none;
  }

  .browser-heading h1 {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 15px;
    letter-spacing: .14em;
  }

  .mobile-back-button {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #ef6166;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-results-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
  }

  .mobile-results-header strong {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
  }

  /* SEARCH MODE */
  body[data-mobile-mode="search"] .route-browser {
    max-height: 210px;
  }

  body[data-mobile-mode="search"] .result-summary,
  body[data-mobile-mode="search"] .route-list {
    display: none;
  }

  /* RESULTS MODE */
  body[data-mobile-mode="results"] .route-browser {
    max-height: min(50dvh, 430px);
    overflow: hidden;
  }

  body[data-mobile-mode="results"] .browser-heading,
  body[data-mobile-mode="results"] .search-box,
  body[data-mobile-mode="results"] .filters,
  body[data-mobile-mode="results"] .result-summary {
    display: none;
  }

  body[data-mobile-mode="results"] .mobile-results-header {
    display: flex;
  }

  body[data-mobile-mode="results"] .route-list {
    display: grid;
    max-height: calc(min(50dvh, 430px) - 60px);
    overflow-y: auto;
  }

  /* DETAIL MODE */
  body[data-mobile-mode="detail"] .route-browser {
    display: none;
  }

  body[data-mobile-mode="detail"] .route-card {
    display: block;
    top: auto;
    bottom: 10px;
    max-height: 44dvh;
    overflow-y: auto;
  }

  body[data-mobile-mode="detail"] .route-card.open {
    opacity: 1;
    pointer-events: auto;
  }

  .route-back-button {
    display: none;
  }

  body[data-mobile-mode="detail"] .route-back-button {
    display: inline-flex;
    margin-bottom: 8px;
  }

  body[data-mobile-mode="detail"] .route-card-media {
    aspect-ratio: 16 / 7.2;
  }

  body[data-mobile-mode="detail"] .route-card h2 {
    font-size: 20px;
  }

  body[data-mobile-mode="detail"] .route-stats {
    margin: 10px 0;
    padding: 10px 0;
  }

  body[data-mobile-mode="detail"] #route-card-description {
    margin-bottom: 8px;
  }

  body[data-mobile-mode="detail"] .route-card-nav {
    margin-top: 10px;
    padding-top: 10px;
  }
}


/* V1.4.3 – mobil detaljvisning */
@media (max-width: 820px) {
  body[data-mobile-mode="detail"] .route-card {
    bottom: 10px;
    max-height: 48dvh;
    padding: 16px;
    overflow-y: auto;
  }

  body[data-mobile-mode="detail"] .route-card-media {
    display: none;
  }

  body[data-mobile-mode="detail"] .route-back-button {
    margin-bottom: 6px;
  }

  body[data-mobile-mode="detail"] .route-card-kicker {
    margin-bottom: 7px;
  }

  body[data-mobile-mode="detail"] .route-card h2 {
    margin-top: 0;
    margin-bottom: 4px;
    font-size: 20px;
    line-height: 1.05;
  }

  body[data-mobile-mode="detail"] .route-location {
    font-size: 11px;
    line-height: 1.35;
  }

  body[data-mobile-mode="detail"] .route-stats {
    margin: 9px 0;
    padding: 8px 0;
  }

  body[data-mobile-mode="detail"] .route-stats strong {
    font-size: 16px;
  }

  body[data-mobile-mode="detail"] #route-card-description {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
  }

  body[data-mobile-mode="detail"] .route-card-nav {
    margin-top: 9px;
    padding-top: 8px;
  }

  body[data-mobile-mode="detail"] .route-card-actions {
    margin-top: 9px;
  }
}


/* V1.4.4 – mobile route detail above map */
@media (max-width: 820px) {
  .mobile-route-summary {
    display: none;
  }

  body[data-mobile-mode="detail"] .route-card {
    top: 12px;
    right: 10px;
    bottom: auto;
    width: calc(100% - 20px);
    max-height: 250px;
    padding: 14px 16px;
    overflow-y: auto;
    border-radius: 18px;
  }

  body[data-mobile-mode="detail"] .mobile-route-summary {
    display: block;
  }

  body[data-mobile-mode="detail"] .route-back-button {
    display: inline-flex;
    margin: 0 0 8px;
  }

  body[data-mobile-mode="detail"] .mobile-route-summary-copy {
    display: grid;
    gap: 3px;
  }

  body[data-mobile-mode="detail"] .mobile-route-type {
    width: fit-content;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(217,39,46,.14);
    color: #ef6166;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  body[data-mobile-mode="detail"] #mobile-route-title {
    margin: 0;
    font-size: 20px;
    line-height: 1.05;
  }

  body[data-mobile-mode="detail"] #mobile-route-location {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 11px;
  }

  /* Hide duplicate desktop-style header elements in detail mode. */
  body[data-mobile-mode="detail"] .route-card-kicker,
  body[data-mobile-mode="detail"] #route-card-title,
  body[data-mobile-mode="detail"] #route-card-location {
    display: none;
  }

  body[data-mobile-mode="detail"] .route-stats {
    margin: 8px 0;
    padding: 8px 0;
  }

  body[data-mobile-mode="detail"] #route-card-description {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
  }

  body[data-mobile-mode="detail"] .route-card-nav {
    margin-top: 8px;
    padding-top: 8px;
  }

  body[data-mobile-mode="detail"] .route-card-actions {
    margin-top: 8px;
  }
}


/* V1.4.6 – desktop search presentation; mobile flow is unchanged. */
@media (min-width: 821px) {
  .route-browser {
    padding-top: 13px;
  }

  .browser-heading h1 {
    margin: 0 0 10px;
    color: var(--accent);
    font-size: 11px;
    letter-spacing: .15em;
  }

  body:not(.desktop-search-performed) .result-summary,
  body:not(.desktop-search-performed) .route-list {
    display: none;
  }
}

@media (max-width: 820px) and (orientation: landscape) {
  body {
    padding-top: 54px;
  }
}


/* V1.4.7 – one desktop heading, above the video, with room for long titles. */
@media (min-width: 821px) {
  .mobile-route-summary { display: none; }
  .route-card { max-height: calc(100% - 48px); overflow-y: auto; }
  .route-card-content { display: flex; flex-direction: column; }
  .route-card-kicker { order: -3; padding-right: 36px; }
  #route-card-title { order: -2; overflow-wrap: anywhere; }
  #route-card-location { order: -1; margin-bottom: 16px; }
  .route-card-media { flex-shrink: 0; margin: 0 0 20px; }
}


/* V1.4.8 – preserve the full landscape photograph on all screens. */
.about-image img {
  height: auto;
  min-height: 0;
}
