/* Living Wall Map — mobile-first schematic */

:root {
  --bg: #1a1c1e;
  --bg-elevated: #25282c;
  --bucket-w: clamp(2.4rem, 7.5vw, 3.75rem);
  --bucket-h: calc(var(--bucket-w) * 0.55);
  --bucket-gap: 2px;
  --charcoal: #2a2d30;
  --charcoal-light: #3a3e44;
  --silver: #8a9099;
  --green-planted: #3d5c45;
  --green-glow: #5a8f6a;
  --text: #e8eaed;
  --text-muted: #9aa0a8;
  --tooltip-bg: #f4f5f7;
  --tooltip-text: #1a1c1e;
  --highlight: #6ab07a;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100vh;
}

body.tooltip-open,
body.admin-mode {
  overflow-x: hidden;
}

body.admin-mode .bucket {
  cursor: pointer;
}

body.admin-mode .bucket::after {
  content: '';
  position: absolute;
  inset: 1px;
  border: 1px dashed rgba(106, 176, 122, 0.25);
  border-radius: inherit;
  pointer-events: none;
}

/* Header */
.site-header {
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid #333;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
}

.header-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 10rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--charcoal-light);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend__swatch {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
}

.legend__swatch--empty {
  background: var(--charcoal);
  border: 1px solid var(--charcoal-light);
}

.legend__swatch--planted {
  background: var(--green-planted);
}

/* Main map area */
main {
  padding: 0.75rem;
  max-width: 56rem;
  margin: 0 auto;
}

.wall-map {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Isometric corner scene ── */
.corner-scene {
  margin: 2rem auto 0;
  padding-top: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 3D wall faces bleed upward past their layout box */
  overflow: visible;
}

.corner-scene__stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 0;
  width: 100%;
  max-width: 100%;
  min-height: min(52vh, 440px);
  padding: 3rem 0.75rem 0.75rem;
  perspective: 900px;
  perspective-origin: 50% 82%;
  transform-style: preserve-3d;
}

.corner-scene__floor {
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 38%;
  background: linear-gradient(180deg, #2e3338 0%, #1e2226 100%);
  border: 1px solid #3a4048;
  transform: rotateX(72deg);
  transform-origin: bottom center;
  z-index: 0;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.corner-scene__edge {
  position: absolute;
  bottom: 8%;
  left: 50%;
  width: 3px;
  height: 78%;
  margin-left: -1px;
  background: linear-gradient(180deg, transparent, var(--silver) 12%, var(--silver) 88%, transparent);
  opacity: 0.35;
  z-index: 2;
  pointer-events: none;
}

/* Wall faces */
.wall-face {
  position: relative;
  z-index: 5;
  pointer-events: auto;
  isolation: isolate;
  padding-top: 0.45rem;
  padding-bottom: 0.5rem;
  background: linear-gradient(145deg, #32373d 0%, #25282c 55%, #1a1d20 100%);
  border: 1px solid #454b54;
  border-radius: 4px 4px 2px 2px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    4px 8px 20px rgba(0, 0, 0, 0.5);
  transform-style: preserve-3d;
  flex-shrink: 0;
  overflow: visible;
  min-width: calc(1.15rem + 3 * var(--bucket-w) + 2 * var(--bucket-gap) + var(--bucket-w) * 0.55);
}

.wall-face--left {
  z-index: 8;
  transform: rotateY(36deg) translateZ(14px);
  transform-origin: right bottom;
  margin-right: -10px;
  padding-left: calc(0.65rem + var(--bucket-w) * 0.55);
  padding-right: calc(0.2rem + var(--bucket-w) * 0.15);
}

.wall-face--right {
  z-index: 2;
  transform: rotateY(-36deg) translateZ(-10px);
  transform-origin: left bottom;
  margin-left: 12px;
  padding-right: calc(0.35rem + var(--bucket-w) * 0.2);
  padding-left: calc(0.25rem + var(--bucket-w) * 0.15);
}

.wall-face__label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--silver);
  text-align: center;
  margin-bottom: 0.25rem;
}

.wall-face__cols {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 0.55rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.wall-face--left .wall-face__col-nums {
  margin-left: calc(var(--bucket-w) / 2);
}

.wall-face--right .wall-face__cols {
  padding-left: calc(var(--bucket-w) / 2);
}

.wall-face__col-track {
  flex: 0 0 auto;
  width: calc(3 * var(--bucket-w) + 2 * var(--bucket-gap));
}

.wall-face__col-num {
  width: var(--bucket-w);
  flex-shrink: 0;
  text-align: center;
}

.wall-face__cols-spacer {
  flex-shrink: 0;
}

.wall-face__rows {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.wall-row {
  display: flex;
  align-items: center;
}

.wall-row__label {
  width: 1.1rem;
  font-size: 0.55rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
}

/* Right face: buckets then label — mirror left */
.wall-face--right .wall-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  box-sizing: content-box;
  width: calc(
    var(--bucket-w) * 0.5 + 3 * var(--bucket-w) + 2 * var(--bucket-gap) + 1.1rem
  );
}

.wall-face--right .wall-row__label {
  flex: 0 0 1.1rem;
  width: 1.1rem;
  margin-left: 0;
  transform: translateZ(4px);
}

.wall-row__buckets {
  display: flex;
  gap: var(--bucket-gap);
}

.wall-row--stagger .wall-row__buckets {
  transform: translateX(calc(var(--bucket-w) / 2));
}

.wall-face--left .wall-row--stagger .wall-row__buckets {
  margin-left: calc(var(--bucket-w) / 2);
  transform: none;
}

.wall-face--right .wall-row__track {
  flex: 0 0 auto;
  width: calc(3 * var(--bucket-w) + 2 * var(--bucket-gap));
}

.wall-face--right .wall-row--stagger .wall-row__track {
  margin-left: calc(var(--bucket-w) / 2);
}

.wall-face--right .wall-row--stagger .wall-row__buckets {
  transform: none;
}

.wall-face--right .wall-row__buckets {
  flex: 0 0 auto;
  width: calc(3 * var(--bucket-w) + 2 * var(--bucket-gap));
}

/* ── Wings below wall ── */
.wings-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid #333;
}

.wing--below .wing__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.2rem;
  text-transform: none;
  letter-spacing: 0;
}

.wing__hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.wing--below .wing__strip {
  justify-content: flex-start;
}

.wing--below.wing--right .wing__strip {
  justify-content: flex-start;
}

/* Bucket pocket shape */
.bucket {
  width: var(--bucket-w);
  height: var(--bucket-h);
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
  pointer-events: auto;
  touch-action: manipulation;
  background: var(--charcoal);
  color: var(--text);
  padding: 0.15rem 0.2rem;
  font-size: clamp(0.55rem, 2vw, 0.7rem);
  font-weight: 600;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  /* Worth Garden scalloped pocket — rounded bowl at bottom */
  border-radius: 12% 12% 45% 45% / 15% 15% 55% 55%;
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.35),
    0 -1px 0 rgba(255, 255, 255, 0.06),
    2px 2px 5px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s, filter 0.12s, box-shadow 0.12s;
  -webkit-tap-highlight-color: transparent;
}

.bucket--face-left,
.bucket--face-right {
  transform: translateZ(2px);
  box-shadow:
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    1px 1px 4px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(0, 0, 0, 0.2);
}

.bucket--wing {
  --bucket-w: clamp(2rem, 5.5vw, 3rem);
  width: var(--bucket-w);
  height: calc(var(--bucket-w) * 0.55);
}

.bucket:hover,
.bucket:focus-visible {
  z-index: 10;
  outline: 2px solid var(--highlight);
  outline-offset: 1px;
  filter: brightness(1.12);
}

.wall-face--left .bucket:hover,
.wall-face--left .bucket:focus-visible {
  transform: translateZ(22px) scale(1.08);
}

.wall-face--left .bucket.module-edge:hover,
.wall-face--left .bucket.module-edge:focus-visible {
  transform: translateZ(26px) scale(1.08);
}

.wall-face--right .bucket:hover,
.wall-face--right .bucket:focus-visible {
  transform: translateZ(6px) scale(1.08);
}

.bucket--wing:hover,
.bucket--wing:focus-visible {
  transform: scale(1.06);
}

.bucket--empty {
  background: var(--charcoal);
}

.bucket--planted {
  background: linear-gradient(180deg, var(--green-planted) 0%, #2d4534 100%);
}

.bucket--status-dormant {
  background: linear-gradient(180deg, #4a4e55 0%, #35383d 100%);
}

.bucket__abbrev {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.bucket--dimmed {
  opacity: 0.25;
}

.bucket--highlight {
  box-shadow: 0 0 0 2px var(--highlight);
}

/* Module edge + corner seam */
.bucket.module-edge {
  margin-right: 2px;
}

.wall-face--left .bucket.module-edge {
  z-index: 12;
  transform: translateZ(18px);
}

/* Wings (horizontal strips) */
.wing__strip {
  display: flex;
  gap: var(--bucket-gap);
  overflow-x: auto;
  padding-bottom: 0.35rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

/* Tooltip */
.tooltip-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
}

.tooltip {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 24rem;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  border-radius: 16px 16px 0 0;
  padding: 1.25rem 1rem 1.5rem;
  z-index: 101;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
}

@media (min-width: 480px) {
  .tooltip {
    bottom: auto;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    max-height: 90vh;
  }
}

.tooltip__close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  border: none;
  background: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #555;
  padding: 0.25rem;
}

.tooltip__title {
  margin: 0 0 0.25rem;
  font-size: 0.85rem;
  color: #666;
  font-weight: 500;
}

.tooltip__common {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.tooltip__species {
  margin: 0 0 0.75rem;
  color: #555;
  font-size: 0.9rem;
}

.tooltip__photo-wrap {
  margin: 0.75rem 0;
  border-radius: 8px;
  overflow: hidden;
  background: #ddd;
}

.tooltip__photo {
  display: block;
  width: 100%;
  max-height: 200px;
  object-fit: cover;
}

.tooltip__meta,
.tooltip__notes {
  margin: 0.35rem 0;
  font-size: 0.9rem;
}

.tooltip__link {
  display: inline-block;
  margin-top: 0.75rem;
  color: #1a5fb4;
  font-weight: 500;
}

/* Admin */
.admin-banner {
  background: #3d2e1a;
  color: #f0e6d8;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #5a4a32;
}

.admin-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.admin-banner button,
.admin-banner a {
  font-size: 0.75rem;
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  border: 1px solid #6a5a42;
  background: #4a3820;
  color: inherit;
  cursor: pointer;
  text-decoration: none;
}

.admin-banner__secondary {
  background: transparent;
  border-color: #6a5a42;
}

.admin-banner__text {
  flex: 1;
  min-width: 12rem;
}

.admin-banner button:hover,
.admin-banner a:hover {
  background: #5c4828;
}

.admin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.admin-login {
  background: var(--bg-elevated);
  padding: 1.5rem;
  border-radius: 8px;
  width: min(90vw, 20rem);
}

.admin-login h2 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.admin-login input {
  width: 100%;
  padding: 0.5rem;
  margin: 0.5rem 0;
  border: 1px solid var(--charcoal-light);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.admin-login button {
  width: 100%;
  padding: 0.55rem;
  margin-top: 0.5rem;
  background: var(--green-planted);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.admin-login__error {
  color: #e57373;
  font-size: 0.85rem;
}

.edit-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.edit-panel--open {
  display: flex;
}

.edit-panel__inner {
  background: var(--bg-elevated);
  width: 100%;
  max-width: 28rem;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1rem;
  border-radius: 12px 12px 0 0;
}

@media (min-width: 480px) {
  .edit-panel {
    align-items: center;
  }

  .edit-panel__inner {
    border-radius: 12px;
    margin: 1rem;
  }
}

.edit-panel__close {
  float: right;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.edit-form label {
  display: block;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
}

.edit-form input,
.edit-form select,
.edit-form textarea {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem;
  border: 1px solid var(--charcoal-light);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.edit-panel__preview {
  margin: 0.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.edit-panel__preview img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 6px;
}

.edit-form__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.edit-form__actions button {
  flex: 1;
  padding: 0.55rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.edit-form__actions button[type='submit'] {
  background: var(--green-planted);
  color: white;
}

#btn-clear-bucket {
  background: var(--charcoal-light);
  color: var(--text);
}

.flash-message {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--green-planted);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  z-index: 300;
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
}

.flash-message--visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

@media (min-width: 640px) {
  .wall-face--left {
    transform: rotateY(40deg) translateZ(14px);
    margin-right: -8px;
  }

  .wall-face--right {
    transform: rotateY(-40deg) translateZ(-10px);
  }

  .corner-scene__stage {
    min-height: min(56vh, 500px);
  }

  .site-header h1 {
    font-size: 1.35rem;
  }
}

@media (max-width: 380px) {
  :root {
    --bucket-w: clamp(2rem, 6.5vw, 2.4rem);
  }

  .wall-face--left {
    transform: rotateY(30deg) translateZ(12px);
    margin-right: -6px;
    padding-left: calc(0.5rem + var(--bucket-w) * 0.5);
    padding-right: calc(0.2rem + var(--bucket-w) * 0.12);
  }

  .wall-face--right {
    transform: rotateY(-30deg) translateZ(-8px);
    margin-left: 8px;
    padding-right: calc(0.25rem + var(--bucket-w) * 0.15);
    padding-left: calc(0.2rem + var(--bucket-w) * 0.12);
  }
}
