/* inteligencija.hr · legal pages (privatnost.html, kolacici.html)
   Generic long-form reading layer on top of styles.css (tokens, header, footer, chat, cookie).
   Structure:
     .legal-hero > .legal-grid > .legal-companion (3D Albert + thought bubble) + .legal-hero-copy (h1, p)
     .legal-body > .legal-grid.legal-layout > aside.legal-aside[data-legal-toc] + article.legal
   legal.js builds the table of contents from article h2[id] and highlights the current section. */

:root {
  --legal-toc-w: 15.5rem;
  --legal-gap: clamp(40px, 6vw, 104px);
  --legal-measure: 68ch;
  --legal-sticky-top: calc(var(--header-h) + 40px);
}

/* Shared grid: TOC column + reading column, centred as one block so hero and body align. */
.legal-grid {
  font-size: 18px; /* makes 68ch in the grid template equal 68ch of the article text */
  display: grid;
  grid-template-columns: var(--legal-toc-w) minmax(0, var(--legal-measure));
  column-gap: var(--legal-gap);
  justify-content: center;
}

/* ---------------- Hero ---------------- */
.legal-hero {
  position: relative; overflow: hidden;
  padding: calc(var(--header-h) + 12px + clamp(48px, 9vh, 96px)) 0 clamp(40px, 6vh, 64px);
}
.legal-hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(38% 70% at 12% 100%, rgba(168, 200, 232, .5), transparent 72%),
    radial-gradient(40% 50% at 4% 0%, rgba(216, 231, 246, .9), transparent 70%),
    radial-gradient(36% 46% at 92% 18%, rgba(234, 242, 251, 1), transparent 70%);
}
.legal-hero .legal-grid { position: relative; align-items: end; }
.legal-hero-copy { padding-bottom: 6px; }
.legal-hero h1 {
  font-size: clamp(2.6rem, 5.4vw, 4.6rem); line-height: 1.02; letter-spacing: -0.02em; font-weight: 600;
  color: var(--navy);
}
.legal-hero h1 + p {
  margin-top: clamp(18px, 2.4vh, 26px);
  font-size: clamp(1.08rem, 1.35vw, 1.25rem); line-height: 1.6; color: var(--muted); max-width: 52ch;
}

/* Albert, reading along: a small 3D companion above the TOC column, never over text. */
.legal-companion { position: relative; justify-self: center; width: 200px; height: 236px; }
.legal-companion::before { /* the soft disc he stands on (same language as the homepage stage) */
  content: ""; position: absolute; left: 50%; bottom: -34px; width: 230px; height: 84px; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 255, 255, .95), rgba(234, 242, 251, .7) 60%, rgba(216, 231, 246, 0));
}
.legal-albert { position: absolute; inset: 0; }
.legal-albert-svg { width: auto; height: 100%; margin: 0 auto; aspect-ratio: 300 / 360; }
.legal-thought { /* thought bubble with the page's subject icon */
  position: absolute; right: -12px; top: 2px; z-index: 1;
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--white); border: 1px solid var(--line); color: var(--blue-dk); font-size: 26px;
  box-shadow: var(--shadow-soft);
}
.legal-thought::before, .legal-thought::after {
  content: ""; position: absolute; border-radius: 50%; background: var(--white); border: 1px solid var(--line);
}
.legal-thought::before { width: 14px; height: 14px; left: -4px; bottom: -10px; }
.legal-thought::after { width: 8px; height: 8px; left: -14px; bottom: -20px; }

@media (prefers-reduced-motion: no-preference) {
  .legal-hero-copy > * { animation: legalRise .9s var(--ease-out) both; }
  .legal-hero-copy > :nth-child(2) { animation-delay: .08s; }
  .legal-thought { animation: legalFloat 5s ease-in-out 1s infinite; }
}
@keyframes legalRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes legalFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* ---------------- Body ---------------- */
.legal-body {
  position: relative; background: var(--white); border-top: 1px solid var(--line);
  padding: clamp(48px, 8vh, 88px) 0 clamp(80px, 12vh, 140px);
}
.legal-layout { align-items: start; }

/* ---------------- Article typography ---------------- */
.legal { min-width: 0; max-width: var(--legal-measure); font-size: 18px; line-height: 1.72; color: var(--navy); }
.legal > * + * { margin-top: 1.05em; }
.legal p { hyphens: manual; overflow-wrap: break-word; }
.legal h2 {
  margin-top: 2.6em; font-size: clamp(1.5rem, 2.1vw, 1.95rem); line-height: 1.15; letter-spacing: -0.01em; font-weight: 600;
  scroll-margin-top: calc(var(--header-h) + 40px);
}
.legal h2 + * { margin-top: .75em; }
.legal > h2:first-child { margin-top: 0; }
.legal h3 { margin-top: 2em; font-size: 1.2rem; letter-spacing: -0.02em; scroll-margin-top: calc(var(--header-h) + 40px); }
.legal h2:focus { outline: none; }
.legal h2:focus-visible { outline: 3px solid var(--blue); outline-offset: 6px; }
.legal strong { font-weight: 700; color: var(--midnight); }
.legal em { font-style: italic; }
.legal a {
  color: var(--blue-dk); font-weight: 500; text-decoration: underline; text-decoration-color: var(--sky);
  text-decoration-thickness: 1.5px; text-underline-offset: 4px; overflow-wrap: anywhere;
  transition: text-decoration-color .2s ease, color .2s ease;
}
.legal a:hover { color: var(--steel); text-decoration-color: var(--blue); }

.legal ul, .legal ol { padding: 0; list-style: none; }
.legal ul > li { position: relative; padding-left: 1.6em; }
.legal ul > li + li { margin-top: .8em; }
.legal ul > li::before {
  content: ""; position: absolute; left: .35em; top: .7em; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue); box-shadow: 0 0 0 4px var(--tint);
}
.legal ol { counter-reset: legal-ol; }
.legal ol > li { position: relative; padding-left: 2em; counter-increment: legal-ol; }
.legal ol > li + li { margin-top: .8em; }
.legal ol > li::before { content: counter(legal-ol) "."; position: absolute; left: 0; font-weight: 700; color: var(--blue-dk); font-variant-numeric: tabular-nums; }

/* Highlighted block (controller details, "Ukratko") */
.legal-card {
  margin-top: 1.6em; margin-bottom: 1.6em; padding: clamp(22px, 3vw, 34px) clamp(22px, 3vw, 36px);
  border-radius: var(--r-card); border: 1px solid var(--line);
  background: radial-gradient(80% 120% at 100% 0%, rgba(216, 231, 246, .8), transparent 60%), linear-gradient(160deg, var(--tint), var(--white) 78%);
  font-size: 17px; line-height: 1.75;
}
.legal-card + * { margin-top: 0; }

/* Rights: one row each, a calm check mark instead of a heavy card per item */
.legal-right { position: relative; padding: 16px 0 16px 2.1em; border-top: 1px solid var(--line); }
.legal-right + .legal-right { margin-top: 0; }
.legal-right:not(:has(+ .legal-right)) { border-bottom: 1px solid var(--line); }
.legal-right > .ph { position: absolute; left: 0; top: 19px; font-size: 1.15em; color: var(--blue-dk); }

/* Last update stamp */
.legal-meta {
  margin-top: 3.2em !important; padding-top: 22px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px;
}
.legal-meta .ph { font-size: 18px; color: var(--blue-dk); }

/* Wide tables (none today; legal.js wraps any future table so it scrolls on its own) */
.legal-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 18px; }
.legal-table-wrap:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.legal table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 15px; line-height: 1.5; font-variant-numeric: tabular-nums; }
.legal th, .legal td { padding: 12px 16px; text-align: left; vertical-align: top; }
.legal thead th { background: var(--tint); font-weight: 700; color: var(--midnight); }
.legal tbody tr + tr td { border-top: 1px solid var(--line); }

/* ---------------- Table of contents (built by legal.js) ---------------- */
.legal-aside { position: sticky; top: var(--legal-sticky-top); max-height: calc(100vh - var(--legal-sticky-top) - 24px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 4px 4px 4px 0; }
.toc { font-size: 14.5px; line-height: 1.4; }
.toc ol { position: relative; list-style: none; margin: 0; padding: 0 0 0 18px; }
.toc ol::before { content: ""; position: absolute; left: 3px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.toc li + li { margin-top: 2px; }
.toc a {
  display: block; padding: 6px 10px; margin-left: -10px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 500;
  transition: color .25s ease, background-color .25s ease;
}
.toc a:hover { color: var(--navy); background: var(--tint); }
.toc a[aria-current="true"] { color: var(--navy); font-weight: 650; }
.toc-dot { /* slides to the active entry (one authored motion on the page) */
  position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue-dk); box-shadow: 0 0 0 4px var(--white), 0 0 0 5px var(--sky);
  opacity: 0; transform: translateY(var(--toc-y, 0px));
  transition: transform .55s var(--ease-out), opacity .3s ease;
}
.toc.has-active .toc-dot { opacity: 1; }

/* Compact TOC for narrow screens: a sticky select showing the current section */
.toc-mobile { display: none; }

@media (max-width: 999.98px) {
  .legal-grid { grid-template-columns: minmax(0, var(--legal-measure)); }
  .legal-hero .legal-grid { grid-template-columns: minmax(0, var(--legal-measure)) 150px; column-gap: 24px; justify-content: center; }
  .legal-hero .legal-companion { grid-column: 2; grid-row: 1; width: 150px; height: 178px; }
  .legal-hero .legal-companion::before { width: 170px; height: 64px; bottom: -26px; }
  .legal-hero .legal-hero-copy { grid-column: 1; grid-row: 1; }
  .legal-aside { display: none; }
  .legal-layout { display: block; max-width: calc(var(--legal-measure) + 0px); margin: 0 auto; }
  .toc-mobile {
    display: block; position: sticky; top: calc(var(--header-h) + 22px); z-index: 5;
    margin: 0 0 clamp(28px, 5vh, 44px);
  }
  .toc-mobile-field {
    position: relative; display: flex; align-items: center;
    border-radius: 999px; border: 1px solid var(--line);
    background: rgba(255, 255, 255, .94); -webkit-backdrop-filter: blur(14px) saturate(150%); backdrop-filter: blur(14px) saturate(150%);
    box-shadow: var(--shadow-soft);
  }
  .toc-mobile-field > .ph { position: absolute; pointer-events: none; color: var(--blue-dk); font-size: 18px; }
  .toc-mobile-field > .ph-list-bullets { left: 16px; }
  .toc-mobile-field > .ph-caret-down { right: 16px; color: var(--muted); font-size: 15px; }
  .toc-mobile select {
    -webkit-appearance: none; appearance: none; width: 100%; min-width: 0; height: 48px; padding: 0 44px 0 44px;
    border: 0; border-radius: 999px; background: transparent; color: var(--navy);
    font: inherit; font-family: var(--f-body); font-size: 15px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
  }
  .toc-mobile select:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
}

@media (max-width: 899.98px) {
  .legal-hero { padding-top: calc(58px + 8px + 40px); }
  .toc-mobile { top: calc(58px + 18px); }
}

@media (max-width: 640px) {
  .legal-grid { font-size: 17px; }
  .legal-hero .legal-grid { grid-template-columns: minmax(0, 1fr) 96px; column-gap: 12px; }
  .legal-hero .legal-hero-copy { display: contents; }
  .legal-hero h1 { grid-column: 1; grid-row: 1; align-self: end; font-size: clamp(2.2rem, 10vw, 2.9rem); }
  .legal-hero h1 + p { grid-column: 1 / -1; grid-row: 2; }
  .legal-hero .legal-companion { grid-column: 2; grid-row: 1; align-self: end; width: 96px; height: 114px; }
  .legal-hero .legal-companion::before { width: 110px; height: 40px; bottom: -16px; }
  .legal-thought { width: 36px; height: 36px; font-size: 18px; right: -6px; top: -8px; }
  .legal-thought::before { width: 10px; height: 10px; left: -3px; bottom: -7px; }
  .legal-thought::after { width: 6px; height: 6px; left: -10px; bottom: -14px; }
  .legal { font-size: 17px; line-height: 1.7; }
  .legal h2 { margin-top: 2.2em; font-size: 1.45rem; }
  .legal-card { font-size: 16px; border-radius: 22px; }
  .legal-meta { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .toc-dot { transition: none; }
}

/* ---------------- Print: just the document ---------------- */
@media print {
  @page { margin: 18mm 16mm; }
  html, body { background: #fff !important; color: #000; }
  body { font-size: 11pt; }
  .site-header, .top-sentinel, .skip-link, .legal-companion, .legal-aside, .toc-mobile,
  .cookie-banner, .albert-launcher, .albert-chat, .footer-nav, .footer-legal, .footer-brand .brand-albert { display: none !important; }
  .legal-hero { padding: 0 0 12pt; overflow: visible; }
  .legal-hero::before { display: none; }
  .legal-grid, .legal-hero .legal-grid { display: block; font-size: 11pt; }
  .legal-hero h1 { font-size: 26pt; color: #000; }
  .legal-hero h1 + p { color: #222; font-size: 12pt; max-width: none; }
  .legal-hero-copy > * { animation: none !important; }
  .legal-body { border: 0; padding: 0; background: #fff; }
  .legal { max-width: none; font-size: 11pt; line-height: 1.55; color: #000; }
  .legal h2 { font-size: 15pt; margin-top: 18pt; break-after: avoid; page-break-after: avoid; }
  .legal p, .legal li { orphans: 3; widows: 3; }
  .legal strong { color: #000; }
  .legal a { color: #000; text-decoration: underline; }
  .legal a[data-print-url]::after { content: " (" attr(data-print-url) ")"; font-size: 9pt; color: #444; }
  .legal-card { background: none; border: 1px solid #999; border-radius: 6pt; break-inside: avoid; font-size: 11pt; }
  .legal-right { break-inside: avoid; border-color: #ccc; }
  .legal-right > .ph, .legal-meta .ph { color: #000; }
  .legal-meta { color: #333; border-color: #ccc; }
  .legal-table-wrap { overflow: visible; border-color: #999; }
  .legal table { min-width: 0; }
  .site-footer { border-top: 1px solid #ccc; padding: 10pt 0 0; background: #fff; }
  .footer-bottom { margin-top: 0; border: 0; padding-top: 0; color: #333; }
}

/* the flat 2D Albert waits for the 3D one; it fades in only if 3D is not ready after 2.5 s */
.legal-albert-svg { transition: opacity .35s ease; }
.js:not(.fallback-due) .legal-albert-svg { visibility: hidden; opacity: 0; }
@media (prefers-reduced-motion: reduce) { .js:not(.fallback-due) .legal-albert-svg { visibility: visible; opacity: 1; } }
