/*
 * אספנים — שכבת הרכיבים.
 *
 * הטוקנים יושבים ב-tokens.css. כאן רק כללים שמציירים, וכולם קוראים
 * משתנים. אם צבע או מידה מופיעים כאן כערך קשיח, זו טעות.
 *
 * סדר הקובץ: איפוס והתנהגות דמוית-אפליקציה, טיפוגרפיה, שלד ניווט,
 * רכיבים, מסכים.
 */

/* ================================================================
   1. איפוס והתנהגות דמוית-אפליקציה
   ================================================================ */

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

html {
  /* גובה יציב גם כששורת הכתובת של הדפדפן נכנסת ויוצאת */
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--surface-0);
  color: var(--text-1);
  font-family: var(--font-ui);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /*
   * שלוש השורות שהופכות דף לאפליקציה:
   * ההבהוב הכחול בלחיצה נעלם, המשיכה לרענון מבוטלת כדי שגרירה
   * אנכית לא תשבור את המסך, ובחירת טקסט מושבתת כברירת מחדל כי
   * לחיצה ארוכה על כפתור באפליקציה לא אמורה לסמן אותו.
   */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  -webkit-user-select: none;
  user-select: none;
}

/* טקסט שהמשתמש כן צריך להעתיק — שמות קלפים, מזהים, מחירים */
.selectable,
input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  /* חוסם את תפריט ההקשר בלחיצה ארוכה על אנדרואיד */
  -webkit-touch-callout: none;
}

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

a {
  color: var(--accent);
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

/* מיקוד נראה רק בניווט מקלדת, לא בלחיצת עכבר או מגע */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* פס גלילה דק שלא שובר את הכהות */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-full);
}

.no-scrollbar {
  scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/*
 * משוב מישוש: כל דבר לחיץ מתכווץ קלות. 0.97 ולא 0.95 — במסך קטן
 * כיווץ חזק מדי נראה כמו תקלה ולא כמו לחיצה.
 */
.tap {
  transition: transform var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease);
}

.tap:active {
  transform: scale(0.97);
}

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

  .tap:active {
    transform: none;
  }
}

/* ================================================================
   2. טיפוגרפיה ויישור
   ================================================================
   הכלל: יישור למרכז שמור לערכים בודדים שהעין נועלת עליהם — ערך
   ענק, תגית, מצב ריק, מודאל. כל רשימה, מטא-דאטה ופסקה מיושרות
   לתחילת השורה, כי מרכוז ברשימה הורס את הסריקה האנכית של העין.
   ================================================================ */

h1,
h2,
h3 {
  margin: 0;
  line-height: var(--lh-tight);
  letter-spacing: -0.02em;
  font-weight: 800;
}

p {
  margin: 0;
}

.t-hero {
  font-family: var(--font-num);
  font-size: var(--fs-hero);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.t-display {
  font-size: var(--fs-display);
  font-weight: 800;
}

.t-title {
  font-size: var(--fs-title);
  font-weight: 800;
}

.t-lead {
  font-size: var(--fs-lead);
  font-weight: 600;
}

.t-body {
  font-size: var(--fs-body);
  font-weight: 400;
}

.t-caption {
  font-size: var(--fs-caption);
  color: var(--text-2);
}

.t-micro {
  font-size: var(--fs-micro);
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.02em;
}

.t-muted {
  color: var(--text-2);
}

.t-dim {
  color: var(--text-3);
}

/*
 * כל מספר כספי. tabular-nums מקבע את רוחב הספרה, ולכן מחיר שמתעדכן
 * בזמן אמת לא גורם לשורה שלידו לקפוץ.
 */
.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  /* מספרים וסימני מטבע תמיד משמאל לימין, גם בתוך פסקה עברית */
  direction: ltr;
  unicode-bidi: isolate;
}

.num-strong {
  font-weight: 700;
}

/* עוטף לשם קלף באנגלית בתוך ממשק עברי */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: start;
}

.center {
  text-align: center;
}

/* קיצוץ לשורה אחת ולשתי שורות */
.clamp-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* מגמה: הצבע נושא את המשמעות, והסימן חוזר עליה לנגישות */
.trend-up {
  color: var(--up);
}

.trend-down {
  color: var(--down);
}

.trend-flat {
  color: var(--flat);
}

/* ================================================================
   3. שלד הניווט
   ================================================================ */

.shell {
  display: flex;
  min-height: 100dvh;
}

/* ---------- מסילת ניווט צדית (דסקטופ) ---------- */
.rail {
  display: none;
  flex-direction: column;
  gap: var(--s-1);
  width: var(--rail-w);
  flex: none;
  padding: var(--s-5) var(--s-3) var(--s-4);
  border-inline-end: 1px solid var(--hairline);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  height: 100dvh;
  transition: width var(--t-base) var(--ease);
}

.rail.collapsed {
  width: var(--rail-w-collapsed);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3) var(--s-6);
  overflow: hidden;
}

.rail-mark {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  background: var(--brand-gradient);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #05070b;
  font-size: 18px;
}

.rail-name {
  font-weight: 800;
  font-size: var(--fs-lead);
  white-space: nowrap;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.rail.collapsed .rail-name,
.rail.collapsed .rail-label {
  opacity: 0;
  pointer-events: none;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-2);
  font-weight: 600;
  font-size: var(--fs-body);
  white-space: nowrap;
  position: relative;
  width: 100%;
  text-align: start;
}

.rail-item:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.rail-item.on {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  color: var(--text-1);
}

/* פס הזהות בצד הפריט הפעיל */
.rail-item.on::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: var(--r-full);
  background: var(--brand-gradient);
}

.rail-ic {
  width: 22px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.rail-label {
  transition: opacity var(--t-fast) var(--ease);
}

.rail-foot {
  margin-top: auto;
}

/* ---------- אזור התוכן ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  height: calc(var(--topbar-h) + var(--safe-t));
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding-inline: var(--s-4);
  background: color-mix(in srgb, var(--surface-0) 82%, transparent);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--hairline);
}

.topbar-title {
  font-size: var(--fs-title);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar-actions {
  margin-inline-start: auto;
  display: flex;
  gap: var(--s-2);
  align-items: center;
}

.view {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-4) var(--s-4) calc(var(--tabbar-h) + var(--safe-b) + var(--s-8));
}

/* ---------- סרגל תחתון צף (מובייל) ---------- */
.tabbar {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: var(--z-nav);
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface-0) 78%, transparent);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border-top: 1px solid var(--hairline);
}

.tabbar-inner {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: var(--tabbar-h);
  max-width: 520px;
  margin: 0 auto;
}

.tabbtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--text-3);
  font-size: var(--fs-micro);
  font-weight: 600;
  transition: color var(--t-fast) var(--ease);
}

.tabbtn .ic {
  font-size: 20px;
  line-height: 1;
  transition: transform var(--t-base) var(--ease);
}

.tabbtn.on {
  color: var(--accent);
}

.tabbtn.on .ic {
  transform: translateY(-1px);
}

/*
 * כפתור הסריקה: מוגבה 8 פיקסלים מעל הסרגל עם הילה. זה הפעולה
 * המרכזית של האפליקציה, ולכן הוא לא נראה כמו עוד טאב.
 */
.tabbtn.scan .ic {
  width: 52px;
  height: 52px;
  margin-top: -22px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  background: var(--brand-gradient);
  color: #05070b;
  font-size: 24px;
  border: 3px solid var(--surface-0);
  box-shadow: 0 0 0 1px var(--hairline), 0 8px 24px color-mix(in srgb, var(--brand) 50%, transparent),
    0 0 32px color-mix(in srgb, var(--brand-2) 30%, transparent);
}

.tabbtn.scan:active .ic {
  transform: scale(0.92);
}

.tabbtn.scan span:last-child {
  margin-top: -4px;
}

/* ---------- מעבר לדסקטופ ---------- */
@media (min-width: 1024px) {
  .rail {
    display: flex;
  }

  .tabbar {
    display: none;
  }

  .view {
    padding: var(--s-6) var(--s-6) var(--s-10);
  }
}

/* ================================================================
   4. רכיבי בסיס
   ================================================================ */

.card {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--s-4);
}

.card-hover:hover {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
}

/* ---------- כפתורים ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 13px var(--s-5);
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: var(--fs-body);
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #05070b;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--brand) 32%, transparent);
}

.btn-accent {
  background: linear-gradient(112deg, var(--accent), var(--accent-2));
  color: #05070b;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 32%, transparent);
}

.btn-ghost {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-1);
}

.btn-ghost:hover {
  border-color: var(--hairline-strong);
  background: var(--surface-3);
}

.btn-danger {
  background: color-mix(in srgb, var(--down) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--down) 35%, transparent);
  color: var(--down);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
}

.icon-btn:hover {
  color: var(--text-1);
  background: var(--surface-2);
}

/* ---------- תגיות ---------- */
/* תמיד ממורכזות: תגית היא ערך בודד, לא שורת טקסט. */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-1);
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: var(--fs-micro);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

.pill-neutral {
  background: var(--surface-2);
  color: var(--text-2);
  border-color: var(--hairline);
}

.pill-up {
  background: color-mix(in srgb, var(--up) 14%, transparent);
  color: var(--up);
  border-color: color-mix(in srgb, var(--up) 30%, transparent);
}

.pill-down {
  background: color-mix(in srgb, var(--down) 14%, transparent);
  color: var(--down);
  border-color: color-mix(in srgb, var(--down) 30%, transparent);
}

/* דירוג: מסגרת מוזהבת, כי זה תג הערך של הפריט */
.pill-graded {
  background: linear-gradient(112deg, color-mix(in srgb, #eab308 18%, transparent), color-mix(in srgb, #f59e0b 10%, transparent));
  color: #fcd34d;
  border-color: color-mix(in srgb, #eab308 40%, transparent);
  font-family: var(--font-num);
  font-weight: 700;
}

/* ---------- מסנן תגיות אופקי ---------- */
.pills {
  display: flex;
  gap: var(--s-2);
  overflow-x: auto;
  padding-block: var(--s-1) var(--s-3);
  /* גלילה שנעצרת על תגית שלמה ולא באמצע */
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}

.pills > * {
  scroll-snap-align: start;
  flex: none;
}

.chip {
  padding: 8px 14px;
  border-radius: var(--r-full);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  color: var(--text-2);
  font-size: var(--fs-caption);
  font-weight: 600;
  white-space: nowrap;
}

.chip:hover {
  color: var(--text-1);
  border-color: var(--hairline-strong);
}

.chip.on {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface-1));
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ---------- שדות טופס ---------- */
label {
  display: block;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: var(--text-2);
  margin: var(--s-4) 0 var(--s-2);
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='search'],
select,
textarea {
  width: 100%;
  padding: 13px var(--s-3);
  background: var(--surface-0);
  color: var(--text-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  outline: none;
  /* 16px מונע מ-iOS להגדיל את המסך אוטומטית בפוקוס */
  font-size: 16px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

input[inputmode='decimal'],
input[inputmode='numeric'],
input[type='number'],
input[type='date'] {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(var(--s-4) - 3px) 50%, calc(var(--s-4) + 2px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.field-error {
  margin-top: var(--s-3);
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--down) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--down) 30%, transparent);
  color: #fda4af;
  font-size: var(--fs-caption);
}

/* מקטע בורר (Segmented control) */
.seg {
  display: flex;
  gap: var(--s-1);
  background: var(--surface-0);
  padding: var(--s-1);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
}

.seg button {
  flex: 1;
  padding: 9px var(--s-2);
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-weight: 600;
  font-size: var(--fs-caption);
  text-align: center;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.seg button.on {
  background: var(--surface-2);
  color: var(--text-1);
}

.seg-accent button.on {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
  color: var(--accent);
}

/* ================================================================
   5. כרטיס קלף וגריד
   ================================================================ */

.grid {
  display: grid;
  gap: var(--s-3);
}

/*
 * גריד הקלפים: 2 עמודות במובייל, 3 בטאבלט, עד 6 במסך רחב. הרוחב
 * המינימלי משאיר את הארט קריא ולא מכווץ אותו לבול.
 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
}

@media (min-width: 560px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

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

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

@media (min-width: 1500px) {
  .card-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  text-align: start;
  width: 100%;
}

/*
 * מסגרת התמונה שומרת על יחס קלף קבוע, ולכן הגריד לא קופץ כשהתמונה
 * מגיעה. זה מה שמחזיק Cumulative Layout Shift על אפס.
 */
.tile-art {
  position: relative;
  aspect-ratio: var(--card-ratio);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--ph, var(--surface-2));
  border: 1px solid var(--hairline);
  isolation: isolate;
}

.tile-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--t-slow) var(--ease);
}

.tile-art img.ready {
  opacity: 1;
}

/* צללית בצבע הדומיננטי של הקלף בזמן הטעינה */
.tile-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, var(--ph, var(--surface-2)), var(--surface-1));
  filter: blur(12px);
  transform: scale(1.2);
  transition: opacity var(--t-slow) var(--ease);
  z-index: -1;
}

.tile-art.loaded::before {
  opacity: 0;
}

.tile-meta {
  min-width: 0;
}

.tile-name {
  font-size: var(--fs-caption);
  font-weight: 600;
  line-height: var(--lh-snug);
}

.tile-sub {
  font-size: var(--fs-micro);
  color: var(--text-3);
  margin-top: 2px;
}

.tile-price {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-caption);
  font-weight: 700;
  direction: ltr;
  text-align: start;
}

/* תגית פינה על הארט */
.tile-badge {
  position: absolute;
  top: var(--s-2);
  inset-inline-start: var(--s-2);
  z-index: 2;
}

.tile-corner {
  position: absolute;
  bottom: var(--s-2);
  inset-inline-end: var(--s-2);
  z-index: 2;
  padding: 2px 7px;
  border-radius: var(--r-sm);
  background: rgba(5, 7, 11, 0.72);
  backdrop-filter: blur(8px);
  font-family: var(--font-num);
  font-size: var(--fs-micro);
  font-weight: 700;
  direction: ltr;
}

/* ---------- שורת רשימה (תצוגת משקיעים) ---------- */
.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  width: 100%;
  text-align: start;
}

.row + .row {
  margin-top: var(--s-2);
}

.row:hover {
  background: var(--surface-2);
  border-color: var(--hairline-strong);
}

.row-art {
  width: 42px;
  aspect-ratio: var(--card-ratio);
  border-radius: 6px;
  overflow: hidden;
  flex: none;
  background: var(--ph, var(--surface-2));
}

.row-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.row-main {
  flex: 1;
  min-width: 0;
}

/*
 * הצד הכספי: התוויות בתחילת השורה והמספרים בסופה. ההפרדה הזו היא
 * מה שמאפשר לסרוק עמודת מחירים במבט אחד.
 */
.row-end {
  flex: none;
  text-align: end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

/* שורת נתון: תווית מימין, ערך משמאל */
.kv {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--hairline);
}

.kv:last-child {
  border-bottom: 0;
}

.kv-k {
  font-size: var(--fs-caption);
  color: var(--text-2);
  font-weight: 600;
}

.kv-v {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  direction: ltr;
}

/* ---------- החלקה למחיקה ---------- */
.swipe {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-md);
}

.swipe-body {
  position: relative;
  z-index: 1;
  transition: transform var(--t-base) var(--ease);
  will-change: transform;
}

.swipe-action {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: 84px;
  display: grid;
  place-items: center;
  background: var(--down);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-caption);
}

/* ================================================================
   6. קרוסלה עם נקודות עצירה
   ================================================================ */

.carousel {
  display: flex;
  gap: var(--s-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline-start: var(--s-4);
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--s-2);
  /* יוצא אל מחוץ לפדינג של המסך כדי שהגלילה תיגע בקצה */
  margin-inline: calc(var(--s-4) * -1);
  padding-inline: var(--s-4);
}

.carousel > * {
  scroll-snap-align: start;
  flex: none;
}

.carousel-item {
  width: 132px;
}

.carousel-item.wide {
  width: 240px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin: var(--s-6) 0 var(--s-3);
}

.section-head:first-child {
  margin-top: 0;
}

.section-head h2 {
  font-size: var(--fs-lead);
}

.section-more {
  margin-inline-start: auto;
  font-size: var(--fs-caption);
  color: var(--text-2);
  font-weight: 600;
}

/* ================================================================
   7. קלף הולוגרפי
   ================================================================ */

.holo-stage {
  perspective: 1100px;
  display: grid;
  place-items: center;
  padding: var(--s-4) 0;
}

.holo {
  position: relative;
  width: min(280px, 68vw);
  aspect-ratio: var(--card-ratio);
  border-radius: var(--r-md);
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform var(--t-slow) var(--ease);
  box-shadow: var(--shadow-3);
  background: var(--surface-2);
  will-change: transform;
}

.holo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/*
 * שכבת הנצנוץ. --mx/--my מתעדכנים מהעכבר במחשב ומהגירוסקופ במובייל,
 * ולכן הברק זז עם הקלף כמו על קלף פויל אמיתי.
 */
.holo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.4), transparent 42%),
    linear-gradient(
      115deg,
      transparent 26%,
      color-mix(in srgb, var(--accent) 42%, transparent) 42%,
      rgba(255, 0, 200, 0.28) 50%,
      color-mix(in srgb, var(--accent-2) 42%, transparent) 58%,
      transparent 74%
    );
  background-size: 100% 100%, 240% 240%;
  background-position: 0 0, var(--sheen-x, 50%) var(--sheen-y, 50%);
  mix-blend-mode: color-dodge;
  opacity: var(--sheen, 0);
  transition: opacity var(--t-base) var(--ease);
  pointer-events: none;
}

/* קלף נדיר מנצנץ מעט גם במנוחה, כדי שיבלוט בגריד */
.holo.rare {
  --sheen: 0.35;
}

.holo.rare::after {
  animation: idle-sheen 5s var(--ease-in-out) infinite;
}

@keyframes idle-sheen {
  0%,
  100% {
    background-position: 0 0, 22% 30%;
  }
  50% {
    background-position: 0 0, 78% 70%;
  }
}

/* ================================================================
   8. גיליון תחתון (Bottom Sheet)
   ================================================================ */

.sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: grid;
  align-items: end;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 9, 0.66);
  backdrop-filter: blur(4px);
  animation: fade-in var(--t-base) var(--ease);
}

.sheet-panel {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-bottom: 0;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  padding: var(--s-2) var(--s-5) calc(var(--s-6) + var(--safe-b));
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: sheet-up var(--t-base) var(--ease);
  will-change: transform;
  box-shadow: var(--shadow-3);
}

/* במסך רחב הגיליון הופך לחלון ממורכז */
@media (min-width: 768px) {
  .sheet {
    place-items: center;
  }

  .sheet-panel {
    width: min(480px, 92vw);
    border-radius: var(--r-xl);
    border-bottom: 1px solid var(--hairline);
    padding-bottom: var(--s-6);
    animation: pop-in var(--t-base) var(--ease);
  }
}

.sheet-grip {
  width: 40px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  margin: var(--s-2) auto var(--s-4);
}

@keyframes sheet-up {
  from {
    transform: translateY(24px);
    opacity: 0;
  }
}

@keyframes pop-in {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

/* ---------- מגירת פרטים (דסקטופ) ---------- */
.drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: var(--z-drawer);
  width: var(--drawer-w);
  max-width: 100vw;
  background: var(--surface-1);
  border-inline-start: 1px solid var(--hairline);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-5) var(--s-5) var(--s-10);
  box-shadow: var(--shadow-3);
  animation: drawer-in var(--t-base) var(--ease);
}

@keyframes drawer-in {
  from {
    transform: translateX(var(--drawer-from, 100%));
    opacity: 0;
  }
}

/* ================================================================
   9. גרף
   ================================================================ */

.chart-wrap {
  position: relative;
  touch-action: pan-y;
}

.chart {
  width: 100%;
  height: 180px;
  display: block;
  overflow: visible;
}

.chart-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--hairline-strong);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}

.chart-tip {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  border: 1px solid var(--hairline-strong);
  font-family: var(--font-num);
  font-size: var(--fs-micro);
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
  direction: ltr;
  box-shadow: var(--shadow-2);
}

.chart-wrap.active .chart-cursor,
.chart-wrap.active .chart-tip {
  opacity: 1;
}

/* ================================================================
   10. סורק
   ================================================================ */

.scanner {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: #000;
  display: flex;
  flex-direction: column;
}

.scanner video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-ui {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.scanner-top {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: calc(var(--safe-t) + var(--s-4)) var(--s-4) var(--s-3);
}

/*
 * הכוונת: החור במסכה נוצר מ-box-shadow ענק, ולכן אין צורך בשכבה
 * נוספת מעל הווידאו.
 */
.viewfinder {
  position: absolute;
  inset-inline: 12%;
  top: 50%;
  transform: translateY(-50%);
  aspect-ratio: var(--card-ratio);
  border-radius: var(--r-lg);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.58);
  transition: box-shadow var(--t-base) var(--ease);
  pointer-events: none;
}

.viewfinder-corner {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid var(--brand-2);
  transition: border-color var(--t-base) var(--ease);
}

.viewfinder-corner.tl {
  top: -2px;
  inset-inline-start: -2px;
  border-inline-end: 0;
  border-block-end: 0;
  border-start-start-radius: var(--r-lg);
}

.viewfinder-corner.tr {
  top: -2px;
  inset-inline-end: -2px;
  border-inline-start: 0;
  border-block-end: 0;
  border-start-end-radius: var(--r-lg);
}

.viewfinder-corner.bl {
  bottom: -2px;
  inset-inline-start: -2px;
  border-inline-end: 0;
  border-block-start: 0;
  border-end-start-radius: var(--r-lg);
}

.viewfinder-corner.br {
  bottom: -2px;
  inset-inline-end: -2px;
  border-inline-start: 0;
  border-block-start: 0;
  border-end-end-radius: var(--r-lg);
}

/* קו סריקה נע, הרמז הוויזואלי שהמערכת עובדת */
.viewfinder-beam {
  position: absolute;
  inset-inline: 6px;
  height: 2px;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, transparent, var(--brand-2), transparent);
  animation: beam 2.4s var(--ease-in-out) infinite;
  opacity: 0.85;
}

@keyframes beam {
  0%,
  100% {
    top: 8%;
  }
  50% {
    top: 92%;
  }
}

/* נעילה: הכוונת מוריקה, הקו נעצר */
.scanner.locked .viewfinder-corner {
  border-color: var(--up);
}

.scanner.locked .viewfinder {
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.58), 0 0 40px var(--up-glow);
}

.scanner.locked .viewfinder-beam {
  opacity: 0;
}

.scanner-hint {
  position: absolute;
  inset-inline: var(--s-6);
  bottom: calc(var(--safe-b) + 148px);
  text-align: center;
  font-size: var(--fs-caption);
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.scanner-foot {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: var(--s-5) var(--s-4) calc(var(--safe-b) + var(--s-6));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-8);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
}

.shutter {
  width: 74px;
  height: 74px;
  border-radius: var(--r-full);
  background: #fff;
  border: 5px solid rgba(255, 255, 255, 0.35);
  background-clip: padding-box;
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.25);
  transition: transform var(--t-fast) var(--ease);
}

.shutter:active {
  transform: scale(0.9);
}

.shutter:disabled {
  opacity: 0.5;
}

/* ================================================================
   11. מצבים: ריק, טעינה, הודעה
   ================================================================ */

/* מצב ריק ממורכז: אין כאן רשימה לסרוק, יש מסר אחד. */
.empty {
  text-align: center;
  padding: var(--s-12) var(--s-5);
  color: var(--text-2);
}

.empty-ic {
  font-size: 44px;
  opacity: 0.35;
  margin-bottom: var(--s-3);
}

.empty h3 {
  font-size: var(--fs-lead);
  margin-bottom: var(--s-2);
  color: var(--text-1);
}

.empty p {
  font-size: var(--fs-caption);
  line-height: var(--lh-body);
  max-width: 34ch;
  margin: 0 auto var(--s-5);
}

.skeleton {
  background: linear-gradient(100deg, var(--surface-1) 30%, var(--surface-2) 50%, var(--surface-1) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--r-md);
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.sk-tile {
  aspect-ratio: var(--card-ratio);
}

.toast {
  position: fixed;
  inset-inline: var(--s-4);
  bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s-4));
  z-index: var(--z-toast);
  margin: 0 auto;
  max-width: 400px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--surface-3);
  border: 1px solid var(--hairline-strong);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-caption);
  font-weight: 600;
  text-align: center;
  animation: sheet-up var(--t-base) var(--ease);
}

.toast.good {
  border-color: color-mix(in srgb, var(--up) 45%, transparent);
  color: #6ee7b7;
}

.toast.bad {
  border-color: color-mix(in srgb, var(--down) 45%, transparent);
  color: #fda4af;
}

@media (min-width: 1024px) {
  .toast {
    bottom: var(--s-6);
  }
}

.progress {
  height: 2px;
  border-radius: var(--r-full);
  background: var(--surface-2);
  overflow: hidden;
}

.progress::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  border-radius: var(--r-full);
  background: var(--brand-gradient);
  animation: indeterminate 1.1s var(--ease-in-out) infinite;
}

@keyframes indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}

/* ================================================================
   12. שער כניסה
   ================================================================ */

.gate {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--s-8) var(--s-5) calc(var(--s-8) + var(--safe-b));
  overflow: hidden;
}

.gate-aurora {
  position: absolute;
  inset: -25% -20% auto -20%;
  height: 75vh;
  background: radial-gradient(42% 52% at 28% 28%, color-mix(in srgb, var(--brand) 32%, transparent), transparent 70%),
    radial-gradient(38% 48% at 74% 18%, color-mix(in srgb, var(--brand-2) 26%, transparent), transparent 70%);
  filter: blur(24px);
  pointer-events: none;
}

.gate-inner {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.gate-logo {
  font-size: 2.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gate-card {
  background: color-mix(in srgb, var(--surface-1) 78%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--hairline);
  border-radius: var(--r-xl);
  padding: var(--s-5);
  box-shadow: var(--shadow-2);
}

.gate-points {
  list-style: none;
  padding: 0;
  margin: var(--s-6) 0 0;
  color: var(--text-2);
  font-size: var(--fs-caption);
  line-height: 2;
}

.gate-points b {
  color: var(--accent);
  margin-inline-end: var(--s-2);
}

.boot {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--surface-0);
  z-index: 100;
}

.boot-mark {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: var(--brand-gradient);
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 800;
  color: #05070b;
  animation: breathe 1.5s var(--ease-in-out) infinite;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(0.9);
    opacity: 0.7;
  }
}

/* ================================================================
   13. עזרי פריסה
   ================================================================ */

.stack > * + * {
  margin-top: var(--s-3);
}

.stack-lg > * + * {
  margin-top: var(--s-5);
}

.cluster {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-3);
}

.spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

/* פריסת דסקטופ עם מגירה פתוחה: התוכן מתכווץ ולא נחתך */
@media (min-width: 1024px) {
  body.drawer-open .main {
    padding-inline-end: var(--drawer-w);
  }
}
