/*
 * Field-Atlas detail page styles. Loaded via the layout's `:head` slot from
 * app/views/flurstuecke/show.html.erb so the rest of the site keeps its
 * Tailwind defaults.
 *
 * The custom properties below intentionally mirror map.css. Detail and map
 * are independent surfaces — the detail page never includes map.css — so
 * we declare the palette inline here. Update in lock-step if the palette
 * shifts in map.css.
 */

:root {
  --paper: #faf6ee;
  --paper-card: #fffef9;
  --ink: #2a1f14;
  --ink-soft: #4d3f30;
  --ink-mute: #8a7a64;
  --rule: #d9cfbb;
  --forest: #1f3a2e;
  --sage: #6b7c3e;
  --terracotta: #c66b3d;
  --crimson: #8b2e2e;
}

body.detail-body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Public Sans", system-ui, sans-serif;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.detail-page {
  background: var(--paper);
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── sticky header ───────────────────────────────────────── */
.detail-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  padding-top: env(safe-area-inset-top);
  height: calc(56px + env(safe-area-inset-top));
}

.detail-header__back,
.detail-header__menu {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--ink);
  padding: 0;
  height: 56px;
  cursor: pointer;
  text-decoration: none;
}

.detail-header__title {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── title block ─────────────────────────────────────────── */
.detail-title {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--rule);
}

.detail-kicker {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--terracotta);
  margin-bottom: 8px;
}

.detail-title__id {
  font-family: "Newsreader", Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 32px;
  line-height: 1;
  margin: 0 0 12px;
  color: var(--forest);
}

.detail-title__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 14px;
  color: var(--ink-soft);
}

.detail-title__meta .dot {
  color: var(--ink-mute);
}

.detail-title__shape,
.detail-title__edges {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.good-spacing {
  color: #5c8a3e;
  font-weight: 500;
}

/* ── status grid ─────────────────────────────────────────── */
.detail-status {
  padding: 20px;
  border-bottom: 1px solid var(--rule);
}

.detail-section-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  margin: 0 0 12px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.status-card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
  cursor: pointer;
  min-height: 48px;
  font-family: inherit;
}

.status-card:active {
  background: var(--paper);
}

.status-card.is-active {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.status-saved {
  margin-top: 10px;
  font-size: 12px;
  color: var(--sage);
  font-family: "JetBrains Mono", monospace;
}

@media (min-width: 769px) {
  .status-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── + Beobachtung action cards ──────────────────────────── */
.detail-actions {
  padding: 20px;
  border-bottom: 1px solid var(--rule);
}

.action-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.action-card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 18px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  font-family: inherit;
  /* Reset: <label class="action-card"> and <button class="action-card">
     should render identically. Buttons need text-align/font-size; labels
     need to suppress their default `display: inline`. */
  text-align: center;
  font-size: inherit;
  line-height: 1.2;
  width: 100%;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* Visually hidden but reachable via screen-readers and clickable via
   <label for=>. Used for the photo-uploader file input — keeping it
   hidden via `[hidden]` would defeat the label-for-input click flow on
   iOS Safari (the input must be in the layout tree). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.action-card:active {
  background: var(--paper);
  border-color: var(--ink);
}

.action-card__icon {
  font-size: 28px;
  line-height: 1;
}

.action-card__label {
  font-size: 13px;
  font-weight: 500;
}

/* Voice action card — pulses red while MediaRecorder is active.
   The stop indicator only appears in is-recording, replacing the mic icon. */
.action-card--voice { position: relative; }

.action-card--voice .voice-stop-indicator {
  display: none;
  font-size: 28px;
  line-height: 1;
}

.action-card.is-recording {
  background: var(--crimson, #c0392b);
  color: var(--paper);
  border-color: var(--crimson, #c0392b);
  animation: recording-pulse 1.2s infinite;
}

.action-card.is-recording .action-card__icon { display: none; }
.action-card.is-recording .voice-stop-indicator { display: block; }

@keyframes recording-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.78; }
}

/* ── shared section padding for the lower stack ──────────── */
.detail-photos,
.detail-voice,
.detail-note,
.detail-listing,
.detail-owner {
  padding: 20px;
  border-bottom: 1px solid var(--rule);
}

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

.photo-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
}

.photo-thumb--spinner {
  background: var(--paper);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--rule);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  font-size: 13px;
  color: var(--ink-mute);
  font-style: italic;
}

.voice-row {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.voice-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.voice-row audio {
  width: 100%;
  margin-bottom: 8px;
}

.voice-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 4px;
}

.voice-transcript {
  font-size: 14px;
  color: var(--ink-soft);
}

.text-error { color: var(--crimson); }

/* ── note textarea ───────────────────────────────────────── */
.note-textarea {
  width: 100%;
  min-height: 120px;
  padding: 12px;
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: "Public Sans", system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  resize: vertical;
  box-sizing: border-box;
}

.note-textarea:focus {
  outline: none;
  border-color: var(--ink);
}

.note-saved {
  margin-left: 8px;
  color: var(--sage);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

/* ── listing + owner cards ───────────────────────────────── */
.listing-card,
.owner-card {
  background: var(--paper-card);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 14px 16px;
}

.listing-card + .listing-card {
  margin-top: 10px;
}

.listing-card__head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.listing-card__type { color: var(--terracotta); }

.listing-card__status {
  padding: 2px 8px;
  border: 1px solid var(--rule);
}

.listing-card__status.status-aktiv { color: #5c8a3e; border-color: #5c8a3e; }
.listing-card__status.status-reserviert { color: #b8a064; border-color: #b8a064; }
.listing-card__status.status-weg { color: var(--ink-mute); border-color: var(--ink-mute); }

.listing-card__title {
  font-family: "Newsreader", Georgia, serif;
  font-size: 18px;
  margin: 0 0 8px;
  color: var(--forest);
}

.listing-card__numbers {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.listing-card__body {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin: 0 0 10px;
}

.listing-card__links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-link {
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 2px;
}

.btn-link:hover {
  background: var(--ink);
  color: var(--paper);
}

.owner-card__name {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 4px;
}

.owner-card__address {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.owner-card__erkenntnisse {
  font-size: 13px;
  background: var(--paper);
  padding: 8px 10px;
  border-left: 2px solid var(--terracotta);
  margin: 8px 0;
}

/* ── lightbox ───────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 3000;
  display: none;
  flex-direction: column;
}

.lightbox.is-open { display: flex; }

.lightbox__close {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 2px;
  font-size: 24px;
  z-index: 1;
  cursor: pointer;
}

.lightbox__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 16px;
}

.lightbox__image {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

.lightbox__caption-row {
  display: flex;
  width: 100%;
  max-width: 600px;
  margin-top: 20px;
  gap: 8px;
}

.lightbox__caption-input {
  flex: 1;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 14px;
  border-radius: 2px;
}

.lightbox__caption-input::placeholder { color: rgba(255, 255, 255, 0.5); }

.lightbox__delete {
  background: var(--crimson);
  color: #fff;
  border: none;
  padding: 10px 14px;
  font-size: 13px;
  border-radius: 2px;
  cursor: pointer;
}
