/* IDEASPACE — "מחברת לילה": warm charcoal + honey amber, Suez One / Assistant */

:root {
  --bg: #171310;
  --surface: #211c17;
  --surface2: #2b241d;
  --line: rgba(242, 236, 227, .08);
  --text: #f2ece3;
  --muted: #a99c8b;
  --accent: #f2a33c;        /* honey */
  --accent-soft: rgba(242, 163, 60, .14);
  --place: #e2725b;         /* terracotta — places/map */
  --danger: #d9634f;
  --star: #f2c94c;
  --radius: 20px;
  --nav-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body { min-height: 100dvh; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Assistant', sans-serif;
  font-size: 16px;
  line-height: 1.55;
  padding-top: env(safe-area-inset-top);
  overflow-x: hidden;
}

/* atmosphere */
.glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 38% at 85% -5%, rgba(242, 163, 60, .13), transparent 70%),
    radial-gradient(45% 30% at 0% 8%, rgba(226, 114, 91, .07), transparent 70%);
}
.glow::after {
  content: ''; position: absolute; inset: 0; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── header ── */
.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 6px;
}
.brand {
  font-family: 'Suez One', serif;
  font-size: 26px; letter-spacing: .04em; direction: ltr;
  color: var(--text);
}
.brand span { color: var(--accent); }
.topbar-actions { display: flex; align-items: center; gap: 2px; }
.iconbtn {
  background: none; border: 0; color: var(--muted); padding: 10px;
  border-radius: 50%; cursor: pointer; transition: color .2s;
}
.iconbtn:active { color: var(--accent); }

.searchwrap { padding: 6px 20px 2px; position: relative; z-index: 2; }
.searchwrap input {
  width: 100%; padding: 12px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font: inherit; outline: none;
}
.searchwrap input:focus { border-color: rgba(242, 163, 60, .45); }
.searchwrap input::placeholder { color: var(--muted); }

/* ── category chips ── */
.chips {
  position: relative; z-index: 2;
  display: flex; gap: 8px; overflow-x: auto; padding: 12px 20px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); border-radius: 999px; padding: 7px 16px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  transition: all .18s;
}
.chip.active {
  background: var(--accent); border-color: var(--accent); color: #241a0d;
}

/* ── feed ── */
.view { position: relative; z-index: 1; }
#feedView { padding: 4px 20px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.feed { display: flex; flex-direction: column; gap: 14px; }

.card {
  background: linear-gradient(160deg, var(--surface2), var(--surface) 55%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  animation: rise .45s cubic-bezier(.2, .8, .3, 1) both;
  animation-delay: calc(var(--i) * 55ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.card-title { font-family: 'Suez One', serif; font-size: 18px; font-weight: 400; }
.card-text { color: var(--text); opacity: .92; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }
.card-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.card-cat {
  font-size: 12.5px; font-weight: 700; padding: 3px 11px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
}
.card-cat.place-cat { background: rgba(226, 114, 91, .14); color: var(--place); }
.card-date { font-size: 12.5px; color: var(--muted); margin-inline-start: auto; }
.card-place {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; font-weight: 600; color: var(--place);
}
.card-stars { color: var(--star); font-size: 14px; letter-spacing: 2px; }
.card-editbtn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 18px; padding: 2px 6px; line-height: 1;
}

/* link preview area (Phase 2 fills it) */
.card-link {
  display: block; margin-top: 12px; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface);
  color: inherit; text-decoration: none;
}
.card-link img.thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.card-link .linkbar {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
}
.card-link .linkbar img.fav { width: 20px; height: 20px; border-radius: 5px; }
.card-link .linktitle {
  font-size: 14px; font-weight: 600;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.card-link .linkhost { font-size: 12px; color: var(--muted); direction: ltr; }

/* ── script cards ── */
.script-block { margin-top: 8px; }
.script-badge {
  display: inline-block; font-size: 11.5px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 2px 10px; margin-bottom: 8px;
}
.script-hook {
  font-weight: 700; font-size: 16px;
  border-inline-start: 3px solid var(--accent);
  padding-inline-start: 10px; margin-bottom: 8px;
}
.script-block .card-text.clamped {
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden;
}
.script-expand {
  background: none; border: 0; color: var(--accent); font: inherit;
  font-weight: 700; font-size: 13.5px; cursor: pointer; padding: 6px 0;
}
.script-cta {
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: 12px; padding: 7px 12px; margin-top: 8px; width: fit-content;
}

/* ── empty state ── */
.empty { text-align: center; padding: 12vh 30px 0; }
.empty-art {
  font-size: 44px; color: var(--accent); margin-bottom: 14px;
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; transform: scale(.92); } }
.empty-title { font-family: 'Suez One', serif; font-size: 22px; }
.empty-sub { color: var(--muted); margin-top: 8px; max-width: 300px; margin-inline: auto; }

/* ── map ── */
#mapView { position: fixed; inset: 0; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
#map { height: 100%; background: var(--surface); }

.map-controls {
  position: absolute; top: calc(env(safe-area-inset-top) + 14px); inset-inline: 14px;
  z-index: 900; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  pointer-events: none;
}
.map-controls > * { pointer-events: auto; }
.segctrl {
  display: flex; gap: 2px; background: rgba(23, 19, 16, .88);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.segbtn {
  border: 0; background: none; color: var(--muted); font: inherit; font-weight: 700; font-size: 12.5px;
  padding: 8px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap; transition: all .18s;
}
.segbtn.active { background: var(--accent); color: #241a0d; }
.locatebtn {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(23, 19, 16, .88);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  color: var(--accent); display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.locatebtn:active { transform: scale(.94); }

/* ── map pins ── */
.pin { background: none !important; border: none !important; }
.pin-badge {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .45);
  border: 2px solid rgba(23, 19, 16, .35);
}
.pin-label { transform: rotate(45deg); font-weight: 800; font-size: 12.5px; color: #241a0d; }
.pin-want .pin-badge { background: var(--place); }
.pin-visited .pin-badge { background: var(--accent); }

/* Leaflet popup theme override (keep attribution visible, only restyle chrome) */
.leaflet-popup-content-wrapper {
  background: var(--surface2); color: var(--text);
  border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-tip { background: var(--surface2); border: 1px solid var(--line); }
.leaflet-popup-close-button { color: var(--muted) !important; }
.leaflet-container a.leaflet-popup-close-button:hover { color: var(--accent) !important; }
.leaflet-container { font-family: 'Assistant', sans-serif; }
.leaflet-control-attribution { background: rgba(23, 19, 16, .75) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }

.popup-body { direction: rtl; min-width: 160px; }
.popup-title { font-family: 'Suez One', serif; font-size: 15px; font-weight: 400; margin-bottom: 4px; }
.popup-cat {
  display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 2px 9px; border-radius: 999px; margin-bottom: 8px;
}
.hidden-el { display: none !important; }
.popup-actions { display: flex; gap: 8px; margin-top: 6px; }
.popup-btn {
  border: 0; border-radius: 10px; padding: 8px 12px; font: inherit; font-weight: 700; font-size: 13px;
  cursor: pointer; background: var(--accent); color: #241a0d;
}
.popup-btn.ghost { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }

/* tap-to-rate star row — card + popup share this (min 44px touch target) */
.popup-stars, .card-rate {
  display: flex; gap: 2px; margin-top: 6px;
}
.star-btn {
  background: none; border: 0; color: rgba(242, 236, 227, .25); font-size: 20px;
  min-width: 44px; min-height: 44px; line-height: 1; cursor: pointer; padding: 0;
}
.star-btn.active { color: var(--star); }
.visit-chip {
  margin-top: 8px; display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 6px 16px; border-radius: 999px; font: inherit; font-weight: 700; font-size: 13px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(242, 163, 60, .3); cursor: pointer;
}

/* ── place search (add/edit sheet) ── */
.place-results { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.place-result {
  text-align: right; background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 10px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.place-result:active { border-color: rgba(242, 163, 60, .45); }
.place-status { color: var(--muted); font-size: 13.5px; padding: 4px 2px; display: block; }
.place-chosen {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 10px 14px;
}
.place-remove { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 8px; }

/* ── bottom nav ── */
.bottomnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: rgba(23, 19, 16, .88);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.navbtn {
  background: none; border: 0; color: var(--muted); font: inherit;
  font-size: 12px; font-weight: 600; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0;
}
.navbtn.active { color: var(--accent); }
.fab {
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #241a0d;
  font-size: 32px; font-weight: 400; line-height: 1;
  margin-top: -26px;
  box-shadow: 0 8px 24px rgba(242, 163, 60, .35);
  transition: transform .15s;
}
.fab:active { transform: scale(.92); }

/* ── bottom sheet ── */
.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(10, 8, 6, .55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 31;
  background: var(--surface2);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--line);
  padding: 10px 22px calc(18px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
  animation: slideup .32s cubic-bezier(.2, .8, .3, 1);
}
@keyframes slideup { from { transform: translateY(60px); opacity: .4; } }
.sheet-grip {
  width: 42px; height: 4px; border-radius: 2px; background: var(--line);
  margin: 4px auto 14px;
}
.sheet-head { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; }
.sheet-title { font-family: 'Suez One', serif; font-size: 20px; font-weight: 400; }
.backbtn { padding: 6px; margin-inline-start: -8px; color: var(--accent); }

/* step transitions */
.step { animation: stepin .28s cubic-bezier(.2, .8, .3, 1) both; }
@keyframes stepin { from { opacity: 0; transform: translateX(-12px); } }
#stepForm { display: flex; flex-direction: column; }
#stepForm .sheet-actions { order: 99; }

/* type picker */
.typegrid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-bottom: 8px;
}
.typetile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  background: linear-gradient(160deg, var(--surface), var(--bg));
  border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; cursor: pointer; text-align: start;
  font: inherit; color: var(--text);
  transition: border-color .18s, transform .12s;
}
.typetile:active { transform: scale(.96); border-color: rgba(242, 163, 60, .5); }
.typetile .typeicon { font-size: 26px; margin-bottom: 6px; }
.typetile .typename { font-family: 'Suez One', serif; font-size: 16.5px; }
.typetile small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }

/* live preview inside the sheet */
.sheet-preview { margin-top: 10px; }
.sheet-preview:empty { display: none; }
.sheet-preview .card-link { pointer-events: none; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field-label em { font-style: normal; font-weight: 400; opacity: .7; }
.field input[type="text"], .field input[type="url"], .field input[type="search"], .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--text); font: inherit; outline: none; resize: none;
}
.field input:focus, .field textarea:focus { border-color: rgba(242, 163, 60, .45); }
.field ::placeholder { color: rgba(169, 156, 139, .6); }

.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; min-width: 0; }
.pastebtn {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface);
  color: var(--accent); font: inherit; font-weight: 700; font-size: 14px;
  border-radius: 13px; padding: 0 16px; cursor: pointer;
}

.catpick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.catpick:empty { display: none; }

.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.btn {
  border: 0; border-radius: 14px; padding: 13px 20px; font: inherit;
  font-weight: 700; font-size: 15.5px; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #241a0d; flex: 1; }
.btn.ghost { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--danger); }

/* ── settings sheet ── */
.settings-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.settings-btn { width: 100%; }
.settings-meta { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 16px; }

/* ── iOS install banner ── */
.installbanner {
  position: fixed; z-index: 25; inset-inline: 14px;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  animation: rise .3s ease both;
}
.installbanner-icon { font-size: 18px; flex: 0 0 auto; }
.installbanner-text { flex: 1; font-size: 13.5px; font-weight: 600; color: var(--text); }
.installbanner-close {
  background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer;
  padding: 4px 6px; flex: 0 0 auto; min-width: 28px; min-height: 28px;
}

/* ── toast ── */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  inset-inline: 0; margin-inline: auto; width: fit-content; max-width: 86vw;
  z-index: 40; background: var(--surface2); border: 1px solid var(--line);
  color: var(--text); padding: 11px 20px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600;
  animation: rise .3s ease both;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
