/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  --primary:        #90B88E;
  --secondary_light:#DDC1EC;
  --secondary_dark: #7D7ABC;
  --tertiary:       #C06E52;
  --dark:           #30362F;
  --light:          #FFEDDF;
  --radius-lg:      20px;
  --radius-md:      14px;
  --shadow-soft:    0 12px 30px rgba(48, 54, 47, 0.10);
  --shadow-soft-2:  0 18px 45px rgba(48, 54, 47, 0.14);
}

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

html {
  -webkit-text-size-adjust: 100%;
}

/* ── Base ────────────────────────────────────────────────────────────────── */
body {
  background:
    linear-gradient(rgba(0,0,0,0.45), rgba(0,0,0,0.45)),
    url("/static/images/background.webp");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  min-height: 100vh;
  color: var(--dark);
  margin: 0;
  padding: 0 0 2rem;
}

body > * {
  width: min(960px, calc(100% - 2rem));
  margin-left: auto;
  margin-right: auto;
}

h1 {
  margin: 2.5rem auto 1rem;
  font-size: clamp(2rem, 3vw, 2.8rem);
  color: white;
  text-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

h2 {
  color: var(--light);
}

/* ── Navigation ──────────────────────────────────────────────────────────── */
nav {
  display: flex;
  gap: 0.75rem;
  padding: 0.8rem;
  border-radius: var(--radius-lg);
  background: white;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  margin-bottom: 2rem;
  align-items: center;
  flex-wrap: wrap;
}

nav a {
  text-decoration: none;
  font-weight: 800;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  transition: transform 0.15s ease, background 0.2s ease;
}

nav a:hover {
  background: var(--secondary_light);
  transform: translateY(-2px);
}

nav a.nav-auth {
  margin-left: auto;
  background: var(--tertiary);
}

nav a.nav-auth:hover {
  background: var(--secondary_dark);
}

/* Upload button in nav — matches anchor pill style exactly */
#navUploadBtn {
  text-decoration: none;
  font-weight: 800;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: var(--secondary_light);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  transition: transform 0.15s ease, background 0.2s ease;
  box-shadow: none;
  width: auto;
  letter-spacing: normal;
}

#navUploadBtn:hover {
  background: var(--secondary_light);
  transform: translateY(-2px);
  box-shadow: none;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
form {
  background: white;
  padding: 2rem;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px rgba(0,0,0,0.18);
  margin-bottom: 3rem;
}

label {
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 0.4rem;
  display: block;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  padding: 0.9rem;
  border-radius: var(--radius-md);
  border: 2px solid var(--primary);
  margin-bottom: 1.2rem;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 3rem;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="file"]:focus {
  outline: none;
  border-color: var(--secondary_dark);
  box-shadow: 0 0 0 4px rgba(125,122,188,0.25);
}

button[type="submit"] {
  width: 100%;
  padding: 1rem;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--secondary_dark));
  color: white;
  box-shadow: 0 18px 35px rgba(0,0,0,0.25);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

button[type="submit"]:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 25px 50px rgba(0,0,0,0.35);
}

.error-message {
  background: var(--tertiary);
  color: white;
  padding: 1rem;
  border-radius: var(--radius-md);
  font-weight: 800;
  margin-bottom: 1.2rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

/* ── Tag pill input (upload & edit forms) ────────────────────────────────── */
.tag-input-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius-md);
  background: white;
  margin-bottom: 1.2rem;
  cursor: text;
}

.tag-input-wrapper:focus-within {
  border-color: var(--secondary_dark);
  box-shadow: 0 0 0 4px rgba(125,122,188,0.25);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.tag-pill button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  width: auto;
  box-shadow: none;
  font-weight: 900;
}

.tag-pill button:hover {
  transform: none;
  box-shadow: none;
  color: var(--light);
}

#tagTextInput,
#editTagTextInput {
  border: none;
  outline: none;
  font-size: 1rem;
  flex: 1;
  min-width: 120px;
  padding: 0.2rem;
  margin-bottom: 0;
}

.tag-hint {
  font-size: 0.85rem;
  color: #7D7ABC;
  margin-top: -1rem;
  margin-bottom: 1.2rem;
}

/* ── Gallery grid ────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

/* Legacy .grid img rule (kept for backwards compat) */
.grid img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-radius: var(--radius-md);
  border: 3px solid var(--primary);
  box-shadow: 0 15px 35px rgba(0,0,0,0.25);
}

.grid img:hover {
  transform: scale(1.05);
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}

#searchStatus {
  color: white;
}

/* ── Gallery cards ───────────────────────────────────────────────────────── */
.grid-card {
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 3px solid var(--primary);
  box-shadow: 0 15px 35px rgba(0,0,0,0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grid-card:hover {
  transform: scale(1.04);
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
}

.grid-card img {
  width: 100%;
  height: clamp(190px, 28vw, 240px);
  object-fit: cover;
  display: block;
  border-radius: 0;
  border: none;
  box-shadow: none;
  transition: none;
}

.grid-card:hover img {
  transform: none;
  box-shadow: none;
}

.card-tag-strip {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(48,54,47,0.75);
  padding: 0.3rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.card-tag {
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

/* ── Road warning badge ──────────────────────────────────────────────────── */
.road-warning {
  position: absolute;
  top: 0.45rem;
  left: 0.45rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.3px;
  pointer-events: none;
}

.road-warning.yellow { background: #F5C518; color: #3a2e00; }
.road-warning.red    { background: #D32F2F; color: white; }
.road-warning.black  { background: #1a1a1a; color: white; }
.road-warning.addr   { background: var(--secondary_dark); color: white; }

/* ── Search tag pills (gallery search bar) ───────────────────────────────── */
.search-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--secondary_dark);
  color: white;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.search-tag-pill button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  width: auto;
  box-shadow: none;
  font-weight: 900;
}

.search-tag-pill button:hover {
  transform: none;
  box-shadow: none;
  color: var(--light);
}

#activeTags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  min-height: 1.5rem;
}

/* ── Infinite scroll ─────────────────────────────────────────────────────── */
#feedSentinel { height: 1px; }

#feedLoader {
  text-align: center;
  color: var(--light);
  padding: 1rem;
  font-weight: 700;
}

/* ── Shared modal base ───────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(0,0,0,0.45);
  color: white;
  border: none;
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  padding: 0;
}

.modal-close-btn:hover {
  background: var(--tertiary);
  transform: none;
  box-shadow: none;
}

/* ── Upload modal (slide-up sheet) ──────────────────────────────────────── */
#uploadOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 600;
  justify-content: center;
  align-items: flex-end;
}

#uploadOverlay.open { display: flex; }

#uploadPanel {
  background: white;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -20px 60px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 2rem 2rem 2.5rem;
  position: relative;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

#uploadPanelClose {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.12);
  color: var(--dark);
  border: none;
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  padding: 0;
}

#uploadPanelClose:hover {
  background: var(--tertiary);
  color: white;
  transform: none;
  box-shadow: none;
}

#uploadPanel h2 {
  margin: 0 0 1.2rem;
  color: var(--dark);
  font-size: 1.3rem;
}

#uploadPanel form {
  box-shadow: none;
  padding: 0;
  border-radius: 0;
  margin-bottom: 0;
}

/* ── Detail modal (gallery & my uploads) ─────────────────────────────────── */
#detailOverlay,
#myDetailOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  z-index: 700;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

#detailOverlay.open,
#myDetailOverlay.open {
  display: flex;
}

#detailPanel,
#myDetailPanel {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0,0,0,0.4);
  max-width: 620px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#detailPanel img,
#myDetailPanel img {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: none;
  box-shadow: none;
}

#detailPanel img:hover,
#myDetailPanel img:hover {
  transform: none;
  box-shadow: none;
}

#detailBody,
#myDetailBody {
  padding: 1.4rem;
}

#detailPanelWrap,
#myDetailPanelWrap {
  position: relative;
}

#detailClose,
#myDetailClose {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(0,0,0,0.45);
  color: white;
  border: none;
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  padding: 0;
}

#detailClose:hover,
#myDetailClose:hover {
  background: var(--tertiary);
  transform: none;
  box-shadow: none;
}

.detail-row { margin-bottom: 1rem; }

.detail-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.detail-label {
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--secondary_dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.detail-tag-pill {
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.detail-tag-pill:hover {
  background: var(--secondary_dark);
  transform: translateY(-1px);
}

.detail-tag-pill.active-tag {
  background: var(--secondary_dark);
  outline: 2px solid var(--secondary_light);
}

.detail-location-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  color: var(--secondary_dark);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.95rem;
}

.detail-location-link:hover {
  color: var(--tertiary);
  text-decoration: underline;
}

.detail-location-text {
  font-size: 0.95rem;
  color: var(--dark);
}

/* ── My Uploads page ─────────────────────────────────────────────────────── */
#myUploadsStatus {
  color: var(--light);
  font-weight: 700;
  padding: 0.5rem 0;
}

#myUploadsError {
  color: var(--tertiary);
  font-weight: 800;
  margin-top: 0.5rem;
}

.my-upload-card {
  display: block;
}

.my-card-img-wrap {
  position: relative;
  overflow: hidden;
}

.my-card-img-wrap img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

/* ── Detail modal inline edit controls ──────────────────────────────────── */
.detail-edit-btn {
  font-size: 0.9rem;
  font-weight: 800;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: none;
  background: var(--secondary_dark);
  color: white;
  cursor: pointer;
  margin-left: 0.5rem;
  vertical-align: middle;
  transition: background 0.15s ease, transform 0.1s ease;
  box-shadow: none;
  width: auto;
  letter-spacing: normal;
}

.detail-edit-btn:hover {
  background: var(--primary);
  transform: translateY(-1px);
  box-shadow: none;
}

.detail-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.detail-edit-section {
  display: none;
  margin-top: 0.6rem;
}

.detail-edit-footer {
  display: none;
  justify-content: flex-end;
}

#myDetailBody.is-editing .detail-edit-section,
#myDetailBody.is-editing .detail-edit-footer {
  display: flex;
}

#myDetailBody.is-editing #editTagsSection,
#myDetailBody.is-editing #editAddressSection,
#myDetailBody.is-editing #editLocationSection {
  display: block;
}

#myDetailBody.is-editing .detail-edit-toggle {
  display: none;
}

.detail-save-btn,
.detail-cancel-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.1s ease;
  box-shadow: none;
  width: auto;
  letter-spacing: normal;
}

.detail-save-btn {
  background: var(--primary);
  color: white;
}

.detail-save-btn:hover { transform: translateY(-1px); box-shadow: none; }

.detail-cancel-btn {
  background: #eee;
  color: var(--dark);
}

.detail-cancel-btn:hover { background: #ddd; transform: none; box-shadow: none; }

.detail-danger-row {
  padding-top: 0.25rem;
  border-top: 1px solid rgba(48, 54, 47, 0.12);
}

.detail-danger-text {
  font-size: 0.92rem;
  color: var(--dark);
  margin: 0 0 0.75rem;
}

.detail-delete-btn {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--tertiary);
  color: white;
  box-shadow: none;
  width: auto;
  letter-spacing: normal;
}

.detail-delete-btn:hover {
  transform: translateY(-1px);
  box-shadow: none;
}

/* ── Help page ───────────────────────────────────────────────────────────── */
.help-section {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.8rem 2rem;
  margin-bottom: 1.5rem;
}

.help-heading {
  color: var(--primary);
  font-size: 1.2rem;
  font-weight: 900;
  margin: 0 0 0.8rem;
}

.help-text {
  color: var(--dark);
  font-size: 0.97rem;
  line-height: 1.7;
  margin: 0 0 0.8rem;
}

.help-text:last-child { margin-bottom: 0; }

.help-list {
  color: var(--dark);
  font-size: 0.97rem;
  line-height: 1.8;
  padding-left: 1.4rem;
  margin: 0.4rem 0 0.8rem;
}

.help-list li { margin-bottom: 0.4rem; }

.help-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  font-size: 0.95rem;
}

.help-table th {
  background: var(--primary);
  color: white;
  font-weight: 800;
  padding: 0.6rem 0.9rem;
  text-align: left;
  border: none;
}

.help-table td {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid #eee;
  color: var(--dark);
  vertical-align: top;
}

.help-table tr:last-child td { border-bottom: none; }
.help-table tr:nth-child(even) td { background: #fafafa; }

/* Warning legend on help page */
.warning-legend {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0.5rem 0 1rem;
}

.warning-legend-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.legend-badge {
  flex-shrink: 0;
  position: static;
  pointer-events: none;
}

.legend-text {
  font-size: 0.95rem;
  color: var(--dark);
  line-height: 1.6;
}

.auth-switch {
  text-align: center;
  color: var(--light);
  margin-top: -1rem;
}

.auth-switch a {
  color: var(--secondary_light);
}

.inline-radio-group {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.inline-radio-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  cursor: pointer;
}

.helper-text {
  font-size: 0.85rem;
  color: #7D7ABC;
}

.helper-text.compact-top {
  margin-top: -0.8rem;
}

.helper-text.tight-bottom {
  margin-bottom: 0.8rem;
}

.optional-copy {
  font-weight: 400;
  font-size: 0.9rem;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  body > * {
    width: min(100%, calc(100% - 1.5rem));
  }

  #detailPanel,
  #myDetailPanel {
    max-width: 100%;
  }
}

@media (max-width: 760px) {
  h1 {
    margin-top: 1.5rem;
  }

  form,
  .help-section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  nav a,
  #navUploadBtn {
    flex: 1 1 calc(50% - 0.375rem);
    text-align: center;
  }

  nav a.nav-auth {
    margin-left: 0;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
  }

  #uploadPanel {
    max-width: none;
    max-height: 100vh;
    border-radius: 1.25rem 1.25rem 0 0;
    padding: 1.5rem 1rem;
    padding-bottom: 1.5rem;
  }

  #detailOverlay,
  #myDetailOverlay {
    align-items: flex-end;
    padding: 0;
  }

  #detailPanel,
  #myDetailPanel {
    max-height: 92vh;
    border-radius: 1.25rem 1.25rem 0 0;
  }

  #detailPanel img,
  #myDetailPanel img {
    max-height: 42vh;
  }
}

@media (max-width: 560px) {
  body {
    padding-bottom: 1.25rem;
  }

  body > * {
    width: min(100%, calc(100% - 1rem));
  }

  nav {
    padding: 0.65rem;
    gap: 0.5rem;
  }

  nav a,
  #navUploadBtn {
    flex: 1 1 100%;
    width: 100%;
    text-align: center;
    padding: 0.75rem 1rem;
  }

  nav a.nav-auth {
    margin-left: 0;
  }

  h2 {
    font-size: 1.45rem;
  }

  form {
    padding: 1rem;
    margin-bottom: 1.5rem;
  }

  input[type="text"],
  input[type="password"],
  input[type="file"],
  #tagTextInput,
  #editTagTextInput {
    font-size: 16px;
  }

  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .grid-card img,
  .my-card-img-wrap img {
    height: 160px;
  }

  .card-tag-strip {
    padding: 0.35rem 0.4rem;
  }

  .card-tag,
  .road-warning {
    font-size: 0.65rem;
  }

  #uploadOverlay,
  #detailOverlay,
  #myDetailOverlay {
    padding: 0;
  }

  #uploadPanel,
  #detailPanel,
  #myDetailPanel {
    width: 100%;
    max-height: 100vh;
    border-radius: 1rem 1rem 0 0;
  }

  #detailBody,
  #myDetailBody {
    padding: 1rem;
  }

  .detail-modal-actions,
  .detail-edit-actions,
  .warning-legend-row,
  .inline-radio-group {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-edit-btn,
  .detail-save-btn,
  .detail-cancel-btn,
  .detail-delete-btn {
    width: 100%;
    text-align: center;
    margin-left: 0;
  }

  .help-section {
    padding: 1rem;
  }

  .help-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .legend-text {
    font-size: 0.92rem;
  }
}
