/* ==========================================================================
   BOBCAFE — Design tokens
   Palette: sage/olive green primary (#55704A) on a warm peach-cream
   background (#FFF0E0) — every accent, border and hover state derives
   from these two brand colors.
   Type: Vazirmatn (display + body, weight contrast carries hierarchy)
   ========================================================================== */

:root {
  /* --- color: light mode --- */
  --bg: #FFF0E0;
  --bg-elevated: #FFFBF5;
  --surface: #FCE2C4;
  --surface-hover: #F8D3AC;
  --border: rgba(85, 112, 74, 0.18);
  --text: #2B2A1F;
  --text-secondary: #5B6B50;
  --text-muted: #8C9280;
  --accent: #1D533C;
  --accent-2: #6F8B60;
  --accent-soft: rgba(85, 112, 74, 0.14);
  --gold: #55704A;
  --shadow-color: 40, 40, 20;
  --overlay: rgba(43, 42, 31, 0.55);

  /* --- type --- */
  --font-display: "Vazirmatn", "Estedad", sans-serif;
  --font-body: "Vazirmatn", "Estedad", sans-serif;

  /* --- layout --- */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --container: 1180px;
  --controls-height: 132px;

  /* --- motion --- */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 180ms;
  --med: 320ms;
}

[data-theme="dark"] {
  --bg: #171A13;
  --bg-elevated: #1F2318;
  --surface: #262B1D;
  --surface-hover: #2E3423;
  --border: rgba(255, 240, 224, 0.09);
  --text: #FFF0E0;
  --text-secondary: #C8CBB8;
  --text-muted: #8D9080;
  --accent: #86AB74;
  --accent-2: #9BBD8B;
  --accent-soft: rgba(134, 171, 116, 0.18);
  --gold: #86AB74;
  --shadow-color: 0, 0, 0;
  --overlay: rgba(8, 10, 6, 0.65);
}

/* Dark mode is opt-in only (manual toggle + saved preference).
   It is applied purely via the [data-theme="dark"] attribute above —
   the site intentionally does not follow prefers-color-scheme, so a
   first-time visitor always sees Light Mode regardless of OS setting. */

/* ==========================================================================
   Reset & base
   ========================================================================== */

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

/* The [hidden] attribute must always win over component display rules
   (e.g. .state-panel { display: flex }) — otherwise a later, equally
   specific author rule can keep a "hidden" element visually visible. */
[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--med) var(--ease), color var(--med) var(--ease);
  overflow-x: hidden;
}

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

a {
  color: var(--accent);
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 2px;
}
a:hover { color: var(--accent-2); }
button { font-family: inherit; }
ul, ol { margin: 0; padding: 0; }
h1, h2, h3, p { margin: 0; }

/* Visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.skip-link {
  position: absolute;
  right: -9999px;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus {
  right: 12px;
  top: 12px;
}

/* ==========================================================================
   HERO
   ========================================================================== */

.hero {
  position: relative;
  padding: 56px 20px 88px;
  background:
    radial-gradient(ellipse 120% 100% at 50% -10%, var(--accent-soft), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg) 100%);
  text-align: center;
  overflow: hidden;
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(168,103,47,0.10) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, black, transparent 85%);
  z-index: -1;
}

.hero__backdrop {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.hero__steam {
  position: absolute;
  bottom: 10%;
  width: 40px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, var(--accent-soft), transparent 70%);
  filter: blur(6px);
  opacity: 0.6;
  animation: steamRise 7s ease-in-out infinite;
}
.hero__steam.s1 { right: 12%; animation-delay: 0s; }
.hero__steam.s2 { right: 22%; animation-delay: 1.4s; width: 30px; }
.hero__steam.s3 { right: 33%; animation-delay: 2.8s; width: 24px; }

@keyframes steamRise {
  0%   { transform: translateY(0) scaleX(1); opacity: 0; }
  20%  { opacity: 0.5; }
  100% { transform: translateY(-160px) scaleX(1.6); opacity: 0; }
}

.hero__content {
  position: relative;
  animation: heroEnter 900ms var(--ease) both;
}

@keyframes heroEnter {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero__logo {
  margin: 0 auto 18px;
  border-radius: 50%;
  box-shadow: 0 10px 30px -8px rgba(var(--shadow-color), 0.35);
  animation: heroEnter 900ms var(--ease) both;
}

.hero__eyebrow {
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 6px;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.05;
}

.hero__title-accent {
  color: var(--accent);
}

.hero__subtitle {
  margin-top: 14px;
  font-size: clamp(0.95rem, 2.6vw, 1.1rem);
  color: var(--text-secondary);
  font-weight: 400;
  max-width: 34ch;
  margin-inline: auto;
}

.theme-toggle {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 4px 14px -6px rgba(var(--shadow-color), 0.3);
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease);
}
.theme-toggle:hover { transform: translateY(-2px); }
.theme-toggle:active { transform: translateY(0) scale(0.94); }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.8; position: absolute; transition: opacity var(--fast) var(--ease), transform var(--fast) var(--ease); }
.theme-toggle .icon-sun circle { fill: currentColor; stroke: none; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }

.theme-toggle .icon-moon { opacity: 0; transform: rotate(-40deg) scale(0.6); }
.theme-toggle .icon-sun { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .theme-toggle .icon-sun { opacity: 0; transform: rotate(40deg) scale(0.6); }
[data-theme="dark"] .theme-toggle .icon-moon { opacity: 1; transform: rotate(0) scale(1); }

/* ==========================================================================
   STICKY CONTROLS — search + category chips
   ========================================================================== */

.controls {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 20px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}

.controls.is-stuck {
  border-bottom-color: var(--border);
  box-shadow: 0 12px 24px -20px rgba(var(--shadow-color), 0.5);
}

.search-bar {
  max-width: var(--container);
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 12px 16px;
  transition: box-shadow var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.search-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.search-bar__icon { stroke: var(--text-muted); fill: none; stroke-width: 2; flex-shrink: 0; }

.search-bar__input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 15.5px;
  font-family: inherit;
  min-width: 0;
}
.search-bar__input::placeholder { color: var(--text-muted); }

.search-bar__clear {
  border: 0;
  background: var(--surface);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.search-bar__clear:hover { background: var(--surface-hover); }
.search-bar__clear:active { transform: scale(0.9); }

.chips {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 2px 4px;
  -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--fast) var(--ease), color var(--fast) var(--ease),
              border-color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.chip:hover { transform: translateY(-1px); border-color: var(--accent); color: var(--accent); }
.chip:active { transform: translateY(0) scale(0.97); }

.chip[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px -6px var(--accent-soft);
}

.chip__icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--accent);
  transition: color var(--fast) var(--ease);
}
.chip__icon svg { width: 100%; height: 100%; stroke: currentColor; fill: none; }
.chip[aria-selected="true"] .chip__icon { color: #fff; }

.chip__count {
  font-size: 11px;
  opacity: 0.75;
}

/* ==========================================================================
   MAIN / GRID
   ========================================================================== */

.main {
  max-width: var(--container);
  margin: 0 auto;
  padding: 28px 20px 40px;
  min-height: 40vh;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.result-count {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Category section headers when "all" filter is active */
.category-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 28px 0 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.category-heading:first-child { margin-top: 4px; }

.category-heading__title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}
.category-heading__count {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==========================================================================
   MENU CARD
   ========================================================================== */

.card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: default;
  transition: transform var(--med) var(--ease), box-shadow var(--med) var(--ease), border-color var(--med) var(--ease);
  animation: cardFadeIn 560ms var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 40px -20px rgba(var(--shadow-color), 0.35);
  border-color: transparent;
}

.card:active {
  transform: translateY(-2px) scale(0.99);
}

.card__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface);
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease);
}
.card:hover .card__media img { transform: scale(1.06); }

.card__badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: color-mix(in srgb, var(--overlay) 60%, transparent);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.01em;
}

.card__body {
  padding: 18px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.card__name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.card__desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__price {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  color: var(--accent);
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.card__price small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.card__mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}
.card__mark svg { stroke: currentColor; fill: none; stroke-width: 2; }

/* highlighted search match */
mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 2px;
}

/* ==========================================================================
   SKELETON LOADING STATE
   ========================================================================== */

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.skel-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.skel-media, .skel-line {
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-hover) 50%, var(--surface) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
.skel-media { aspect-ratio: 16/9; }
.skel-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.skel-line { height: 12px; border-radius: 6px; }
.skel-line.w60 { width: 60%; }
.skel-line.w90 { width: 90%; }
.skel-line.w40 { width: 40%; margin-top: 6px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   EMPTY / ERROR STATES
   ========================================================================== */

.state-panel {
  max-width: 420px;
  margin: 60px auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: cardFadeIn 500ms var(--ease) both;
}

.state-panel__icon {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 6px;
}
.state-panel__icon svg { stroke: currentColor; fill: none; stroke-width: 1.6; }

.state-panel__title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.state-panel__text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.btn {
  margin-top: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  padding: 11px 26px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--fast) var(--ease), background var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(0.96); }

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 20px -10px var(--accent-soft);
}
.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface); }

/* ==========================================================================
   FOOTER
   ========================================================================== */

.footer {
  padding: 48px 20px 100px;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
}
.footer__brand img { border-radius: 50%; }

.footer__text {
  font-size: 13.5px;
  color: var(--text-secondary);
}
.footer__copy {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   FLOATING ACTION BUTTON (back to top)
   ========================================================================== */

.fab {
  position: fixed;
  bottom: 24px;
  left: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 14px 28px -12px rgba(var(--shadow-color), 0.45);
  z-index: 60;
  opacity: 0;
  transform: translateY(16px) scale(0.9);
  pointer-events: none;
  transition: opacity var(--med) var(--ease), transform var(--med) var(--ease);
}
.fab.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.fab:hover { transform: translateY(-3px) scale(1.03); }
.fab:active { transform: translateY(0) scale(0.94); }
.fab svg { stroke: currentColor; fill: none; stroke-width: 2; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (min-width: 640px) {
  .hero { padding: 72px 32px 104px; }
  .main { padding: 32px 32px 48px; }
  .controls { padding: 16px 32px 14px; }
}

@media (min-width: 900px) {
  .menu-grid, .skeleton-grid { grid-template-columns: repeat(3, 1fr); }
  .hero__title { font-size: 4.6rem; }
}

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

@media (max-width: 380px) {
  .hero__title { font-size: 2.3rem; }
  .card__desc { -webkit-line-clamp: 3; }
}