/* ============================================================
   SHARED  ·  Portfolio Iryna Nechytailo
   Tokens · reset · layout · curtain scroll · topbar base
   reveal animation · tweaks panel · keyframes
   ============================================================ */

/* ── GOOGLE FONTS ─────────────────────────────────────────────
   Loaded via <link> in each page's <head>.
   Public Sans (300–700) · JetBrains Mono (400–500) · Fraunces (300–400)
   ──────────────────────────────────────────────────────────── */

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  /* Palette — warm default */
  --bg:        #F2EDE4;
  --bg-2:      #ECE6DA;
  --bg-card:   #ffffff;
  --ink:       #15110C;
  --muted:     #706860;
  --rule:      rgba(21, 17, 12, 0.12);
  --rule-soft: rgba(21, 17, 12, 0.06);
  --hot:       #C0612F;
  --black:     #0A0908;

  /* Case accent — overridden per project page via data-case attribute */
  --case-accent:       #0E6B5A;
  --case-accent-deep:  #094B3E;
  --case-accent-light: rgba(14, 107, 90, 0.18);

  /* Typography */
  --f-ui:      'Public Sans', system-ui, sans-serif;
  --f-display: 'Public Sans', system-ui, sans-serif;
  --f-mono:    'JetBrains Mono', ui-monospace, monospace;

  /* Layout */
  --width:  1280px;
  --pad-x:  40px;
  --pad-x-mobile: 24px;

  /* Motion */
  --anim:         1;
  --d-fast:       calc(0.32s * var(--anim));
  --d-med:        calc(0.60s * var(--anim));
  --d-slow:       calc(1.00s * var(--anim));
  --ease:         cubic-bezier(0.22, 1, 0.36, 1);
  --ease-curtain: cubic-bezier(0.65, 0, 0.05, 1);
}

/* ── PALETTE THEMES ─────────────────────────────────────────── */
:root[data-palette="warm"] {
  --bg: #F2EDE4; --bg-2: #ECE6DA; --ink: #15110C; --muted: #706860;
  --rule: rgba(21, 17, 12, 0.12); --rule-soft: rgba(21, 17, 12, 0.06);
}
:root[data-palette="paper"] {
  --bg: #F6F3EC; --bg-2: #EFEAE0; --ink: #1A1814; --muted: #6A6358;
  --rule: rgba(26, 24, 20, 0.12); --rule-soft: rgba(26, 24, 20, 0.06);
}
:root[data-palette="cool"] {
  --bg: #ECEDEE; --bg-2: #E2E4E7; --ink: #0E1116; --muted: #5C6470;
  --rule: rgba(14, 17, 22, 0.12); --rule-soft: rgba(14, 17, 22, 0.06);
}
:root[data-palette="ink"] {
  --bg: #F1ECE3; --bg-2: #E9E2D4; --ink: #11151B; --muted: #686870;
  --rule: rgba(17, 21, 27, 0.14); --rule-soft: rgba(17, 21, 27, 0.06);
}

/* ── TYPE THEMES ────────────────────────────────────────────── */
:root[data-type="grotesk"]       { --f-display: 'Public Sans', system-ui, sans-serif; }
:root[data-type="serif-display"] { --f-display: 'Fraunces', 'Public Sans', serif; }
:root[data-type="mono-meta"]     { --f-display: 'Public Sans', system-ui, sans-serif; }

/* ── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html,
body {
  background: var(--black);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { font-feature-settings: "ss01", "ss02"; overflow-x: hidden; }
::selection { background: var(--ink); color: var(--bg); }
a { color: inherit; text-decoration: none; }
img, svg, video { display: block; max-width: 100%; }

/* ── MONO LABEL BASE ─────────────────────────────────────────
   All small monospace uppercase labels across both pages.
   Only `color` is overridden per element.
   ─────────────────────────────────────────────────────────── */
.eyebrow,
.project__thumb-cover,
.project__eyebrow,
.exp-case__aside-label,
.exp-case__media .media-caption,
.exp-case__meta,
.approach__item-label,
.scroll-hint__label,
.case-hero__eyebrow,
.gallery__shot-cap,
.gallery__controls,
.about__dt,
.about__block-label,
.sec__eyebrow,
.decision__aside-label,
.decision__card-head-label,
.impact-card__label,
.case-next__label {
  font-family: var(--f-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ── LAYOUT PRIMITIVE ───────────────────────────────────────── */
.wrap {
  width: min(var(--width), 100% - var(--pad-x) * 2);
  margin: 0 auto;
}
@media (max-width: 700px) {
  .wrap {
    width: min(var(--width), 100% - var(--pad-x-mobile) * 2);
  }
  /* Disable scroll-reveal on mobile — show content immediately */
  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
section { position: relative; }

/* ── SCROLL CURTAIN ─────────────────────────────────────────── */
/*
  Cream layer (.curtain) scrolls up, revealing the fixed
  dark section underneath — via margin-bottom: 100vh.
  Two stacked levels:
    curtain      z-index 3  — always on top of both beneath layers
    .beneath--experience  z-index 2  — mid-page dark section
    .beneath     z-index 1  — footer, lowest layer
*/
.curtain {
  position: relative;
  z-index: 3;
  background: var(--bg);
  margin-bottom: 100vh;
  margin-bottom: 100dvh;
  transition: background var(--d-fast) var(--ease);
}

/* ── MID-PAGE DARK BENEATH (experience section) ─────────── */
.beneath--experience {
  position: fixed;
  inset: auto 0 0 0;
  height: 100vh;
  height: 100dvh;
  z-index: 1;
  background: var(--black);
  overflow: hidden;
}

.beneath {
  position: fixed;
  inset: auto 0 0 0;
  height: 100vh;
  z-index: 1;
  background: var(--black);
  color: #BFBAB0;
  overflow: hidden;
}
.beneath::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(1100px 600px at 18% 70%, rgba(184, 90, 46, 0.10), transparent 60%),
    radial-gradient(900px 500px at 82% 30%, rgba(255, 255, 255, 0.04), transparent 60%);
  pointer-events: none;
}

.beneath__inner {
  position: relative;
  height: 100%;
  width: min(var(--width), 100% - var(--pad-x) * 2);
  margin: 0 auto;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 80px 0 56px;
}

.beneath__heading {
  font-family: var(--f-display);
  font-weight: 300;
  font-size: clamp(40px, 4.6vw, 64px);
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: #F5EFE2;
  max-width: 18ch;
  align-self: end;
}
:root[data-type="serif-display"] .beneath__heading { font-family: var(--f-display); }
.beneath__heading em { font-style: normal; color: #C8B8A0; }

.beneath__foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 56px;
  color: rgba(245, 239, 226, 0.55);
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
}
.beneath__links { display: flex; gap: 28px; }
.beneath__links a { color: rgba(245, 239, 226, 0.55); transition: color var(--d-fast) var(--ease); }
.beneath__links a:hover { color: #F5EFE2; }

/* ── TOPBAR (base) ──────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid transparent;
  transition:
    border-color var(--d-fast) var(--ease),
    background   var(--d-fast) var(--ease);
}
.topbar--scrolled       { border-bottom-color: var(--rule-soft); }

/* Dark variant — active when topbar overlaps a dark section */
.topbar--dark {
  background: color-mix(in srgb, var(--black) 85%, transparent);
}
.topbar--dark.topbar--scrolled          { border-bottom-color: rgba(245, 239, 226, 0.10); }
.topbar--dark .brand                    { color: #F5EFE2; }
.topbar--dark .topbar__back             { color: #F5EFE2; }
.topbar--dark .topbar__anchors          { color: #BFBAB0; }
.topbar--dark .topbar__anchors a:hover  { color: #F5EFE2; }
.topbar--dark .topbar__anchors a.is-active {
  color: #F5EFE2;
  background: rgba(245, 239, 226, 0.10);
}

.topbar__inner {
  width: min(var(--width), 100% - var(--pad-x) * 2);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  font-size: 14px;
}
@media (max-width: 700px) {
  .topbar__inner {
    width: min(var(--width), 100% - var(--pad-x-mobile) * 2);
    gap: 10px;
  }
  /* Brand / back link: shrink and truncate with ellipsis */
  /* padding-top/bottom matches link padding so topbar height stays fixed when dropdown opens */
  .brand, .topbar__back {
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 6px 0;
  }
  /* Nav stays at natural size — never shrinks */
  .topbar__anchors { flex-shrink: 0; }
}

/* ── TOPBAR: ANCHOR PILL NAV ────────────────────────────────── */
/* Shared by both home and case pages */
.topbar__anchors {
  display: flex;
  gap: 2px;
  color: var(--muted);
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar__anchors::-webkit-scrollbar { display: none; }
.topbar__anchors a {
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
  transition:
    color      var(--d-fast) var(--ease),
    background var(--d-fast) var(--ease);
}
.topbar__anchors a:hover    { color: var(--ink); }
.topbar__anchors a.is-active { color: var(--ink); background: var(--bg-2); }

/* ── MEDIA SLOT ─────────────────────────────────────────────── */
/*
  Universal container for image / gif / video.
  Replace .media-slot__placeholder with actual <img> or <video>.
  See README.txt in each media/ subfolder for instructions.
*/
.media-slot {
  position: relative;
  overflow: hidden;
  display: block;
}
.media-slot__placeholder {
  position: absolute;
  inset: 0;
}
.media-slot img,
.media-slot video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── REVEAL ON SCROLL ───────────────────────────────────────── */
[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity   var(--d-slow) var(--ease),
    transform var(--d-slow) var(--ease);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

/* ── TWEAKS PANEL ───────────────────────────────────────────── */
.tweaks-toggle {
  display: none !important;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--bg);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 28px -12px rgba(21, 17, 12, 0.18);
  transition: transform var(--d-fast) var(--ease);
}
.tweaks-toggle:hover { transform: rotate(45deg); }

.tweaks-panel {
  position: fixed;
  right: 20px;
  bottom: 76px;
  z-index: 101;
  width: 320px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 18px;
  font-size: 15px;
  box-shadow: 0 30px 60px -30px rgba(21, 17, 12, 0.40);
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--d-fast) var(--ease),
    opacity   var(--d-fast) var(--ease);
}
.tweaks-panel.is-open { transform: none; opacity: 1; pointer-events: auto; }

.tweaks__section { margin-bottom: 14px; }
.tweaks__section:last-child { margin-bottom: 0; }
.tweaks__label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.tweaks__row { display: flex; gap: 6px; }

.tweaks__chip {
  flex: 1;
  padding: 8px 10px;
  font-size: 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: all var(--d-fast) var(--ease);
}
.tweaks__chip:hover { background: var(--bg-2); }
.tweaks__chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.tweaks__swatch {
  flex: 1;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--rule);
  cursor: pointer;
  transition: transform var(--d-fast) var(--ease);
}
.tweaks__swatch.is-on { outline: 2px solid var(--ink); outline-offset: 2px; }
.tweaks__swatch:hover { transform: translateY(-2px); }
.tweaks__slider { width: 100%; }

/* ── TOPBAR: MOBILE NAV DROPDOWN ───────────────────────────── */
@media (max-width: 700px) {
  .topbar__anchors { position: relative; }

  /* Hide ALL links by default — no flash of full nav */
  .topbar__anchors a { display: none !important; }

  /* External links (LinkedIn) always visible */
  .topbar__anchors a[href^="http"] { display: inline-flex !important; }

  /* Show only active link (or first link as fallback) */
  .topbar__anchors a.is-active                        { display: flex !important; }
  .topbar__anchors:not(:has(a.is-active)) a:first-child { display: flex !important; }

  /* Chevron on the visible trigger link */
  .topbar__anchors a.is-active,
  .topbar__anchors:not(:has(a.is-active)) a:first-child {
    padding-right: 26px;
    position: relative;
  }
  .topbar__anchors a.is-active::after,
  .topbar__anchors:not(:has(a.is-active)) a:first-child::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-70%) rotate(45deg);
    opacity: 0.55;
    transition: transform var(--d-fast) var(--ease);
  }

  /* Open: dropdown panel */
  .topbar__anchors.is-open {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    border-radius: 10px;
    border: 1px solid var(--rule);
    background: color-mix(in srgb, var(--bg) 96%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 32px -12px rgba(21, 17, 12, 0.22);
    z-index: 10;
    min-width: 190px;
  }
  .topbar--dark .topbar__anchors.is-open {
    background: color-mix(in srgb, #191B1C 96%, transparent);
    border-color: rgba(245, 239, 226, 0.12);
    box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.45);
  }
  /* Show all links when open */
  .topbar__anchors.is-open a { display: flex !important; }
  /* Flip chevron when open */
  .topbar__anchors.is-open a.is-active::after,
  .topbar__anchors.is-open:not(:has(a.is-active)) a:first-child::after {
    transform: translateY(-30%) rotate(-135deg);
  }

  /* Footer: vertical stack, left-aligned — LinkedIn / email / copyright */
  .beneath__foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .beneath__foot > span { order: 3; }   /* copyright last */
  .beneath__links {
    order: 1;
    flex-direction: column;
    gap: 8px;
  }
  /* LinkedIn first, email second */
  .beneath__links a[href*="linkedin"] { order: -1; }
}

/* ── KEYFRAMES ──────────────────────────────────────────────── */
@keyframes rise {
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fade-in {
  to { opacity: 1; }
}
