/* ==========================================================================
   Nulti bit – landing
   ========================================================================== */

:root {
  --bg: #0E0F10;
  --bg-alt: #121415;
  --surface: #17191B;
  --surface-hover: #1D2022;
  --border: #26292C;
  --text: #E8E9EA;
  --muted: #9A9C9F;
  --accent: #B7E200;
  --accent-soft: rgba(183, 226, 0, 0.12);
  --accent-ink: #0E0F10;
  --brand-gray: #58595B;

  --radius: 14px;
  --radius-sm: 8px;
  --container: 1120px;
  --gutter: 16px;
  --header-h: 68px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 8px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

a { color: inherit; text-decoration: none; }

h1, h2, h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 700;
}

p { margin: 0; }

::selection { background: var(--accent); color: var(--accent-ink); }

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

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

@media (min-width: 768px) {
  :root { --gutter: 32px; }
}

.mono { font-family: var(--mono); }
.accent { color: var(--accent); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px; top: -100px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.975rem;
  transition: background-color .2s, color .2s, border-color .2s, transform .2s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: #C8F01A; }

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(14, 15, 16, 0.8);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.site-header.scrolled { border-bottom-color: var(--border); }

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand img { height: 26px; width: auto; }

.nav {
  display: flex;
  gap: 28px;
  font-size: 0.95rem;
  font-weight: 500;
}
.nav a {
  color: var(--muted);
  transition: color .2s;
}
.nav a:hover { color: var(--text); }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.lang-switch button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
.lang-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

.nav-toggle {
  display: none;
  position: relative;
  width: 44px; height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.nav-toggle .bar {
  position: absolute;
  left: 13px; right: 13px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .25s, top .25s;
}
.nav-toggle .bar:nth-of-type(2) { top: 17px; }
.nav-toggle .bar:nth-of-type(3) { top: 25px; }
.nav-toggle[aria-expanded="true"] .bar:nth-of-type(2) { top: 21px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .bar:nth-of-type(3) { top: 21px; transform: rotate(-45deg); }

@media (max-width: 767px) {
  .nav-toggle { display: block; }
  .brand img { height: 22px; }

  .nav {
    position: fixed;
    top: var(--header-h);
    left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    padding: 8px var(--gutter) 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s, transform .2s, visibility .2s;
  }
  .nav.open {
    opacity: 1;
    transform: none;
    visibility: visible;
  }
  .nav a {
    padding: 14px 0;
    font-size: 1.1rem;
    color: var(--text);
    border-bottom: 1px solid var(--border);
  }
  .nav a:last-child { border-bottom: 0; }
}

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 72px 0 88px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 400px at 85% 30%, rgba(183, 226, 0, 0.09), transparent 70%),
    linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse at 70% 40%, #000 0%, transparent 75%);
          mask-image: radial-gradient(ellipse at 70% 40%, #000 0%, transparent 75%);
  opacity: 0.7;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  display: grid;
  gap: 48px;
  align-items: center;
}

.hero h1 {
  font-size: clamp(2.3rem, 6.5vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.035em;
  max-width: 14ch;
  text-wrap: balance;
}

.lead {
  margin-top: 22px;
  max-width: 54ch;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.6vw, 1.15rem);
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 34px;
}

.hero-mark {
  display: none;
  justify-self: center;
}
.hero-mark .mark {
  width: clamp(200px, 26vw, 300px);
  height: auto;
  overflow: visible;
}

/* Animirani znak: ćelije mreže se upale redom, a nulti bit zadnji doskoči i zasvijetli */
.mark-cell { fill: #555657; }
.mark-bit {
  fill: var(--accent);
  filter: drop-shadow(0 0 0 rgba(183, 226, 0, 0));
}
.mark-cell,
.mark-bit { transform-box: fill-box; transform-origin: center; }

.mark.play .mark-cell { animation: cell-in .45s cubic-bezier(.2, .8, .2, 1) calc(var(--i) * 70ms) both; }
.mark.play .mark-bit {
  animation:
    bit-in .7s cubic-bezier(.3, 1.6, .5, 1) .7s both,
    bit-glow 4s ease-in-out 1.6s infinite;
}

@keyframes cell-in {
  from { opacity: 0; transform: scale(.4); }
  to   { opacity: 1; transform: none; }
}
@keyframes bit-in {
  0%   { opacity: 0; transform: scale(.2); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes bit-glow {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(183, 226, 0, 0)); }
  50%      { filter: drop-shadow(0 0 14px rgba(183, 226, 0, 0.45)); }
}

@media (min-width: 900px) {
  .hero { padding: 112px 0 128px; }
  .hero-inner { grid-template-columns: 1.4fr 1fr; }
  .hero-mark { display: block; }
}

/* --------------------------------------------------------------------------
   Sections
   -------------------------------------------------------------------------- */
.section { padding: 80px 0; }
.section-alt {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
  .section { padding: 112px 0; }
}

.section-head { margin-bottom: 44px; max-width: 640px; }

.section-label {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: lowercase;
}
.section-label .slash { color: var(--accent); font-weight: 500; }

.section-head h2 { font-size: clamp(1.8rem, 4vw, 2.6rem); }

.section-intro {
  margin-top: 14px;
  color: var(--muted);
  font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.cards { display: grid; gap: 16px; }

@media (min-width: 640px) {
  .cards-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .cards-4 { grid-template-columns: repeat(4, 1fr); }
  .cards-4 .card { padding: 24px 22px; }
}
@media (min-width: 768px) {
  .cards-4 { gap: 20px; }
  .cards-projects { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}

.card {
  position: relative;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .25s, background-color .25s, transform .25s;
}
.card:hover {
  border-color: rgba(183, 226, 0, 0.4);
  background: var(--surface-hover);
}

.card h3 { font-size: 1.18rem; margin-bottom: 10px; }
.card p { color: var(--muted); font-size: 0.97rem; }

.card-icon {
  display: grid;
  place-items: center;
  width: 48px; height: 48px;
  margin-bottom: 22px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.card-icon svg { width: 24px; height: 24px; }

/* Projects */
.project {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.project-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, #1B1E20 0%, #141617 100%);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.project-media img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform .5s ease;
}
.project:hover .project-media img { transform: scale(1.03); }
.project-media .placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  font-family: var(--mono);
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--brand-gray);
  letter-spacing: 0.08em;
}
.project-media .placeholder b { color: var(--accent); font-weight: 500; }

.project-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 12px;
  padding: 24px 26px 26px;
}

.project-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.project-top h3 { margin: 0; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.status.is-active { color: var(--accent); border-color: rgba(183, 226, 0, 0.35); }
.status.is-active::before { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.status.is-dev { border-color: rgba(183, 226, 0, 0.35); }
.status.is-dev::before { background: var(--accent); animation: status-pulse 1.6s ease-in-out infinite; }
@keyframes status-pulse { 50% { opacity: 0.25; } }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: auto 0 0;
  padding: 6px 0 0;
  list-style: none;
}
.tags li {
  padding: 3px 9px;
  border-radius: 6px;
  background: #212426;
  color: #C5C7C9;
  font-family: var(--mono);
  font-size: 0.74rem;
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.93rem;
}
.project-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* --------------------------------------------------------------------------
   About
   -------------------------------------------------------------------------- */
.about { display: grid; gap: 8px; }
.about .section-head { margin-bottom: 20px; }

.about-body {
  display: grid;
  gap: 16px;
  max-width: 68ch;
  color: var(--muted);
  font-size: 1.06rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 40px 0 0;
}
.stat {
  padding: 22px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
}
.stat dd {
  order: -1;
  margin: 0 0 4px;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.stat { display: flex; flex-direction: column; }
.stat-stack dd { white-space: nowrap; }
.stat dd .slash { color: var(--accent); font-weight: 500; margin: 0 0.12em; }

@media (min-width: 900px) {
  .about {
    grid-template-columns: minmax(200px, 0.8fr) 2.2fr;
    column-gap: 64px;
    align-items: start;
  }
  .about .section-head { grid-row: span 2; }
  .stats { margin-top: 24px; }
}

/* na uskim ekranima API/IoT/AI ne stane u trećinu reda: ide u svoj red ispod */
@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat-stack { grid-column: 1 / -1; order: 1; }
}

@media (max-width: 420px) {
  .stat { padding: 18px 12px; }
}

/* --------------------------------------------------------------------------
   Contact
   -------------------------------------------------------------------------- */
.contact-grid {
  display: grid;
  gap: 16px;
}
@media (min-width: 768px) {
  .contact-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .25s, background-color .25s;
}
.contact-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.contact-icon {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}
.contact-icon svg { width: 22px; height: 22px; }

.contact-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
}
.contact-value {
  font-size: 1.12rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
  padding: 36px 0;
  border-top: 1px solid var(--border);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-logo { height: 20px; width: auto; opacity: 0.85; }
.footer-meta {
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-meta a:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Reveal animation
   -------------------------------------------------------------------------- */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .6s ease, transform .6s ease;
}
.js .reveal.visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .status.is-dev::before { animation: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  /* bez kretanja: samo blago pojavljivanje i sjaj */
  .mark.play .mark-cell { animation: fade-in .6s ease both !important; }
  .mark.play .mark-bit {
    animation:
      fade-in .6s ease .4s both,
      bit-glow 4s ease-in-out 1.2s infinite !important;
  }
  * { transition-duration: 0s !important; }
}
