/* 
  Mobile-first layout rules for wewent.to
  Breakpoints:
  - Phone portrait: orientation: portrait and max-width: 599px (baseline)
  - Phone landscape: orientation: landscape and max-height: 500px
  - Tablet portrait: orientation: portrait and min-width: 600px
  - Tablet landscape: orientation: landscape and min-height: 501px
*/

:root {
  --header-height: 90px;
}

/* ==========================================================================
   1. Phone Portrait (Baseline)
   ========================================================================== */

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* Navigation */
header {
  height: var(--header-height);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background-color: #005f73;
  
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 0 16px;
  box-sizing: border-box;
}

header nav {
  display: none !important; /* Hide desktop/tablet landscape nav */
}

.mobile-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.mobile-wordmark {
  font-weight: bold;
  font-size: 1.2rem;
  text-decoration: none;
  color: white;
}

.hamburger-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  font-weight: bold;
  padding: 0;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-drawer {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  background: white;
  border-bottom: 1px solid #eee;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  display: none;
  flex-direction: column;
  z-index: 999;
  max-height: calc(100dvh - var(--header-height));
  overflow-y: auto;
}

.mobile-drawer.open {
  display: flex;
}

.drawer-item {
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  text-decoration: none;
  color: #333;
}

.drawer-item.active {
  font-weight: bold;
  border-left: 4px solid #007bff;
  padding-left: 12px;
  background-color: #f8f9fa;
}

.drawer-divider {
  height: 1px;
  background: #eee;
  margin: 0;
  border: none;
}

/* Adjust main content for fixed header */
main {
  margin-top: var(--header-height);
  padding: 12px;
  box-sizing: border-box;
}

/* Journey Grid & Cards (Index/Explore) */
.journey-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  overflow-y: auto;
}

.journey-card {
  background: white;
  border-radius: 8px;
  border: 1px solid #eee;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.journey-card-content {
  padding: 0;
}

.journey-card-main-link {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  padding: 12px;
}

.journey-card-main-link .cover {
  width: 100%;
  aspect-ratio: 256 / 160;
  height: auto;
  flex-shrink: 0;
  margin-right: 0;
}

.journey-card-main-link .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}

.journey-card-main-link .title {
  margin: 0 0 4px 0;
  font-size: 1.1rem;
  font-weight: bold;
  overflow-wrap: break-word;
  min-width: 0;
}

.journey-card-main-link .desc {
  margin: 0 0 8px 0;
  font-size: 0.9rem;
  color: #666;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.journey-card-main-link .meta {
  margin: 0;
  font-size: 0.8rem;
  color: #999;
}

.tags-list {
  padding: 0 12px 12px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Create button on phone portrait */
.journey-header .add-btn {
  width: 100%;
  margin-top: 12px;
  height: 44px;
}

.journey-title-row {
  display: flex;
  flex-direction: column;
}

/* Journey Edit - Mobile */
.journey-mobile-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  margin: -12px; /* Negate main padding */
}

.mobile-header {
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  background: white;
}

.mobile-header .journey-title-row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.mobile-header .journey-title {
  margin: 0;
  font-size: 1.25rem;
  overflow-wrap: break-word;
  min-width: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #007bff;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: black;
  font-weight: bold;
}

.tab-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden; /* Prevent container-level scrolling */
}

.journey-tabs {
  display: flex;
  background: white;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: var(--header-height);
  z-index: 100;
}

.tab-btn {
  flex: 1;
  padding: 12px 0;
  border: none;
  background: none;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  position: relative;
  color: #666;
}

.tab-btn.active {
  color: #007bff;
  font-weight: bold;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 2px;
  background: #007bff;
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  flex: 1; /* Force the active tab to grow */
}

#map-tab {
  flex: 1;
  overflow: hidden; /* Map handles its own panning */
}


/* Phone Photos Grid */
.thumb-strip {
  display: block;
}

.thumb-strip .thumb-btn {
  display: none;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.info-sections {
  padding: 16px;
}

.info-sections section {
  margin-bottom: 24px;
}

.track-list, .access-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.track-item, .photo-track-item, .access-item {
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Modals */
.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 90dvh;
  background: white;
  z-index: 2000;
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  display: none;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease-out;
}

.modal.hidden {
    display: none !important;
}

.modal.active {
  display: flex !important;
  transform: translateY(0);
}

.modal-content {
  overflow-y: auto;
  padding: 20px;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid #eee;
  background: #f8f9fa;
  display: flex;
  gap: 12px;
}

.modal-footer .btn {
  flex: 1;
}

/* Image Overlay */
.image-overlay {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 3000;
  display: flex;
  flex-direction: column;
}

.overlay-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.image-panel {
  position: relative;
  flex: 1;
  max-height: 60dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.overlay-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.5rem;
  z-index: 10;
}

.meta-panel {
  flex: 1;
  background: white;
  border-radius: 12px 12px 0 0;
  overflow-y: auto;
  padding: 16px;
}

.mini-map {
  height: 140px;
  border-radius: 8px;
  margin-bottom: 12px;
}

/* Description Overlay */
.description-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1100;
  display: flex;
  align-items: flex-end;
}

.description-overlay.hidden {
  display: none;
}

.description-content {
  background: white;
  width: 100%;
  padding: 24px;
  border-radius: 16px 16px 0 0;
  max-height: 80dvh;
  overflow-y: auto;
}

/* ==========================================================================
   2. Phone Landscape
   ========================================================================== */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --header-height: 44px;
  }
  
  header { height: var(--header-height); }
  
  .journey-tabs {
    height: 40px;
    top: var(--header-height);
  }
  
  .tab-btn { padding: 8px 0; }
  
  #map-tab {
    height: calc(100dvh - var(--header-height) - 40px - 44px);
  }
  
  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .journey-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .journey-card-main-link {
    flex-direction: column;
  }
  
  .journey-card-main-link .cover {
    width: 100%;
    height: 100px;
    margin-right: 0;
    margin-bottom: 8px;
  }
  
  .modal {
    max-height: 85dvh;
  }

  .overlay-container {
    flex-direction: row;
  }

  .image-panel {
    flex: 6;
    max-height: 100dvh;
  }

  .meta-panel {
    flex: 4;
    border-radius: 0;
    height: 100%;
  }

  .mini-map {
    height: 120px;
  }
}

/* ==========================================================================
   3. Tablet Portrait
   ========================================================================== */
@media (min-width: 600px) {
  .journey-tabs {
    display: none !important;
  }
  
  .tab-content {
    display: block !important;
    flex: none;
    overflow: visible;
  }
  
  #map-tab {
    height: 45vw !important;
    min-height: 280px;
    max-height: 420px;
  }
  
  /* Tablet Strip */
  .thumb-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
  }

  .thumb-strip .thumb-btn {
    display: flex;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
  }

  .photo-grid {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    padding: 0;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-width: 0;
  }
  
  .photo-grid img {
    width: auto;
    height: 120px;
    aspect-ratio: auto;
    flex-shrink: 0;
  }

  .info-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    padding: 24px 0;
  }
}

@media (orientation: portrait) and (min-width: 600px) {
  .journey-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  
  .journey-card-main-link {
    flex-direction: column;
  }
  
  .journey-card-main-link .cover {
    width: 100%;
    height: 160px;
    margin-right: 0;
    margin-bottom: 12px;
  }
  
  .modal {
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    width: 90%;
    max-width: 480px;
    border-radius: 8px;
    max-height: 90dvh;
  }

  .image-panel {
    max-height: 55dvh;
  }

  .mini-map {
    height: 180px;
  }
}

/* ==========================================================================
   4. Tablet Landscape
   ========================================================================== */
@media (orientation: landscape) and (min-height: 501px) {
  .tablet-landscape-nav {
    display: flex !important;
    gap: 16px;
  }
  
  .mobile-top-bar {
    display: none;
  }
  
  .journey-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  main {
    padding: 0;
  }

  .journey-mobile-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin: 0;
  }
  
  .tab-container {
    display: grid !important;
    grid-template-columns: minmax(200px, 25%) 1fr;
    grid-template-rows: minmax(200px, 1fr) 140px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  
  .journey-tabs {
    display: none !important;
  }

  .tab-content {
    display: flex !important; /* Force all tabs visible in landscape */
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: static !important;
    width: auto !important;
    background: white;
  }

  #info-tab {
    grid-area: 1 / 1 / 3 / 2;
    border-right: 1px solid #eee;
    overflow-y: auto;
  }
  
  #map-tab {
    grid-area: 1 / 2 / 2 / 3;
    min-width: 320px;
    height: 100% !important; /* Override Tablet Portrait height: 45vw !important */
    min-height: 0 !important; /* Override Tablet Portrait min-height: 280px */
    position: relative; /* Create stacking context for clipping */
    overflow: hidden;
  }

  #map-container {
    flex: 1;
    min-height: 0; /* Allow shrinking */
    display: flex;
    flex-direction: column;
  }

  #map {
    flex: 1;
    min-height: 0;
  }
  
  #photos-tab {
    grid-area: 2 / 2 / 3 / 3;
    height: 140px;
    border-top: 1px solid #eee;
    overflow-x: auto;
    overflow-y: hidden;
    z-index: 10; /* Ensure it stays above map if there's any overflow */
  }

  .thumb-strip {
    height: 100%;
    padding: 10px;
  }

  .info-sections {
    display: block;
    padding: 16px;
  }

  .overlay-container {
    flex-direction: row;
  }

  .image-panel {
    flex: 65;
    max-height: 100dvh;
  }

  .meta-panel {
    flex: 35;
    border-radius: 0;
    height: 100%;
  }

  .mini-map {
    height: 220px;
  }
}

/* Account Page Styles */
.account-form label {
  display: block;
  margin-top: 16px;
  font-weight: bold;
}

.account-form input[type="file"],
.account-form input[type="text"],
.account-form textarea {
  width: 100% !important;
  box-sizing: border-box;
  margin-top: 4px;
}

.account-form-buttons button {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  margin-top: 24px;
}

.danger-zone {
  margin-top: 40px;
  padding: 16px;
  border: 1px solid #ffcccc;
  background-color: #fffafa;
  border-radius: 8px;
}

.danger-button {
  width: 100%;
  padding: 12px;
  background-color: #d9534f;
  color: white;
  border: none;
  border-radius: 4px;
  font-weight: bold;
}

@media (min-width: 600px) {
  .account-form-buttons button, .danger-button {
    width: auto;
    padding: 8px 24px;
  }
}

/* Auth Pages (Login/Register) */
.centre form {
  width: 100%;
  max-width: 100%;
  padding: 0;
}

.centre input {
  width: 100%;
  box-sizing: border-box;
}

.centre .btn-primary, .centre button[type="submit"] {
  width: 100%;
  padding: 12px;
}

@media (min-width: 600px) {
  .centre .btn-primary, .centre button[type="submit"] {
    width: auto;
  }
}

/* Help Page - Mobile padding */
.help-body {
  padding: 0 16px;
}
