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

:root {
  --navy:    #0e1c2f;
  --navy2:   #162540;
  --amber:   #e8892b;
  --amber2:  #f5a94e;
  --sand:    #f5efe6;
  --sand2:   #ede4d6;
  --fog:     #c8bfb3;
  --white:   #fdfaf7;
  --radius:  10px;
}

html {
  height: 100%;
}
body {
  height: 100%;
  background: var(--navy);
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-weight: 300;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 68px;
  background: var(--navy2);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  position: relative;
  z-index: 1001;
}

.header-inner { display: flex; flex-direction: column; gap: 1px; }

.wordmark { display: flex; align-items: baseline; gap: 8px; }
.wordmark-cape {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fog);
}
.wordmark-sunsets {
  font-family: 'Playfair Display', serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--amber);
  letter-spacing: -0.01em;
}

.tagline {
  font-size: 0.72rem;
  color: var(--fog);
  letter-spacing: 0.04em;
}

.upload-btn {
  background: var(--amber);
  color: var(--navy);
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.1s;
}
.upload-btn:hover { background: var(--amber2); transform: translateY(-1px); }
.upload-btn:active { transform: translateY(0); }

/* ── Layout ──────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#map {
  flex: 1;
  min-width: 0;
  background: var(--navy);

}

/* ── Sidebar ─────────────────────────────────────── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--navy2);
  border-left: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-title {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  font-weight: 400;
  font-style: italic;
  color: var(--fog);
  padding: 18px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

#feed {
  overflow-y: auto;
  flex: 1;
}

#feed::-webkit-scrollbar { width: 4px; }
#feed::-webkit-scrollbar-track { background: transparent; }
#feed::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.feed-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: background 0.15s;
}
.feed-item:hover { background: rgba(255,255,255,0.04); }

.feed-thumb {
  width: 62px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.08);
}

.feed-info { flex: 1; min-width: 0; }
.feed-caption {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--sand);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.feed-time {
  font-size: 0.72rem;
  color: var(--sand);
  letter-spacing: 0.02em;
}
.feed-date {
  font-size: 0.68rem;
  color: var(--fog);
  letter-spacing: 0.03em;
}
.feed-date-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.feed-weather {
  font-size: 0.65rem;
  color: var(--amber2);
}

.feed-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--fog);
  font-size: 0.82rem;
  line-height: 1.6;
}

/* ── Modal ───────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,18,30,0.82);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--navy2);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 440px;
  position: relative;
  animation: modalIn 0.22s ease;
  display: flex;
  flex-direction: column;
}
.modal-form { display: flex; flex-direction: column; }

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

.modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none; border: none;
  color: var(--fog); font-size: 1rem;
  cursor: pointer; padding: 4px 8px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--white); }

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 4px;
}
.modal-sub {
  font-size: 0.8rem;
  color: var(--fog);
  margin-bottom: 22px;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed rgba(232,137,43,0.35);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--amber);
  background: rgba(232,137,43,0.06);
}
.drop-icon { font-size: 2rem; margin-bottom: 6px; color: var(--amber); }
.drop-zone p { font-size: 0.82rem; color: var(--fog); }
.drop-zone #preview {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 6px;
  margin-top: 10px;
}

/* Location */
.location-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--fog);
  margin-bottom: 14px;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
}
.loc-icon { color: var(--amber); font-size: 1rem; }

.caption-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--white);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  margin-bottom: 18px;
  outline: none;
  transition: border-color 0.2s;
}
.caption-input:focus { border-color: var(--amber); }
.caption-input::placeholder { color: var(--fog); }

.submit-btn {
  width: 100%;
  background: var(--amber);
  color: var(--navy);
  border: none;
  border-radius: var(--radius);
  padding: 13px;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
  letter-spacing: 0.02em;
}
.submit-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.submit-btn:not(:disabled):hover { background: var(--amber2); }

.submit-msg {
  margin-top: 12px;
  text-align: center;
  font-size: 0.82rem;
  min-height: 20px;
  line-height: 1.4;
}
.submit-msg.ok  { color: #6fcf97; }
.submit-msg.err { color: #eb5757; }
.submit-msg.pending { color: var(--amber2); }

/* ── Leaflet tweaks ───────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: var(--navy2);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-family: 'DM Sans', sans-serif;
}
.leaflet-popup-tip { background: var(--navy2); }
.leaflet-popup-close-button { display: none !important; }
.leaflet-popup-content { margin: 0; }
.popup-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px 8px 0 0;
  display: block;
}
.popup-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.popup-info { width: 100%; }
.popup-caption { font-size: 0.82rem; color: var(--sand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.popup-time { font-size: 0.75rem; color: var(--sand); }
.popup-date-row { display: flex; justify-content: space-between; align-items: center; }
.popup-date { font-size: 0.68rem; color: var(--fog); }
.popup-weather { font-size: 0.68rem; color: var(--amber2); }

.popup-btns {
  display: flex; flex-direction: row; gap: 6px; width: 100%;
}
.popup-share, .popup-close {
  flex: 1; border-radius: 6px; padding: 6px 10px; font-size: 0.78rem;
  cursor: pointer; font-family: 'DM Sans', sans-serif; transition: background 0.15s;
  white-space: nowrap; border: 1px solid;
}
.popup-share {
  background: rgba(232,137,43,0.15); border-color: rgba(232,137,43,0.3); color: var(--amber);
}
.popup-share:hover { background: rgba(232,137,43,0.25); }
.popup-close {
  background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); color: var(--fog);
}
.popup-close:hover { background: rgba(255,255,255,0.12); }
.popup-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-top: 1px solid rgba(255,255,255,0.07);
}
.popup-prev, .popup-next {
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.12);
  color: var(--white); border-radius: 6px; padding: 5px 10px;
  font-size: 0.78rem; cursor: pointer; font-family: 'DM Sans', sans-serif;
  transition: background 0.15s;
}
.popup-prev:hover:not(:disabled), .popup-next:hover:not(:disabled) { background: rgba(255,255,255,0.15); }
.popup-prev:disabled, .popup-next:disabled { opacity: 0.3; cursor: not-allowed; }
.popup-counter { font-size: 0.75rem; color: var(--fog); }

/* ── Fullscreen image overlay ─────────────────────── */
.img-fullscreen {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.img-fullscreen.open { display: flex; }
.img-fullscreen img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}
.popup-img { cursor: zoom-in; }


/* ── Button visibility by screen size ────────────── */
@media (min-width: 641px) and (hover: hover) {
  #aboutBtn { display: inline-block !important; }
}

/* ── Wordmark submit mode (mobile only) ──────────── */
@media (max-width: 640px), (pointer: coarse) and (max-width: 1024px) {
  #wordmarkLink.submit-mode {
    background: var(--amber);
    border-radius: var(--radius);
    padding: 8px 16px;
    transition: opacity 0.15s;
  }
  #wordmarkLink.submit-mode:active {
    opacity: 0.8;
  }
  #wordmarkLink.submit-mode .wordmark {
    display: none;
  }
  #wordmarkLink.submit-mode #tagline {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.01em;
    opacity: 1;
  }
}

/* ── Drag handle (hidden on desktop) ─────────────── */
.sidebar-handle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 10px 0 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-handle-pill {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.22);
  border-radius: 2px;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px), (pointer: coarse) and (max-width: 1024px) {
  #map {
    width: 100%;
    height: 100%;
  }

  .sidebar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 62px;
    border-left: none;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
    transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    z-index: 400;
  }

  .sidebar--open {
    height: 55vh;
  }

  .sidebar-handle { display: flex; }

  .sidebar-title { cursor: pointer; padding: 0 20px 12px; }

  #feed {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 1px; background: rgba(255,255,255,0.05);
    overflow-y: auto; flex: 1; min-height: 0;
  }

  .sidebar--open #feed { overflow-y: auto; }

  .feed-item { flex-direction: column; gap: 8px; padding: 10px; background: var(--navy2); border-bottom: none; }
  .feed-thumb { width: 100%; height: 90px; }
  .feed-caption { font-size: 0.75rem; }
  .feed-coords { display: none; }
  .feed-empty { grid-column: 1 / -1; }

  header { padding: 0 18px; }
  .header-inner { flex: 1; }
  .upload-btn { flex-shrink: 0; }
  .modal { margin: 16px; padding: 28px 20px; }
}

/* ── Landscape phone: hide header ────────────────── */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  header { display: none; }
}

/* ── Modal landscape layout (phone rotated) ──────── */
@media (pointer: coarse) and (orientation: landscape) and (max-height: 500px) {
  .modal-backdrop { align-items: center; }
  .modal {
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
    max-width: 680px;
    max-height: calc(100dvh - 16px);
    padding: 14px 16px;
    overflow-y: auto;
    margin: 8px;
  }
  .drop-zone {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
    padding: 16px 12px;
  }
  .drop-zone #preview { max-height: 130px; }
  .drop-icon { font-size: 1.4rem; margin-bottom: 4px; }
  .drop-zone p { font-size: 0.72rem; }
  .modal-form { width: 190px; flex-shrink: 0; }
  .modal-title { font-size: 1.1rem; margin-bottom: 2px; }
  .modal-sub { font-size: 0.75rem; margin-bottom: 8px; }
  .location-row { margin-bottom: 6px; padding: 6px 10px; font-size: 0.72rem; }
  .modal-close { top: 8px; right: 10px; }
}
