/* Nüans Teknoloji — motion engine: opening, first-block entrance, scroll reveals, page transitions.
   Loaded before site.css, which sets the tokens and may restyle every piece.

   Classes on <html> (set by erken.js before the first paint, some by site.js):
     js      JavaScript runs: scroll reveals may hide content until it is revealed
     acilis  first page of the browser session: the opening overlay plays
     sahne   the opening reached its hand-over: the header and the first block reveal
     kondu   the overlay mark has landed on the header logo
     giris   ordinary page load: the first block plays its entrance at once
     vt      the page arrived through a cross-document view transition (no entrance)
             (giris and vt are removed when the entrance is over: key animations to them, with
             fill "backwards", never a lasting state)
     cikis   exit fade for browsers without cross-document view transitions
     kaydi   the page is scrolled (the header condenses)
     sakin   site.js started after the safety net of erken.js: the page stays the static page

   Hooks in the markup:
     data-sahne="1..9"   item of the first block; reveals in this order (opening and ordinary load)
     data-satirlar       heading whose lines rise one by one (opening and scroll reveal; needs JS)
     data-acilis-gizle   header item that fades in at the hand-over of the opening
     .gor                reveals once when it scrolls into view: .gorundu is added, and .gor-bitti
                         when the reveal is over (from then on the engine styles nothing on it)
       .gor-ciz          ... as a line that draws from the left
       .gor-soluk        ... fading only
     data-gecis-kart / data-gecis-ad / data-gecis-baslik   title morph between a card and its page
     .ust (header), main, .alt (footer, id="alt")   elements the engine relies on */

:root {
  --yay: cubic-bezier(.2, .7, .2, 1);        /* entrances */
  --yay-ciz: cubic-bezier(.65, 0, .35, 1);   /* lines that draw */
  --acilis-zemin: #fff;                      /* overlay background of the opening */
  --sahne-adim: 70ms;                        /* stagger between first-block items */
  --vt-kayma: 16px;                          /* how far a page rises in a page transition (0px: fade only) */
}

/* ---------- Inline sprite (icons + logo wordmark) and logo ---------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.logo-svg { display: block; height: auto; overflow: visible; }
.logo-svg .yazi { color: #282C44; }
.logo-beyaz .yazi { color: #fff; }

/* ---------- Opening ---------- */
.acilis-perde { display: none; }
html.acilis .acilis-perde { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.acilis-zemin { position: absolute; inset: 0; background: var(--acilis-zemin); }
.acilis-simge { position: relative; width: clamp(128px, 15vw, 208px); height: auto; overflow: visible; transform-origin: 0 0; will-change: transform; }
html.acilis .acilis-simge .h { stroke-dasharray: 1 2; stroke-dashoffset: 1; animation: nu-ciz .82s var(--yay-ciz) .14s forwards; }
html.acilis .acilis-simge .h-y { animation-delay: .26s; }
html.acilis .acilis-simge .d { transform-box: fill-box; transform-origin: center; transform: scale(0); animation: nu-dugum .42s var(--yay) forwards; }
html.acilis .acilis-simge .d-y { animation-delay: .12s; }
@keyframes nu-ciz { to { stroke-dashoffset: 0; } }
@keyframes nu-dugum { to { transform: none; } }

/* hand-over: the background fades while site.js flies the mark onto the header logo */
html.sahne .acilis-zemin { opacity: 0; transition: opacity .55s ease .05s; }
/* until the mark has landed the overlay still takes the click that skips the opening */
html.kondu .acilis-perde { pointer-events: none; }
html.kondu .acilis-simge { visibility: hidden; }
/* the real header mark stays hidden until the overlay mark has landed on it */
html.acilis:not(.kondu) .ust .logo-svg .simge { visibility: hidden; }
html.acilis .ust .logo-svg .yazi,
html.acilis [data-acilis-gizle] { opacity: 0; }
html.acilis.sahne .ust .logo-svg .yazi,
html.acilis.sahne [data-acilis-gizle] { opacity: 1; transition: opacity .6s ease .3s; }

/* ---------- Arrival: the two halves of the header mark lock into each other ("kenetlenme") ---------- */
html.vt .ust .logo-svg .y-l,
html.giris .ust .logo-svg .y-l { animation: nu-kenet-l .7s cubic-bezier(.3, 1.25, .5, 1) backwards; }
html.vt .ust .logo-svg .y-y,
html.giris .ust .logo-svg .y-y { animation: nu-kenet-y .7s cubic-bezier(.3, 1.25, .5, 1) backwards; }
@keyframes nu-kenet-l { from { transform: translateY(-30px); opacity: 0; } }
@keyframes nu-kenet-y { from { transform: translateY(30px); opacity: 0; } }

/* ---------- First block entrance ---------- */
[data-sahne="1"] { --i: 0; } [data-sahne="2"] { --i: 1; } [data-sahne="3"] { --i: 2; }
[data-sahne="4"] { --i: 3; } [data-sahne="5"] { --i: 4; } [data-sahne="6"] { --i: 5; }
[data-sahne="7"] { --i: 6; } [data-sahne="8"] { --i: 7; } [data-sahne="9"] { --i: 8; }
html.acilis:not(.sahne) [data-sahne] { opacity: 0; }
html.sahne { --sahne-gecikme: 340ms; }
html.sahne [data-sahne],
html.giris [data-sahne] { animation: nu-gir .8s var(--yay) backwards; animation-delay: calc(var(--i, 0) * var(--sahne-adim) + var(--sahne-gecikme, 0ms)); }
/* Fill "backwards": when an entrance is over nothing pins the item (its own hover and transition
   rules work). It starts at opacity .001, not 0: Chrome never repaints a composited fade, so text
   that starts at 0 is not counted as painted until the animation is removed, which put the
   largest contentful paint at the end of the opening instead of at the hand-over. */
@keyframes nu-gir { from { opacity: .001; transform: translateY(22px); } }

/* headings split into words by site.js (data-satirlar): every line rises from behind a mask */
.nu-k { display: inline-block; clip-path: inset(-.12em -.08em -.2em -.08em); pointer-events: none; }
.nu-k > span { display: inline-block; }
html.acilis:not(.sahne) .nu-bolundu .nu-k > span { transform: translateY(115%); }
html.sahne .nu-bolundu[data-sahne] { animation: none; opacity: 1; }
html.sahne .nu-bolundu .nu-k > span,
.gorundu.nu-bolundu .nu-k > span { animation: nu-kelime .9s var(--yay) both; animation-delay: calc(var(--satir, 0) * 90ms + var(--i, 0) * var(--sahne-adim) + var(--g, 0) * 70ms + var(--sahne-gecikme, 0ms)); }
@keyframes nu-kelime { from { transform: translateY(115%); } }

/* ---------- Scroll reveals ----------
   Life cycle: .gor (hidden, only under html.js) -> .gorundu (the reveal plays) -> .gor-bitti (released).
   A released element is the design's own again: no rule below matches it, so its transform,
   opacity, transitions and hover states apply as they do without JavaScript. :where() keeps the
   weight of the rules at (0,2,1) / (0,3,1): a design overrides them with html.js .x.gor { ... }. */
html.js .gor:where(:not(.gorundu)) { opacity: 0; transform: translateY(20px); }
html.js .gor.gorundu:where(:not(.gor-bitti)) { transition: opacity .7s var(--yay), transform .8s var(--yay); transition-delay: calc(var(--g, 0) * 70ms); }
html.js .gor.gor-soluk:where(:not(.gorundu)) { transform: none; }
html.js .gor.gor-ciz:where(:not(.gor-bitti)) { transform-origin: left center; }
html.js .gor.gor-ciz:where(:not(.gorundu)) { opacity: 1; transform: scaleX(0); }
html.js .gor.gor-ciz.gorundu:where(:not(.gor-bitti)) { transition: transform .9s var(--yay-ciz); transition-delay: calc(var(--g, 0) * 70ms); }
/* a heading that rises by lines (data-satirlar): the block itself is simply there */
html.js .gor.nu-bolundu { opacity: 1; transform: none; transition: none; }
html.js .gor.nu-bolundu:not(.gorundu) .nu-k > span { transform: translateY(115%); }

/* ---------- Page transitions ---------- */
@view-transition { navigation: auto; }
/* The header is its own group, but only while a transition is active: a permanent name would make
   it a backdrop root (a backdrop-filter inside it would see nothing of the page). */
:root:active-view-transition .ust { view-transition-name: nu-ust; }
::view-transition-old(root) { animation: nu-vt-cik .18s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: nu-vt-gir .42s cubic-bezier(.2, .7, .2, 1) .04s both; }
@keyframes nu-vt-cik { to { opacity: 0; transform: translateY(calc(var(--vt-kayma) * -.6)); } }
@keyframes nu-vt-gir { from { opacity: 0; transform: translateY(var(--vt-kayma)); } }
::view-transition-group(nu-baslik) { animation-duration: .42s; animation-timing-function: cubic-bezier(.2, .7, .2, 1); }
::view-transition-old(nu-baslik),
::view-transition-new(nu-baslik) { height: 100%; width: auto; object-fit: none; object-position: left top; }
::view-transition-old(nu-baslik) { animation: nu-vt-sol .15s ease-out both; }
::view-transition-new(nu-baslik) { animation: nu-vt-bel .3s ease-out .1s both; }
@keyframes nu-vt-sol { to { opacity: 0; } }
@keyframes nu-vt-bel { from { opacity: 0; } }
[data-gecis-ad], [data-gecis-baslik] { width: fit-content; }
/* browsers without cross-document view transitions: site.js fades the page out before it leaves */
html.cikis main,
html.cikis .alt { opacity: 0; transform: translateY(-8px); transition: opacity .18s ease-in, transform .18s ease-in; }

/* ---------- Late start (html.sakin): animations that a design keys to .gorundu end at once ---------- */
html.sakin .gor, html.sakin .gor *, html.sakin .gor::before, html.sakin .gor::after,
html.sakin .gor *::before, html.sakin .gor *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }

/* ---------- Reduced motion: everything is simply there ----------
   One reset for the whole page, effects that a design hangs on .gor / .gorundu / data-sahne
   included: animations and transitions end at once. site.js marks every .gor as revealed and
   released when it starts, so a hidden start state written for .gor:not(.gorundu) never shows. */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .acilis-perde { display: none !important; }
  html [data-sahne] { animation: none !important; opacity: 1 !important; }
  html.js .gor:where(:not(.gorundu)), html.js .gor.gor-ciz:where(:not(.gorundu)) { opacity: 1; transform: none; }
  .nu-k > span { animation: none !important; transform: none !important; }
  .ust .logo-svg .y { animation: none !important; }
  html.cikis main, html.cikis .alt { opacity: 1; transform: none; }
}

/* ---------- Forced colours: the navy half of the mark and the wordmark follow the text colour ---------- */
@media (forced-colors: active) {
  .logo-svg .yazi { color: CanvasText; }
  .logo-svg .h-l, .acilis-simge .h-l { stroke: CanvasText; }
  .logo-svg .d-l, .acilis-simge .d-l { fill: CanvasText; }
}

/* ---------- Print: nothing waits for a scroll, an entrance or the opening ---------- */
@media print {
  .acilis-perde { display: none !important; }
  html .gor, html .gor-ciz, html [data-sahne], html [data-acilis-gizle], .nu-k > span,
  .ust .logo-svg .yazi { opacity: 1 !important; transform: none !important; animation: none !important; transition: none !important; }
  .ust .logo-svg .simge { visibility: visible !important; }
}
