/* Terrateana — base: tokeni, reset, layout, navigacija, tranzicije */

:root {
  --bg: #08090a;
  --bg-2: #0c0e0d;
  --card: #121513;
  --card-2: #171b18;
  --card-3: #1d2220;
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.14);
  --fg: #f2f5f1;
  --muted: #8f9992;
  --dim: #616b64;
  --accent: #c9f75c;
  --accent-2: #6fe3a1;
  --accent-ink: #0b1005;
  --danger: #ff7373;
  --warn: #ffc45c;
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 12px;
  --tab-h: 62px;
  --safe: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  overscroll-behavior-y: none;
}

/* suptilni ambijentalni gradijent */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(680px 420px at 12% -8%, rgba(201, 247, 92, 0.10), transparent 62%),
    radial-gradient(560px 380px at 96% 6%, rgba(111, 227, 161, 0.07), transparent 60%);
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

.view {
  padding: 14px 16px calc(var(--tab-h) + var(--safe) + 26px);
  max-width: 1180px;
  margin: 0 auto;
  /* bez animacije na svaki render — pokrete vodi View Transition ispod */
}

/* samo prvi paint pri otvaranju appa */
.view.boot { animation: viewIn 0.36s var(--ease) both; }

@keyframes viewIn {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: none; }
}

/* ---------- bottom tabbar (mobile) ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe));
  padding-bottom: var(--safe);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  background: rgba(10, 12, 11, 0.82);
  backdrop-filter: blur(22px) saturate(160%);
  border-top: 1px solid var(--line);
  z-index: 40;
}

.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--dim);
  transition: color 0.2s var(--ease), transform 0.25s var(--spring);
  padding-top: 8px;
}
.tabbar a svg { width: 22px; height: 22px; stroke-width: 1.7; }
.tabbar a.active { color: var(--accent); }
.tabbar a:active { transform: scale(0.92); }
.tabbar a.active svg { filter: drop-shadow(0 0 10px rgba(201, 247, 92, 0.45)); }

/* ---------- sidebar (desktop) ---------- */
.sidenav { display: none; }

@media (min-width: 900px) {
  .tabbar { display: none; }

  .sidenav {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: 92px;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 22px 0;
    background: rgba(9, 11, 10, 0.7);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(16px);
    z-index: 40;
  }
  .sidenav .brand {
    width: 40px; height: 40px;
    display: grid; place-items: center;
    border-radius: 13px;
    background: linear-gradient(150deg, var(--accent), var(--accent-2));
    color: var(--accent-ink);
    margin-bottom: 18px;
    box-shadow: 0 8px 24px rgba(201, 247, 92, 0.22);
  }
  .sidenav .brand svg { width: 22px; height: 22px; stroke-width: 2.2; }
  .sidenav a {
    width: 60px; height: 58px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 5px;
    border-radius: 16px;
    color: var(--dim);
    font-size: 10px;
    font-weight: 600;
    transition: all 0.22s var(--ease);
  }
  .sidenav a svg { width: 21px; height: 21px; stroke-width: 1.7; }
  .sidenav a:hover { color: var(--fg); background: rgba(255, 255, 255, 0.035); }
  .sidenav a.active {
    color: var(--accent);
    background: rgba(201, 247, 92, 0.09);
    box-shadow: inset 0 0 0 1px rgba(201, 247, 92, 0.16);
  }

  .view {
    margin-left: 92px;
    max-width: 1120px;
    padding: 26px 34px 60px;
  }
}

/* ---------- page header ---------- */
.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 6px 0 18px;
}
.pagehead h1 {
  font-size: 27px;
  font-weight: 720;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.pagehead .sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 5px;
  font-weight: 500;
}
@media (min-width: 900px) {
  .pagehead h1 { font-size: 34px; }
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 26px 2px 11px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
}
.section-title a { color: var(--accent); letter-spacing: 0.02em; text-transform: none; font-size: 12.5px; }

/* ---------- view transitions (samo sadrzaj, nav ostaje miran) ---------- */
#view { view-transition-name: content; }

/* root se NE animira: inace se tabbar/sidebar svaki put preslikaju i "skaču" */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(content) {
    animation: 120ms cubic-bezier(0.4, 0, 1, 1) both vtOut;
    transform-origin: 50% 0;
  }
  ::view-transition-new(content) {
    animation: 300ms cubic-bezier(0.22, 1, 0.36, 1) both vtIn;
    transform-origin: 50% 0;
  }
}
@keyframes vtOut {
  to { opacity: 0; }
}
@keyframes vtIn {
  from { opacity: 0; transform: translate3d(0, 12px, 0); }
}

/* stagger ulaz kartica — kratko, kasnjenje ograniceno da ne "kaska" */
.stagger > * {
  animation: rise 0.34s var(--spring) both;
  animation-delay: calc(min(var(--i, 0), 8) * 18ms);
}
/* ne animiraj desetine kartica odjednom — mobilni GPU to osjeti */
.stagger > *:nth-child(n + 11) { animation: none; }
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 10px, 0); }
  to { opacity: 1; transform: none; }
}

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

.errorbox {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 115, 115, 0.35);
  background: rgba(255, 115, 115, 0.08);
  color: #ffd9d9;
  font-size: 13.5px;
  line-height: 1.45;
}
.errorbox b { color: var(--danger); }
