/* Terrateana — komponente: kartice, dugmad, chipovi, sheet, toast, ring, skele */

/* ---------- kartice ---------- */
.card {
  position: relative;
  background: linear-gradient(168deg, var(--card-2), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  overflow: hidden;
}
.card.hoverable { transition: transform 0.24s var(--spring), border-color 0.24s var(--ease), box-shadow 0.24s var(--ease); }
.card.hoverable:active { transform: scale(0.985); }
@media (hover: hover) {
  .card.hoverable:hover {
    border-color: var(--line-2);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
    transform: translateY(-2px);
  }
}
.card.flat { background: var(--card); }

/* ---------- dugmad ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 20px;
  border-radius: 14px;
  font-weight: 650;
  font-size: 14.5px;
  letter-spacing: -0.01em;
  transition: transform 0.18s var(--spring), background 0.2s, opacity 0.2s, box-shadow 0.2s;
  will-change: transform;
}
.btn svg { width: 18px; height: 18px; stroke-width: 2; }
.btn:active { transform: scale(0.965); }
.btn.primary {
  background: linear-gradient(160deg, var(--accent), #b9ef49);
  color: var(--accent-ink);
  box-shadow: 0 10px 26px rgba(201, 247, 92, 0.20);
}
.btn.primary:disabled { opacity: 0.45; box-shadow: none; }
.btn.ghost {
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  color: var(--fg);
}
.btn.ghost:active { background: rgba(255, 255, 255, 0.08); }
.btn.danger { background: rgba(255, 115, 115, 0.12); color: var(--danger); border: 1px solid rgba(255, 115, 115, 0.28); }
.btn.block { width: 100%; }
.btn.sm { height: 36px; padding: 0 13px; font-size: 13px; border-radius: 11px; }
.btn.icon { width: 44px; padding: 0; }

/* ---------- chipovi ---------- */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 16px 2px;
  margin: 0 -16px 14px;
  scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .chips { margin: 0 0 14px; padding: 2px 0; } }

.chip {
  flex: 0 0 auto;
  height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-radius: 100px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: all 0.2s var(--ease);
}
.chip:active { transform: scale(0.95); }
.chip.active {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(201, 247, 92, 0.22);
}
.chip .n { font-size: 11px; opacity: 0.6; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
  text-transform: capitalize;
}
.tag.accent { background: rgba(201, 247, 92, 0.14); color: var(--accent); }

/* ---------- input ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field label { font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: 0.02em; }
.input, .select {
  height: 46px;
  width: 100%;
  padding: 0 14px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 15px;
  transition: border-color 0.2s, background 0.2s;
}
.input:focus, .select:focus {
  outline: none;
  border-color: rgba(201, 247, 92, 0.5);
  background: rgba(201, 247, 92, 0.05);
}
.input::placeholder { color: var(--dim); }

.searchwrap { position: relative; margin-bottom: 12px; }
.searchwrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; stroke-width: 2; color: var(--dim);
  pointer-events: none;
}
.searchwrap .input { padding-left: 42px; }

/* ---------- stat plocica ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.stat .k { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); }
.stat .v { font-size: 21px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 3px; letter-spacing: 0; }

/* ---------- prsten (kcal) ---------- */
.ring { position: relative; display: grid; place-items: center; }
.ring svg { transform: rotate(-90deg); overflow: visible; }
.ring .track { stroke: rgba(255, 255, 255, 0.07); }
.ring .bar {
  stroke: url(#ringGrad);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.1s var(--ease);
  filter: drop-shadow(0 0 12px rgba(201, 247, 92, 0.35));
}
.ring .center {
  position: absolute;
  text-align: center;
  display: flex; flex-direction: column; gap: 1px;
}
.ring .center .big {
  font-size: 32px; font-weight: 740; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.ring .center .cap { font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }

/* ---------- lista redova ---------- */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--line);
  width: 100%;
  text-align: left;
  transition: background 0.18s, transform 0.18s var(--spring), border-color 0.18s;
}
.row:active { transform: scale(0.99); background: rgba(255, 255, 255, 0.06); }
@media (hover: hover) { .row:hover { border-color: var(--line-2); background: rgba(255, 255, 255, 0.05); } }
.row .thumb {
  width: 48px; height: 48px; flex: 0 0 48px;
  border-radius: 12px;
  object-fit: cover;
  background: #0e100f;
  border: 1px solid var(--line);
}
.row .main { flex: 1; min-width: 0; }
.row .name { font-size: 14.5px; font-weight: 640; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row .arrow { color: var(--dim); flex: 0 0 auto; }
.row .arrow svg { width: 18px; height: 18px; stroke-width: 2; }

/* ---------- segmented ---------- */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}
.seg button {
  height: 30px; padding: 0 13px;
  border-radius: 9px;
  font-size: 12.5px; font-weight: 650;
  color: var(--muted);
  transition: all 0.2s var(--ease);
}
.seg button.active { background: var(--card-3); color: var(--fg); box-shadow: 0 2px 8px rgba(0,0,0,.3); }

/* ---------- sheet (bottom sheet / modal) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
  z-index: 90;
  animation: fadeIn 0.24s var(--ease) both;
}
.sheet-backdrop.closing { animation: fadeOut 0.22s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }

.sheet {
  position: fixed;
  will-change: transform;
  overscroll-behavior: contain;
  left: 0; right: 0; bottom: 0;
  z-index: 91;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-top: 1px solid var(--line-2);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.6);
  animation: sheetUp 0.38s var(--spring) both;
  padding-bottom: var(--safe);
}
.sheet.closing { animation: sheetDown 0.26s var(--ease) both; }
@keyframes sheetUp { from { transform: translate3d(0, 100%, 0); } to { transform: none; } }
@keyframes sheetDown { to { transform: translate3d(0, 100%, 0); } }
@keyframes sheetDown { to { transform: translateY(100%); } }

.sheet .grip {
  width: 40px; height: 4px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.2);
  margin: 9px auto 0;
  flex: 0 0 auto;
}
.sheet .sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 18px 10px;
  flex: 0 0 auto;
}
.sheet .sheet-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.sheet .sheet-body {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 18px 20px;
  -webkit-overflow-scrolling: touch;
}
.xbtn {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  transition: background 0.2s, transform 0.2s var(--spring);
}
.xbtn:active { transform: scale(0.9); }
.xbtn svg { width: 17px; height: 17px; stroke-width: 2.1; }

@media (min-width: 760px) {
  .sheet {
    left: 50%; right: auto;
    bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: min(620px, 92vw);
    max-height: 88dvh;
    border-radius: 24px;
    border: 1px solid var(--line-2);
    animation: modalIn 0.34s var(--spring) both;
  }
  .sheet.closing { animation: modalOut 0.2s var(--ease) both; }
  @keyframes modalIn { from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } }
  @keyframes modalOut { to { opacity: 0; transform: translate(-50%, -48%) scale(0.97); } }
  .sheet .grip { display: none; }
  .sheet .sheet-head { padding-top: 16px; }
}

/* scroll lock dok je sheet otvoren (bez skoka na iOS-u) */
html.sheet-open, html.sheet-open body { overflow: hidden; }
html.sheet-open body { position: fixed; left: 0; right: 0; width: 100%; }

/* ---------- toast ---------- */
#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe) + 16px);
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
@media (min-width: 900px) { #toast-root { bottom: 28px; } }
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 16px;
  border-radius: 13px;
  background: rgba(24, 29, 26, 0.96);
  border: 1px solid var(--line-2);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  font-size: 13.5px;
  font-weight: 600;
  animation: toastIn 0.34s var(--spring) both;
}
.toast.out { animation: toastOut 0.24s var(--ease) both; }
.toast.err { border-color: rgba(255, 115, 115, 0.4); color: #ffd9d9; }
.toast.ok { border-color: rgba(201, 247, 92, 0.35); }
.toast svg { width: 16px; height: 16px; stroke-width: 2.2; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(0.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(0.97); } }

/* ---------- skeleton ---------- */
.skel {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--r-md);
}
.skel::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.07), transparent);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- segmented stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
.stepper button {
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--fg);
  transition: transform 0.15s var(--spring), background 0.15s;
}
.stepper button:active { transform: scale(0.9); background: rgba(201, 247, 92, 0.16); }
.stepper button svg { width: 18px; height: 18px; stroke-width: 2.4; }
.stepper .mid { text-align: center; flex: 1; }
.stepper .mid .lab { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.stepper .mid .val { font-size: 26px; font-weight: 730; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stepper .mid .val small { font-size: 12px; color: var(--muted); font-weight: 600; margin-left: 3px; letter-spacing: 0; }

/* ---------- muscle map ---------- */
.musclemap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.musclemap svg { width: 100%; height: auto; display: block; }
.musclemap poly { transition: fill 0.4s var(--ease); }
.musclemap .cap {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  padding-bottom: 2px;
}

/* ---------- bar chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 118px; padding-top: 6px; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 5px; }
.bars .col .b {
  width: 100%;
  min-height: 3px;
  border-radius: 5px 5px 3px 3px;
  background: linear-gradient(180deg, var(--accent), rgba(201, 247, 92, 0.28));
  transform-origin: bottom;
  animation: growY 0.62s var(--spring) both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.bars .col .b.zero { background: rgba(255, 255, 255, 0.07); }
.bars .col .lb { font-size: 9px; text-align: center; color: var(--dim); font-weight: 600; }
@keyframes growY { from { transform: scaleY(0.02); opacity: 0.2; } }
