/* =========================================================
   Conejo Valley Then & Now — shared stylesheet
   Warm / archival visual identity. Mobile-first.
   No frameworks, no build step.
   ========================================================= */

:root {
  --color-bg: #faf4e7;
  --color-bg-alt: #f1e6d0;
  --color-paper: #fffdf8;
  --color-text: #3b2f22;
  --color-text-muted: #6b5c47;
  --color-border: #d9c6a3;
  --color-accent: #a3492b;
  --color-accent-dark: #7d3620;
  --color-accent-contrast: #fff8ee;
  --color-accent-2: #5f6f45;
  --color-badge-bg: #e9c46a;
  --color-badge-text: #3b2f22;
  --color-link: #7d3620;
  --shadow-card: 0 2px 8px rgba(59, 47, 34, 0.15);
  --shadow-elevated: 0 8px 28px rgba(59, 47, 34, 0.35);
  --radius: 12px;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --tap-min: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #221a12;
    --color-bg-alt: #2c2216;
    --color-paper: #2a2117;
    --color-text: #f0e3cc;
    --color-text-muted: #cbb894;
    --color-border: #4a3a26;
    --color-accent: #e08a5b;
    --color-accent-dark: #f0a878;
    --color-accent-contrast: #221a12;
    --color-accent-2: #9db27d;
    --color-badge-bg: #caa23a;
    --color-badge-text: #221a12;
    --color-link: #e08a5b;
    --shadow-card: 0 2px 10px rgba(0, 0, 0, 0.45);
    --shadow-elevated: 0 10px 32px rgba(0, 0, 0, 0.6);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  background: var(--color-bg);
  color: var(--color-text);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--color-link);
}

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.2;
  color: var(--color-text);
}

p {
  margin: 0.6em 0;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 16px;
}

/* ---------- Header / nav ---------- */

.site-header {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow-card);
  position: sticky;
  top: 0;
  z-index: 500;
}

.site-header__inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--color-accent-contrast);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-title .icon {
  font-size: 1.6rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-nav a {
  color: var(--color-accent-contrast);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  font-weight: 600;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  background: rgba(255, 255, 255, 0.28);
}

.site-nav a[aria-current="page"] {
  background: var(--color-accent-contrast);
  color: var(--color-accent-dark);
}

/* ---------- Footer ---------- */

.site-footer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 2rem 1rem 3rem;
  margin-top: 3rem;
  font-size: 0.9rem;
}

.site-footer__inner {
  max-width: 1100px;
  margin: 0 auto;
}

.site-footer a {
  color: var(--color-text-muted);
}

/* ---------- Generic layout ---------- */

.page-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2rem;
}

.page-main--narrow {
  max-width: 760px;
}

.lede {
  font-size: 1.1rem;
  color: var(--color-text-muted);
  max-width: 65ch;
}

.card {
  background: var(--color-paper);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap-min);
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  text-decoration: none;
  font-weight: 700;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn:hover, .btn:focus-visible {
  background: var(--color-accent-dark);
}

.btn--secondary {
  background: transparent;
  color: var(--color-accent);
  border: 2px solid var(--color-accent);
}

.btn--secondary:hover, .btn--secondary:focus-visible {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* ---------- Chips (decade / type filters) ---------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.chip {
  min-height: var(--tap-min);
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--color-border);
  background: var(--color-paper);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-accent-contrast);
}

/* ---------- Map page ---------- */

.map-page-main {
  padding: 0;
  max-width: none;
}

#map {
  width: 100%;
  height: calc(100vh - 118px);
  min-height: 420px;
  background: var(--color-bg-alt);
}

.map-intro {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.9rem 1rem 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.marker-popup {
  font-family: var(--font-sans);
  max-width: 220px;
}

.marker-popup img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 0.4rem;
}

.marker-popup h3 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
}

.marker-popup .marker-popup__meta {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.marker-popup button {
  width: 100%;
  min-height: 40px;
}

.leaflet-popup-content {
  margin: 10px 12px;
}

/* ---------- Gallery / documents grid ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
  margin-top: 1rem;
}

.entry-card {
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  border: 1px solid var(--color-border);
}

.entry-card__image-wrap {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.entry-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.entry-card__body {
  padding: 0.9rem 1rem 1.1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.entry-card__body h3 {
  font-size: 1.05rem;
  margin: 0;
}

.entry-card__meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.badge {
  display: inline-block;
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  align-self: flex-start;
}

.type-icon {
  font-size: 1.4rem;
}

.empty-state {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 2rem 0;
}

/* ---------- Detail overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 8, 0.75);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
}

.overlay[hidden] {
  display: none;
}

.overlay__panel {
  background: var(--color-paper);
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-elevated);
  padding: 1.1rem 1.1rem 2rem;
  position: relative;
}

@media (min-width: 700px) {
  .overlay {
    align-items: center;
  }
  .overlay__panel {
    border-radius: var(--radius);
    max-height: 88vh;
  }
}

.overlay__close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 50%;
  border: none;
  background: var(--color-bg-alt);
  color: var(--color-text);
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 2;
}

.overlay__title {
  margin: 0.2rem 2.6rem 0.1rem 0;
  font-size: 1.4rem;
}

.overlay__meta {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.8rem;
}

.overlay__single-image {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 0.9rem;
}

.overlay__single-image img {
  width: 100%;
}

.overlay__rephoto-badge {
  position: absolute;
  bottom: 0.6rem;
  left: 0.6rem;
  right: 0.6rem;
  background: var(--color-badge-bg);
  color: var(--color-badge-text);
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}

.overlay__description {
  margin: 0.8rem 0;
}

.overlay__credit {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 0.7rem;
  margin-top: 0.9rem;
}

.overlay__credit p {
  margin: 0.2rem 0;
}

/* ---------- Then/Now slider component ---------- */

.tn-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
  touch-action: pan-y;
  user-select: none;
  background: var(--color-bg-alt);
}

.tn-slider img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.tn-slider__now-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  width: 50%;
}

.tn-slider__now-wrap img {
  /* Actual pixel width is set by thenNowSlider.js so this image lines up
     with the "then" image underneath regardless of the wrapper's clip width. */
  max-width: none;
}

.tn-slider__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 4px;
  background: var(--color-accent-contrast, #fff);
  transform: translateX(-2px);
  cursor: ew-resize;
}

.tn-slider__handle::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -14px;
  width: 28px;
}

.tn-slider__grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--color-accent-dark);
  border: 3px solid var(--color-accent);
}

.tn-slider__label {
  position: absolute;
  bottom: 0.6rem;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.tn-slider__label--then {
  left: 0.6rem;
}

.tn-slider__label--now {
  right: 0.6rem;
}

/* ---------- Contribute / About pages ---------- */

.info-section {
  margin-bottom: 2rem;
}

.info-section h2 {
  font-size: 1.3rem;
  border-bottom: 3px solid var(--color-accent);
  display: inline-block;
  padding-bottom: 0.2rem;
}

.checklist {
  list-style: none;
  padding: 0;
}

.checklist li {
  padding: 0.5rem 0 0.5rem 2.1rem;
  position: relative;
}

.checklist li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  top: 0.45rem;
  color: var(--color-accent-2);
  font-weight: bold;
  font-size: 1.2rem;
}

.contact-box {
  background: var(--color-bg-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.note-box {
  background: var(--color-bg-alt);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.9rem 1.1rem;
  margin: 1rem 0;
}

/* ---------- Submission form ---------- */

.form-field {
  margin-bottom: 1.3rem;
}

.form-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.form-field .required {
  color: var(--color-accent);
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field input[type="email"],
.form-field input[type="file"],
.form-field textarea {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-paper);
  color: var(--color-text);
}

.form-field textarea {
  min-height: 100px;
  resize: vertical;
  font-family: inherit;
}

.form-field .field-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0.3rem 0 0;
}

.form-field--checkbox label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-weight: 400;
  cursor: pointer;
}

.form-field--checkbox input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
  margin-top: 0.15rem;
}

#submit-map {
  width: 100%;
  height: 280px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}

#form-status {
  font-weight: 600;
}

.form-status--success {
  border-left-color: var(--color-accent-2);
}

.form-status--error {
  border-left-color: var(--color-accent);
}

/* ---------- Lightbox (documents page) ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 7, 4, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 8px;
  margin: 0 auto;
}

.lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 50%;
  border: none;
  background: var(--color-paper);
  color: var(--color-text);
  font-size: 1.4rem;
  cursor: pointer;
}

/* ---------- Custom map markers ---------- */

.map-marker__pin {
  width: 38px;
  height: 38px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
  border: 2px solid #fff;
}

.map-marker__pin span,
.map-marker__pin {
  font-size: 1.05rem;
}

.map-marker__pin--photo {
  background: var(--color-accent);
}

.map-marker__pin--doc {
  background: var(--color-accent-2);
}

.map-marker__pin {
  color: #fff;
  transform: rotate(-45deg);
}

.map-marker__glyph {
  transform: rotate(45deg);
  display: block;
  line-height: 1;
}

/* ---------- Leaflet attribution readability ---------- */

.leaflet-control-attribution {
  font-size: 11px;
}

/* ---------- Utility ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (min-width: 640px) {
  .site-header__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
