/* =========================================================
   Earth Kitchen – style.css
   ========================================================= */

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

:root {
  --gold:    #D4AF37;
  --gold2:   #F7D070;
  --green:   #1a6b4a;
  --bg:      #0d0d0d;
  --surface: #141414;
  --card:    #181818;
  --border:  #2a2a2a;
  --text:    #e8e8e8;
  --muted:   #888;
  --panel-w: 370px;
  --font:    'Cairo', system-ui, sans-serif;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

/* ══ Globe ══════════════════════════════════════════════ */
#globe-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  cursor: grab;
  /* dir="ltr" is set in HTML — critical for CSS3D renderer in RTL pages */
}
#globe-container:active { cursor: grabbing; }

/* ══ Food markers ════════════════════════════════════════ */
.food-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  direction: ltr;        /* prevent RTL from breaking CSS3D layout */
  user-select: none;
  pointer-events: auto;
  /* NEVER set transform here — globe.gl owns transform on this element.
     Overriding it snaps the marker to (0,0,0) causing the "runs away" bug. */
  transition: opacity 0.35s;
}

.marker-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  overflow: hidden;
  background: #111;
  box-shadow: 0 0 14px rgba(212,175,55,0.5), 0 0 0 2px rgba(0,0,0,0.5);
  /* Scale the ring, NOT the wrapper — wrapper transform is owned by globe.gl */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.food-marker:hover .marker-ring {
  transform: scale(1.28);
  box-shadow: 0 0 28px rgba(212,175,55,0.95), 0 0 0 3px rgba(212,175,55,0.3);
}
.marker-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.marker-label {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'Cairo', sans-serif;   /* explicit — not var() — for globe.gl's shadow DOM */
  text-shadow: 0 1px 6px #000, 0 0 12px #000, 0 0 20px #000;
  white-space: nowrap;
  text-align: center;
  line-height: 1.3;
  max-width: 100px;
  background: rgba(0,0,0,0.55);       /* dark pill behind text so it's readable */
  padding: 1px 5px;
  border-radius: 4px;
}

/* ══ Ingredient origin dots (globe.gl pointsData labels) ═ */
.ing-point-label {
  background: rgba(0,0,0,0.82);
  border: 1px solid rgba(212,175,55,0.4);
  color: var(--gold);
  padding: 4px 9px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
  text-align: center;
}
.ing-point-label small {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 400;
}

/* ══ Header ══════════════════════════════════════════════ */
#header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.9) 0%, transparent 100%);
  pointer-events: none;
}
#header > * { pointer-events: auto; }

#logo { display: flex; align-items: center; gap: 10px; }
#logo svg { width: 34px; height: 34px; flex-shrink: 0; }
#logo-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}
#logo-text p { font-size: 0.66rem; color: var(--muted); }

#header-controls { display: flex; gap: 8px; }

.header-btn {
  background: rgba(18,18,18,0.9);
  border: 1px solid var(--border);
  color: var(--gold);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  backdrop-filter: blur(10px);
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-btn:hover { background: rgba(212,175,55,0.15); border-color: var(--gold); }

.icon-btn {
  background: rgba(18,18,18,0.8);
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.icon-btn:hover { background: rgba(220,60,60,0.25); color: #fff; }

/* ══ Sidebar ══════════════════════════════════════════════ */
#sidebar {
  position: fixed;
  top: 0;
  left: -285px;
  width: 270px;
  height: 100%;
  z-index: 50;
  background: rgba(12,12,12,0.97);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  transition: left 0.35s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
#sidebar.open { left: 0; }

[dir="rtl"] #sidebar {
  left: auto;
  right: -285px;
  border-right: none;
  border-left: 1px solid var(--border);
  transition: right 0.35s cubic-bezier(.4,0,.2,1);
}
[dir="rtl"] #sidebar.open { right: 0; }

#sidebar-header {
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
#sidebar-header h2 {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gold);
}

#sidebar-search { padding: 8px 12px; border-bottom: 1px solid var(--border); }
#search-input {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 11px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}
#search-input::placeholder { color: var(--muted); }
#search-input:focus { border-color: var(--gold); }

#food-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
#food-list::-webkit-scrollbar { width: 3px; }
#food-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.food-list-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 9px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  cursor: pointer;
  width: 100%;
  text-align: start;
  transition: background 0.15s, border-color 0.15s;
}
.food-list-item:hover { background: var(--card); border-color: var(--border); }
.food-list-item img {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.food-list-item span { flex: 1; line-height: 1.3; }

/* ══ Info Panel (right side) ═════════════════════════════ */
#info-panel {
  position: fixed;
  top: 0;
  right: calc(-1 * var(--panel-w) - 10px);
  width: var(--panel-w);
  height: 100%;
  z-index: 45;
  background: rgba(10,10,10,0.96);
  border-left: 1px solid var(--border);
  backdrop-filter: blur(24px);
  display: flex;
  flex-direction: column;
  transition: right 0.4s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
#info-panel.open { right: 0; }

/* In RTL mode, panel still stays on right (design choice for consistency) */

#info-panel::-webkit-scrollbar { width: 0; }

/* Banner image */
#panel-banner {
  position: relative;
  flex-shrink: 0;
  height: 200px;
  overflow: hidden;
}
#panel-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#panel-banner-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.15) 0%,
    rgba(10,10,10,0.95) 100%
  );
}
#panel-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}
[dir="rtl"] #panel-close { right: auto; left: 10px; }

#panel-header-overlay {
  position: absolute;
  bottom: 12px;
  left: 16px;
  right: 16px;
  z-index: 2;
}
#panel-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
#panel-country-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #aaa;
}
#panel-country-wrap svg { flex-shrink: 0; }
.year-badge {
  background: rgba(212,175,55,0.15);
  border: 1px solid rgba(212,175,55,0.35);
  color: var(--gold);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}
#panel-title {
  font-size: 1.45rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.25;
}

/* Scrollable body */
#panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px 30px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
#panel-body::-webkit-scrollbar { width: 4px; }
#panel-body::-webkit-scrollbar-track { background: transparent; }
#panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.section-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--gold);
  font-weight: 700;
  margin: 16px 0 7px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

#panel-story {
  font-size: 0.87rem;
  line-height: 1.8;
  color: #c5c5c5;
}

.trail-hint {
  font-size: 0.75rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: rgba(26,107,74,0.1);
  border-left: 2px solid var(--green);
  border-radius: 0 6px 6px 0;
  line-height: 1.5;
}
[dir="rtl"] .trail-hint {
  border-left: none;
  border-right: 2px solid var(--green);
  border-radius: 6px 0 0 6px;
}

#panel-ingredients {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.ing-item {
  padding: 9px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 3px solid var(--gold);
  transition: border-color 0.2s;
}
[dir="rtl"] .ing-item {
  border-left: 1px solid var(--border);
  border-right: 3px solid var(--gold);
}
.ing-item-name {
  font-weight: 700;
  font-size: 0.87rem;
  color: var(--text);
  margin-bottom: 3px;
}
.ing-item-origin {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.ing-origin-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ing-year {
  background: rgba(26,107,74,0.2);
  border: 1px solid rgba(26,107,74,0.4);
  color: #4ecca3;
  padding: 1px 7px;
  border-radius: 12px;
  font-size: 0.68rem;
  white-space: nowrap;
}

#panel-recipe {
  font-size: 0.83rem;
  line-height: 1.75;
  color: #b5b5b5;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

/* ══ Timeline ════════════════════════════════════════════ */
#timeline-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  padding: 8px 22px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.92) 0%, transparent 100%);
  pointer-events: none;
}
#timeline-bar > * { pointer-events: auto; }

#timeline-inner {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  direction: ltr !important;
}

#timeline-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.73rem;
  color: var(--muted);
  direction: ltr;
}
#timeline-year {
  color: var(--gold);
  font-weight: 800;
  font-size: 0.95rem;
  min-width: 58px;
  text-align: center;
}

#timeline-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  direction: ltr !important;
  background: linear-gradient(to right, var(--gold) 100%, var(--border) 100%);
}
#timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #000;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(212,175,55,0.6);
}
#timeline-slider::-moz-range-thumb {
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid #000;
  cursor: pointer;
}

.timeline-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.62rem;
  color: #444;
  padding: 0 1px;
  direction: ltr;
}

/* ══ Hint ════════════════════════════════════════════════ */
#hint {
  position: fixed;
  bottom: 78px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  background: rgba(0,0,0,0.78);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.73rem;
  pointer-events: none;
  white-space: nowrap;
  animation: fadeHint 6s ease forwards;
}
@keyframes fadeHint {
  0%  { opacity: 0; }
  12% { opacity: 1; }
  75% { opacity: 1; }
  100%{ opacity: 0; }
}

/* ══ Responsive ══════════════════════════════════════════ */
@media (max-width: 600px) {
  :root { --panel-w: 100vw; }
  .marker-ring { width: 40px; height: 40px; }
  .marker-label { font-size: 9px; }
  #panel-title { font-size: 1.2rem; }
  #logo-text p { display: none; }
}
