/* Bike Shop Mini App — dark-by-default, phone-native shape.
   Per-shop branding is injected via CSS custom properties (--brand,
   --brand-accent) set from the loaded shop record. Layout is a
   fixed top bar + scrollable view + fixed bottom tab bar, sized
   to the Telegram WebApp viewport. */

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; width: 100%; }
html { background: var(--bg, #0b0f14); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink, #e7edf3);
  background: var(--bg, #0b0f14);
  overflow: hidden;
  overscroll-behavior: none;
}

:root {
  /* Dark theme by default — overridden if shop.theme_dark is false */
  --bg:           #0b0f14;
  --bg-elev-1:   #131922;
  --bg-elev-2:   #1c2330;
  --ink:         #e7edf3;
  --ink-dim:     #98a2b3;
  --ink-faint:   #6b7280;
  --rule:        #232a37;
  --brand:       #16A34A;       /* overridden per shop */
  --brand-accent:#F97316;       /* overridden per shop */
  --topbar-h:    56px;
  --tabbar-h:    66px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body.theme-light {
  --bg:        #ffffff;
  --bg-elev-1: #f5f6f8;
  --bg-elev-2: #ecedf0;
  --ink:       #0b0f14;
  --ink-dim:   #4a5260;
  --ink-faint: #8a93a1;
  --rule:      #e3e6eb;
}

/* ───── Splash ───── */
.splash {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 100;
  background: var(--bg);
  transition: opacity .25s ease;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash-mark { font-size: 56px; line-height: 1; }
.splash-name { margin-top: 12px; color: var(--ink-dim); font-size: 14px; letter-spacing: .02em; }

/* ───── App shell ───── */
#app { height: 100%; width: 100%; display: grid;
       grid-template-rows: calc(var(--topbar-h) + var(--safe-top)) 1fr calc(var(--tabbar-h) + var(--safe-bottom)); }

/* ───── Top bar ───── */
.topbar {
  background: var(--bg-elev-1);
  border-bottom: 1px solid var(--rule);
  padding: calc(8px + var(--safe-top)) 16px 8px;
  display: flex; align-items: center;
}
.topbar-shop { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-logo {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  background: var(--bg-elev-2); object-fit: cover;
  display: grid; place-items: center; font-size: 18px;
}
.topbar-logo[src=""] { display: none; }
.topbar-text { min-width: 0; }
.topbar-name { font-size: 15px; font-weight: 600; line-height: 1.2; color: var(--ink);
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-town { font-size: 12px; color: var(--ink-dim); margin-top: 2px;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───── Scrollable view ───── */
.view {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 24px;
  scroll-behavior: smooth;
}
.view::-webkit-scrollbar { display: none; }

/* ───── Bottom tab bar ───── */
.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-elev-1);
  border-top: 1px solid var(--rule);
  padding-bottom: var(--safe-bottom);
}
.tab {
  background: transparent; border: 0; color: var(--ink-faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 8px 0 6px;
  font: inherit; cursor: pointer;
  transition: color .15s ease;
}
.tab[aria-selected="true"] { color: var(--brand); }
.tab[aria-selected="true"] .tab-icon { transform: translateY(-1px); }
.tab-icon { font-size: 22px; line-height: 1; }
.tab-label { font-size: 11px; font-weight: 600; letter-spacing: .02em; }
.tab:active { background: var(--bg-elev-2); }

/* ───── Hero card (home) ───── */
.hero {
  border-radius: 18px;
  overflow: hidden;
  background: var(--bg-elev-1);
  margin-bottom: 16px;
  position: relative;
  aspect-ratio: 16 / 10;
  display: grid;
  align-items: end;
}
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade { position: absolute; inset: 0;
              background: linear-gradient(180deg, transparent 45%, rgba(0,0,0,.75) 100%); }
.hero-text { position: relative; padding: 16px 18px 18px; }
.hero-tagline { color: #fff; font-size: 16px; line-height: 1.35; font-weight: 500;
                text-shadow: 0 1px 3px rgba(0,0,0,.5); }

/* ───── Section heading ───── */
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 4px 12px;
}
.section-title { font-size: 14px; font-weight: 700; letter-spacing: .06em;
                 text-transform: uppercase; color: var(--ink-dim); }
.section-link  { font-size: 13px; color: var(--brand); font-weight: 600; background: transparent;
                 border: 0; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.section-link:active { background: var(--bg-elev-2); }

/* ───── Card lists ───── */
.cards { display: grid; gap: 12px; }
.card {
  background: var(--bg-elev-1);
  border-radius: 16px;
  overflow: hidden;
  display: grid;
  border: 1px solid var(--rule);
}
.card-img-wrap { aspect-ratio: 16 / 10; background: var(--bg-elev-2);
                 position: relative; overflow: hidden; }
.card-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-body { padding: 14px 16px 16px; }
.card-title { font-size: 16px; font-weight: 650; color: var(--ink); line-height: 1.3; }
.card-meta {
  display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 0;
  font-size: 12px; color: var(--ink-dim);
}
.chip { background: var(--bg-elev-2); padding: 4px 10px; border-radius: 999px;
        color: var(--ink-dim); font-size: 12px; }
.chip-brand { background: color-mix(in srgb, var(--brand) 18%, transparent);
              color: var(--brand); }
.chip-grade-easy        { color: #22c55e; }
.chip-grade-intermediate{ color: #f59e0b; }
.chip-grade-advanced    { color: #ef4444; }
.chip-grade-expert      { color: #a855f7; }
.card-text { font-size: 14px; color: var(--ink-dim); line-height: 1.45; margin-top: 8px; }
.card-cta {
  margin-top: 14px;
  background: var(--brand); color: #fff; border: 0; font: inherit;
  font-size: 14px; font-weight: 650;
  padding: 12px 16px; border-radius: 12px;
  width: 100%; cursor: pointer;
}
.card-cta:active { filter: brightness(.85); }
.card-cta.secondary { background: var(--bg-elev-2); color: var(--ink); }

/* ───── Deal price ───── */
.price-line { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; }
.price-now  { font-size: 20px; font-weight: 700; color: var(--brand); }
.price-was  { font-size: 14px; color: var(--ink-faint); text-decoration: line-through; }
.price-free { font-size: 16px; font-weight: 600; color: var(--brand-accent); }

/* ───── More tab — list rows ───── */
.row-list { display: grid; gap: 1px; background: var(--rule);
            border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 14px 16px;
       background: var(--bg-elev-1); cursor: pointer; }
.row-icon { font-size: 22px; }
.row-text { flex: 1; min-width: 0; }
.row-title { font-size: 15px; color: var(--ink); font-weight: 600; }
.row-sub   { font-size: 12px; color: var(--ink-dim); margin-top: 2px;
             white-space: pre-wrap; }
.row-arrow { color: var(--ink-faint); font-size: 18px; }

/* ───── Empty / loading states ───── */
.empty { padding: 28px 16px; text-align: center; color: var(--ink-faint); font-size: 14px; }
.skel { background: linear-gradient(90deg, var(--bg-elev-1) 0%, var(--bg-elev-2) 50%, var(--bg-elev-1) 100%);
        background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
        border-radius: 12px; }
.skel-card { height: 180px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ───── Error overlay ───── */
.error { position: fixed; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
         left: 16px; right: 16px; background: #b91c1c; color: #fff;
         padding: 12px 16px; border-radius: 12px; font-size: 14px;
         box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 50; }
