/* ============================================================
   Yakiv Serebrianskyi — Portfolio
   Phantom.land-inspired: dark canvas, infinite drag grid,
   mono captions, view toggle, case overlays.
   ============================================================ */

/* ---------------- Фірмова палітра ----------------
   #101010 — графіт, #EF3900 — фірмовий помаранч,
   #F2F2F2 — світло-сірий, #FFFFFF — білий.
   Похідні відтінки побудовані від цих чотирьох. */
:root {
  --bg: #101010;
  --bg-2: #1a1a1a;
  --ink: #f2f2f2;
  --ink-dim: rgba(242, 242, 242, 0.55);
  --line: rgba(242, 242, 242, 0.16);
  --accent: #ef3900;
  --on-ink: #101010;          /* текст на заливці кольору --ink */
  --on-accent: #ffffff;       /* текст на акцентній заливці */
  --panel: rgba(26, 26, 26, 0.85);
  --placeholder: rgba(242, 242, 242, 0.25);
  --font-sans: "Archivo", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;
  --tile-w: clamp(320px, 34vw, 480px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
html[data-theme="light"] {
  --bg: #f2f2f2;
  --bg-2: #ffffff;
  --ink: #101010;
  --ink-dim: rgba(16, 16, 16, 0.55);
  --line: rgba(16, 16, 16, 0.18);
  --accent: #ef3900;
  --on-ink: #ffffff;
  --on-accent: #ffffff;
  --panel: rgba(255, 255, 255, 0.85);
  --placeholder: rgba(16, 16, 16, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.5;
}

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

/* ---------------- Preloader ---------------- */
.preloader {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.7s var(--ease), visibility 0.7s;
}
.preloader.is-done { opacity: 0; visibility: hidden; }
.preloader__inner { width: min(420px, 80vw); text-align: center; }
.preloader__logo {
  font-family: var(--font-sans); font-weight: 600;
  font-size: 64px; letter-spacing: -0.04em; margin-bottom: 32px;
}
.preloader__logo span { color: var(--accent); font-size: 24px; vertical-align: super; }
.preloader__bar { height: 1px; background: var(--line); overflow: hidden; }
.preloader__fill { height: 100%; width: 0%; background: var(--ink); transition: width 0.25s ease-out; }
.preloader__count {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-dim); margin-top: 14px; letter-spacing: 0.1em;
}

/* ---------------- Cursor ---------------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 300;
  pointer-events: none; mix-blend-mode: difference;
}
.cursor__dot {
  position: absolute; left: -5px; top: -5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff;
  transition: transform 0.25s var(--ease);
}
.cursor.is-hover .cursor__dot { transform: scale(3.2); }
.cursor.is-drag .cursor__dot { transform: scale(5.5); }
.cursor__label {
  position: absolute; left: 16px; top: -6px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em;
  color: #fff; white-space: nowrap;
  opacity: 0; transition: opacity 0.2s;
}
.cursor.is-drag .cursor__label, .cursor.is-view .cursor__label { opacity: 1; }
@media (pointer: coarse) { .cursor { display: none; } }

/* ---------------- Header ---------------- */
.header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 28px; pointer-events: none;
}
.header > * { pointer-events: auto; }
.header__logo {
  font-weight: 600; font-size: 30px; letter-spacing: -0.04em;
  color: var(--ink); text-decoration: none; line-height: 1;
  background: var(--panel); backdrop-filter: blur(14px);
  border-radius: 999px; padding: 12px 20px;
}
.header__logo span { color: var(--accent); font-size: 13px; vertical-align: super; }
.header__actions {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); backdrop-filter: blur(14px);
  border-radius: 999px; padding: 5px;
}
.theme-toggle {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line);
  color: var(--ink); cursor: pointer;
  transition: border-color 0.3s, color 0.3s, transform 0.35s var(--ease), background 0.3s;
}
.theme-toggle:hover { border-color: var(--ink); transform: scale(1.08); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle__icon { grid-area: 1 / 1; transition: opacity 0.3s, transform 0.45s var(--ease); }
/* у темній темі показуємо сонце (перемкнути на світлу), у світлій — місяць */
.theme-toggle__icon--moon { opacity: 0; transform: rotate(-90deg) scale(0.5); }
html[data-theme="light"] .theme-toggle__icon--sun { opacity: 0; transform: rotate(90deg) scale(0.5); }
html[data-theme="light"] .theme-toggle__icon--moon { opacity: 1; transform: rotate(0) scale(1); }

html.theme-anim body,
html.theme-anim .header__cta,
html.theme-anim .nav, html.theme-anim .view-toggle,
html.theme-anim .header__logo, html.theme-anim .header__actions,
html.theme-anim .navlink, html.theme-anim .chip,
html.theme-anim .cform input, html.theme-anim .cform textarea,
html.theme-anim .theme-toggle {
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}
html.theme-anim .case, html.theme-anim .about, html.theme-anim .contact {
  transition: background-color 0.5s ease, transform 0.8s var(--ease);
}

.header__cta {
  background: var(--ink); color: var(--on-ink);
  border: none; cursor: pointer;
  font-family: var(--font-sans); font-weight: 500; font-size: 15px;
  text-decoration: none; border-radius: 999px; padding: 16px 28px;
  transition: transform 0.35s var(--ease), background 0.35s;
}
.header__cta:hover { transform: scale(1.06); background: var(--accent); color: var(--on-accent); }

/* ---------------- Drag hint ---------------- */
.drag-hint {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 55; color: var(--ink-dim); pointer-events: none;
  animation: hintPulse 2.4s ease-in-out infinite;
  transition: opacity 0.6s;
}
.drag-hint.is-hidden { opacity: 0; }
@keyframes hintPulse { 0%, 100% { opacity: 0.9; } 50% { opacity: 0.25; } }

/* ---------------- Infinite grid ---------------- */
.grid-stage {
  position: fixed; inset: 0; z-index: 10;
  overflow: hidden; cursor: grab;
  perspective: 900px;
}
.grid-stage.is-dragging { cursor: grabbing; }
.grid-stage.is-hidden { display: none; }
.grid-plane {
  position: absolute; left: 0; top: 0;
  will-change: transform;
  transform-style: preserve-3d;
}
.tile {
  position: absolute;
  width: var(--tile-w);
  user-select: none;
  -webkit-user-drag: none;
}
.tile__media {
  position: relative; overflow: hidden; background: var(--bg-2);
  aspect-ratio: 16 / 9;
}
.tile__media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none;
  transform: scale(1.001);
  transition: transform 0.9s var(--ease), filter 0.9s var(--ease), opacity 0.5s;
  filter: saturate(0.92);
}
.tile:hover .tile__media img { transform: scale(1.07); filter: saturate(1.15); }
.tile__top {
  display: flex; justify-content: space-between; align-items: baseline;
  color: var(--ink-dim); margin-bottom: 8px;
}
.tile__client { color: var(--ink); }
.tile__bottom {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 9px; color: var(--ink-dim);
}
.tile__tags { display: flex; gap: 5px; }
.tag {
  border: 1px solid var(--line); border-radius: 3px;
  padding: 2px 6px; font-size: 9px;
}
.tile__year { font-size: 9px; }

/* ---------------- List view ---------------- */
.list-view {
  position: fixed; inset: 0; z-index: 10;
  overflow-y: auto; overscroll-behavior: contain;
  display: none; padding: 140px 28px 160px;
  scrollbar-width: none;
}
.list-view::-webkit-scrollbar { display: none; }
.list-view.is-active { display: block; }
.list-view__inner { max-width: 1200px; margin: 0 auto; }
.list-row {
  display: grid;
  grid-template-columns: 60px 1fr auto auto;
  gap: 24px; align-items: baseline;
  padding: 26px 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: padding 0.4s var(--ease);
}
.list-row:first-child { border-top: 1px solid var(--line); }
.list-row__idx { font-family: var(--font-mono); font-size: 10px; color: var(--ink-dim); }
.list-row__title {
  font-size: clamp(26px, 4.4vw, 56px); font-weight: 500;
  letter-spacing: -0.03em; line-height: 1.05;
  color: var(--ink-dim);
  transition: color 0.35s, transform 0.45s var(--ease);
}
.list-row:hover .list-row__title { color: var(--ink); transform: translateX(16px); }
.list-row__client, .list-row__year { font-family: var(--font-mono); font-size: 10px; color: var(--ink-dim); letter-spacing: 0.08em; }
.list-view__preview {
  position: fixed; z-index: 11; width: 380px; aspect-ratio: 16/9;
  pointer-events: none; overflow: hidden;
  opacity: 0; transform: scale(0.92);
  transition: opacity 0.3s, transform 0.45s var(--ease);
}
.list-view__preview.is-visible { opacity: 1; transform: scale(1); }
.list-view__preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------- Bottom nav ---------------- */
.bottomnav {
  position: fixed; bottom: 24px; left: 0; right: 0; z-index: 70;
  display: flex; justify-content: center; align-items: center; gap: 14px;
  pointer-events: none;
}
.bottomnav > * { pointer-events: auto; }
.bottomnav__views {
  display: flex; gap: 4px;
  background: var(--panel); backdrop-filter: blur(14px);
  border-radius: 999px; padding: 5px;
  position: absolute; left: 28px; bottom: 0;
}
.viewbtn {
  width: 38px; height: 38px; border-radius: 50%;
  border: none; background: transparent; cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.3s;
}
.viewbtn svg { fill: var(--ink-dim); transition: fill 0.3s; }
.viewbtn.is-active { background: var(--ink); }
.viewbtn.is-active svg { fill: var(--on-ink); }
.viewbtn:not(.is-active):hover svg { fill: var(--ink); }
.bottomnav__links {
  display: flex; gap: 4px;
  background: var(--panel); backdrop-filter: blur(14px);
  border-radius: 999px; padding: 5px;
}
.navlink {
  border: none; cursor: pointer; text-decoration: none;
  background: transparent; color: var(--ink-dim);
  font-family: var(--font-sans); font-size: 15px; font-weight: 500;
  border-radius: 999px; padding: 11px 22px;
  transition: background 0.3s, color 0.3s;
}
.navlink.is-active { background: var(--ink); color: var(--on-ink); }
.navlink:not(.is-active):hover { color: var(--ink); }

/* ---------------- Case overlay ---------------- */
.case, .about, .contact {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  transform: translateY(100%);
  transition: transform 0.8s var(--ease);
  visibility: hidden;
}
.case.is-open, .about.is-open, .contact.is-open { transform: translateY(0); visibility: visible; }
.case__close {
  position: fixed; top: 26px; right: 28px; z-index: 110;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink); font-size: 11px;
  padding: 10px;
  transition: color 0.3s;
}
.case__close:hover { color: var(--accent); }
.case__scroll, .about__scroll, .contact__scroll {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  padding: 110px 28px 80px;
  scrollbar-width: none;
}
.case__scroll::-webkit-scrollbar, .about__scroll::-webkit-scrollbar, .contact__scroll::-webkit-scrollbar { display: none; }
.case__head { max-width: 1200px; margin: 0 auto 40px; }
.case__client { color: var(--accent); margin-bottom: 18px; }
.case__title {
  font-size: clamp(44px, 9vw, 120px);
  font-weight: 500; letter-spacing: -0.04em; line-height: 0.95;
  text-transform: uppercase;
  margin-bottom: 26px;
}
.case__meta { color: var(--ink-dim); display: flex; gap: 28px; flex-wrap: wrap; }
.case__hero { max-width: 1200px; margin: 0 auto 70px; overflow: hidden; }
.case__hero img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.case__body {
  max-width: 1200px; margin: 0 auto 70px;
  display: grid; grid-template-columns: 200px 1fr; gap: 30px;
}
.case__col { color: var(--ink-dim); }
.case__desc { font-size: clamp(18px, 2.2vw, 26px); line-height: 1.45; max-width: 760px; color: var(--ink); }
.case__facts {
  max-width: 1200px; margin: 0 auto 80px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  border-top: 1px solid var(--line);
}
.case__fact { padding: 20px 8px; border-bottom: 1px solid var(--line); color: var(--ink-dim); }
.case__fact b { display: block; color: var(--ink); margin-top: 6px; font-weight: 500; }
.case__next {
  display: block; width: 100%; max-width: 1200px; margin: 0 auto;
  background: transparent; border: 1px solid var(--line); cursor: pointer;
  padding: 40px 32px; text-align: left; color: var(--ink-dim);
  transition: border-color 0.4s, background 0.4s;
}
.case__next:hover { border-color: var(--ink); background: var(--bg-2); }
.case__next .mono { display: block; margin-bottom: 12px; }
.case__next-title {
  font-family: var(--font-sans); font-size: clamp(28px, 5vw, 54px);
  font-weight: 500; letter-spacing: -0.03em; color: var(--ink);
  text-transform: uppercase;
}

/* ---------------- About ---------------- */
.about__title {
  max-width: 1200px; margin: 0 auto 70px;
  font-size: clamp(48px, 10vw, 140px);
  font-weight: 500; letter-spacing: -0.045em; line-height: 1.02;
}
.about__title span { display: block; }
.about__grid {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 60px 50px;
}
.about__label { color: var(--accent); margin-bottom: 20px; }
.about__block p { font-size: 17px; line-height: 1.6; color: var(--ink); margin-bottom: 16px; max-width: 460px; }
.about__list { list-style: none; }
.about__list li {
  padding: 12px 0; border-bottom: 1px solid var(--line);
  color: var(--ink); font-size: 11px;
}
.about__stats { display: flex; flex-direction: column; gap: 28px; }
.stat__num { font-size: clamp(48px, 6vw, 80px); font-weight: 500; letter-spacing: -0.04em; line-height: 1; }
.stat__num::after { content: "+"; color: var(--accent); }
.stat__cap { color: var(--ink-dim); margin-top: 6px; }
.about__mail {
  font-size: clamp(20px, 2.6vw, 30px); font-weight: 500; letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none;
  border-bottom: 1px solid var(--line);
  transition: color 0.3s, border-color 0.3s;
}
.about__mail:hover { color: var(--accent); border-color: var(--accent); }
.about__socials { display: flex; gap: 22px; margin-top: 30px; }
.about__socials a { color: var(--ink-dim); text-decoration: none; transition: color 0.3s; }
.about__socials a:hover { color: var(--ink); }

/* ---------------- Contact ---------------- */
.contact__head { max-width: 1200px; margin: 0 auto 60px; }
.contact__kicker { color: var(--accent); margin-bottom: 22px; }
.contact__title {
  font-size: clamp(44px, 8.5vw, 120px);
  font-weight: 500; letter-spacing: -0.045em; line-height: 1.02;
}
.contact__title span { display: block; }
.contact__grid {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 1.7fr 1fr; gap: 70px;
  align-items: start;
}
.cform__row { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; }
.cform__field { margin-bottom: 38px; }
.cform__field label, .cform__legend { display: block; color: var(--ink-dim); margin-bottom: 14px; }
.cform input, .cform textarea {
  width: 100%; background: transparent; border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ink); font-family: var(--font-sans);
  font-size: 19px; padding: 10px 0 14px;
  outline: none; resize: none;
  transition: border-color 0.3s;
  border-radius: 0;
}
.cform input::placeholder, .cform textarea::placeholder { color: var(--placeholder); }
.cform input:focus, .cform textarea:focus { border-color: var(--ink); }
.cform__field.is-invalid input, .cform__field.is-invalid textarea { border-color: var(--accent); }
.cform__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: transparent; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em;
  padding: 9px 16px;
  transition: border-color 0.3s, color 0.3s, background 0.3s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.chip--lg { padding: 14px 26px; margin-top: 26px; }
.cform__error { color: var(--accent); min-height: 18px; margin-bottom: 14px; }
.cform__submit {
  display: inline-flex; align-items: center; gap: 16px;
  background: var(--ink); color: var(--on-ink); border: none; cursor: pointer;
  font-family: var(--font-sans); font-weight: 500; font-size: 17px;
  border-radius: 999px; padding: 20px 36px;
  transition: transform 0.35s var(--ease), background 0.35s, color 0.35s;
}
.cform__submit:hover { transform: scale(1.05); background: var(--accent); color: var(--on-accent); }
.cform__submit:disabled { opacity: 0.5; pointer-events: none; }
.cform__arrow { transition: transform 0.35s var(--ease); }
.cform__submit:hover .cform__arrow { transform: translateX(6px); }
.contact__aside { display: flex; flex-direction: column; gap: 48px; }
.about__socials--col { flex-direction: column; gap: 12px; margin-top: 0; }
.contact__loc { font-size: 17px; line-height: 1.7; color: var(--ink); }
.contact__loc .mono { color: var(--ink-dim); }
.contact__success {
  display: none; max-width: 1200px; margin: 0 auto;
  text-align: center; padding: 60px 0;
}
.contact.is-sent .contact__grid, .contact.is-sent .contact__head { display: none; }
.contact.is-sent .contact__success { display: block; }
.contact__success-mark {
  width: 86px; height: 86px; margin: 0 auto 34px;
  border: 1px solid var(--accent); border-radius: 50%;
  display: grid; place-items: center;
  color: var(--accent); font-size: 34px;
  animation: popIn 0.6s var(--ease) both;
}
@keyframes popIn { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.contact__success-title {
  font-size: clamp(44px, 7vw, 90px); font-weight: 500;
  letter-spacing: -0.04em; margin-bottom: 18px;
}
.contact__success p { color: var(--ink-dim); font-size: 17px; }

/* ---------------- Reveal animation ----------------
   ВАЖЛИВО: анімація появи живе на .tile__inner, а не на .tile —
   .tile позиціюється transform'ом кожен кадр (drag), і transition
   на ньому зламає панорамування полотна. */
.tile__inner { opacity: 0; transform: scale(0.94) translateY(14px); }
body.is-loaded .tile__inner {
  opacity: 1; transform: scale(1) translateY(0);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 860px) {
  .header { align-items: center; padding: 12px 12px; }
  .header__logo { font-size: 24px; padding: 10px 16px; }
  .header__cta { padding: 12px 20px; font-size: 13px; }
  .theme-toggle { width: 44px; height: 44px; }
  /* перемикач вигляду — по центру над навігацією */
  .bottomnav { bottom: 16px; flex-direction: column; gap: 10px; }
  .bottomnav__views { position: static; }
  .case__body { grid-template-columns: 1fr; }
  .contact__grid { grid-template-columns: 1fr; gap: 50px; }
  .cform__row { grid-template-columns: 1fr; gap: 0; }
  .list-view { padding: 110px 16px 140px; }
  .list-row { grid-template-columns: 36px 1fr auto; }
  .list-row__client { display: none; }
  .list-view__preview { display: none; }
  :root { --tile-w: 78vw; }
}

/* ---------------- State helpers ---------------- */
body.is-list .drag-hint, body.is-overlay .drag-hint { opacity: 0 !important; }
body.is-overlay .cursor__label { opacity: 0 !important; }
