/* ============================================================
   English4Ukrainians — main.css
   v2: tabs navigation + mobile fitText hero
   ============================================================ */

/* ----- TOKENS ----- */
:root {
  --bg: #FAFAF7;
  --ink: #0F0F0F;
  --muted: #6B6B6B;
  --muted-soft: #8A8A8A;
  --line: #E5E2DA;
  --line-hover: #C9C4B5;

  /* Slide-specific accents */
  --c-beginner: #8A98A8;
  --c-intermediate: #C97B4A;
  --c-fluent: #1E6F73;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Manrope', system-ui, sans-serif;

  --transition-slow: 700ms cubic-bezier(0.65, 0, 0.35, 1);
  --transition-med: 450ms cubic-bezier(0.65, 0, 0.35, 1);
  --transition-fast: 250ms ease;
}

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

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

/* ----- NAV ----- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 48px;
  background: rgba(250, 250, 247, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.nav__logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.nav__logo em {
  font-style: italic;
  font-weight: 400;
}

.nav__menu {
  display: flex;
  gap: 32px;
  font-size: 14px;
  font-weight: 500;
}

.nav__menu a {
  color: var(--ink);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 200ms;
}

.nav__menu a:hover { opacity: 1; }

.nav__cta {
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 100px;
  text-decoration: none;
  transition: transform 200ms, background 200ms;
}

.nav__cta:hover {
  transform: translateY(-1px);
  background: var(--c-fluent);
}

/* ----- HERO / SLIDER ----- */
.hero {
  position: relative;
  min-height: 100vh;
  padding: 96px 48px 48px;
  overflow: hidden;
}

/* ----- SLIDER STAGE -----
   Photo controls its own max-height via viewport math.
   Stage just needs enough room and a sensible minimum. */
.stage {
  position: relative;
  min-height: 420px;
  display: grid;
  cursor: pointer;
}

.slide {
  grid-area: 1 / 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-slow), visibility var(--transition-slow);
  max-width: 100%;
  overflow: hidden;
  min-height: 420px;
}

.slide.is-active {
  opacity: 1;
  visibility: visible;
}

/* The giant word — BEHIND the person */
.slide__word {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(64px, 14vw, 220px);
  line-height: 0.85;
  letter-spacing: -0.04em;
  white-space: nowrap;
  z-index: 1;
  transition: color var(--transition-slow);
  user-select: none;
}

.slide[data-stage="beginner"] .slide__word { color: var(--c-beginner); }
.slide[data-stage="intermediate"] .slide__word { color: var(--c-intermediate); }
.slide[data-stage="fluent"] .slide__word { color: var(--c-fluent); }

/* The person photo — bounded by viewport height directly so head never clips
   under nav. Calc: 100vh - nav (~80px) - hero top padding - hero bottom padding
   - controls block - breathing room. */
.slide__photo {
  position: relative;
  z-index: 2;
  height: auto;
  max-height: calc(100vh - 280px);
  width: auto;
  max-width: 100%;
  object-fit: contain;
  object-position: center center;
  filter: drop-shadow(0 20px 40px rgba(15, 15, 15, 0.08));
  animation: subtleFloat 6s ease-in-out infinite;
}

@keyframes subtleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Caption above the word */
.slide__caption {
  position: absolute;
  top: 2%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(16px, 1.6vw, 22px);
  color: var(--ink);
  text-align: center;
  max-width: 80%;
  line-height: 1.4;
  opacity: 0.95;
  background: rgba(250, 250, 247, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 6px 16px;
  border-radius: 100px;
}

/* Subtitle below */
.slide__sub {
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.slide__sub strong {
  color: var(--ink);
  font-weight: 700;
}

.slide__sub-short { display: none; }
.slide__sub-full { display: inline; }

/* ============================================================
   FIX 1: bottom progress bars → readable tab navigation
   ============================================================ */

.controls {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--line);
  gap: 32px;
}

.progress {
  display: flex;
  gap: 12px;
  flex: 1;
  max-width: 480px;
  align-items: flex-start;
}

.progress__bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 8px 0 4px;
  position: relative;
  font-family: var(--font-body);
  text-align: left;
  transition: opacity var(--transition-fast);
}

/* The actual bar element */
.progress__bar::after {
  content: '';
  display: block;
  width: 100%;
  height: 2px;
  background: var(--line);
  border-radius: 2px;
  transition: height var(--transition-fast), background-color var(--transition-fast);
  order: -1;
}

/* Hover state — only when NOT active */
.progress__bar:not(.is-active):hover::after {
  height: 3px;
  background: var(--line-hover);
}

/* Active state — colored bar by stage */
.progress__bar.is-active::after {
  height: 3px;
}

.progress__bar[data-stage="beginner"].is-active::after { background: var(--c-beginner); }
.progress__bar[data-stage="intermediate"].is-active::after { background: var(--c-intermediate); }
.progress__bar[data-stage="fluent"].is-active::after { background: var(--c-fluent); }

/* Label under the bar */
.progress__label {
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted-soft);
  transition: color var(--transition-fast);
  line-height: 1.2;
  white-space: nowrap;
}

.progress__bar.is-active .progress__label {
  color: var(--ink);
}

.progress__bar:not(.is-active):hover .progress__label {
  color: var(--ink);
}

/* Keyboard focus — visible, accessible */
.progress__bar:focus { outline: none; }
.progress__bar:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ----- CTA ----- */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 16px 28px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border-radius: 100px;
  transition: transform 200ms, background 200ms;
  flex-shrink: 0;
}

.cta:hover {
  transform: translateY(-2px);
  background: var(--c-fluent);
}

.cta__arrow {
  transition: transform 200ms;
  display: inline-block;
}

.cta:hover .cta__arrow {
  transform: translateX(4px);
}

/* ----- RESPONSIVE ----- */
@media (max-width: 900px) {
  .nav { padding: 16px 24px; }
  .nav__menu { display: none; }

  .hero { padding: 100px 24px 40px; }

  .slide__caption {
    top: 1%;
    font-size: 14px;
  }

  .slide__sub {
    font-size: 11px;
    letter-spacing: 0.12em;
  }

  .controls {
    flex-direction: column;
    gap: 32px;
    align-items: stretch;
  }

  .cta {
    margin-left: 0;
    justify-content: center;
  }

  .progress {
    max-width: 100%;
    gap: 8px;
  }
}

/* ============================================================
   FIX 2: mobile hero — all three display words fit in viewport
   Strategy: JS auto-fit via fitText() (see script.js).
   CSS provides hard bounds (min 40px, max 90px) and sane defaults.
   ============================================================ */
@media (max-width: 600px) {
  .hero {
    padding: 90px 16px 24px;
    /* leave room for sticky CTA at the bottom */
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }

  .stage {
    height: clamp(440px, 68vh, 580px);
  }

  .slide__word {
    top: auto;
    bottom: 22%;
    left: 50%;
    transform: translateX(-50%);
    /* CSS fallback if JS fails: tuned for "ВПЕВНЕНО" (widest 8-letter word in Fraunces 900) */
    font-size: clamp(36px, calc((100vw - 32px) / 6.2), 78px);
    letter-spacing: -0.06em;
    line-height: 0.9;
    max-width: calc(100vw - 32px);
    /* JS will override font-size via inline style; this is the fallback */
  }

  .slide__photo {
    max-height: calc(100vh - 320px);
    object-fit: contain;
    object-position: center center;
  }

  .slide__caption {
    top: 1%;
    font-size: 15px;
    line-height: 1.35;
    max-width: calc(100vw - 48px);
    width: calc(100vw - 48px);
    padding: 0;
    left: 50%;
    transform: translateX(-50%);
    word-break: normal;
    overflow-wrap: normal;
    hyphens: none;
    white-space: normal;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 0;
  }

  .slide__sub {
    bottom: 2%;
    font-size: 11px;
    letter-spacing: 0.08em;
    white-space: normal;
    text-align: center;
    max-width: 90%;
    padding: 0 24px;
    line-height: 1.3;
  }

  .slide__sub-full { display: none; }
  .slide__sub-short { display: inline; }

  .progress__label {
    font-size: 10px;
    letter-spacing: 0.06em;
  }

  .controls {
    margin-top: 28px;
    padding-top: 24px;
    gap: 20px;
  }

  /* Sticky full-width CTA on mobile */
  .cta {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 50;
    height: 56px;
    padding: 0 22px;
    font-size: 14px;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(15, 15, 15, 0.12);
  }
}

@media (max-width: 380px) {
  .progress__label {
    font-size: 9px;
    letter-spacing: 0.04em;
  }
  .progress { gap: 6px; }
}

/* ----- Accessibility ----- */
@media (prefers-reduced-motion: reduce) {
  .slide__photo { animation: none; }
  .slide,
  .slide__word,
  .progress__bar::after,
  .progress__label,
  .cta,
  .cta__arrow {
    transition: none !important;
  }
}
