/* ===================================================================
   Бебек — design system (Балаш Дадашов)
   Ported from static design/ template and adapted for Laravel.
   =================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; padding: 0; }
body {
  background: #F3EEE6;
  color: #211B14;
  font-family: 'Golos Text', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

:root {
  --accent: #B4623A;
  --ink: #211B14;
  --paper: #F3EEE6;
  --paper-2: #EEE7DB;
  --paper-card: #FBF7F0;
  --muted: #6B5D4C;
  --body: #3b3125;
  --hair: rgba(33,27,20,.14);
  /* preloader */
  --sky-top: #dfeaf2;
  --sky-bottom: #f6f2e8;
  --bird: #4a3f35;
  --pl-text: #6b5d4f;
}

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

a { color: inherit; }

/* ===== Keyframes ===== */
@keyframes bbScroll { 0%,100% { transform: translateY(0); opacity:.5; } 50% { transform: translateY(9px); opacity:1; } }
@keyframes bbMarquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes bbFloat { 0%,100% { transform: translateY(0) rotate(-2.5deg); } 50% { transform: translateY(-14px) rotate(-2.5deg); } }

/* ===== Page wrapper (theme) ===== */
.bb-page { position: relative; min-height: 100vh; }
.bb-page.bb-theme-light { background: var(--paper); color: var(--ink); }
.bb-page.bb-theme-dark  { background: var(--ink);   color: #EDE3D6; --muted: #9a8a78; --hair: rgba(237,227,214,.14); }

/* ===== Sticky nav ===== */
#siteNav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(20px, 5vw, 64px);
  transition: background .4s, backdrop-filter .4s, border-color .4s, padding .4s;
  border-bottom: 1px solid transparent;
}
#siteNav.is-scrolled {
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding-top: 14px; padding-bottom: 14px;
}
.bb-theme-light #siteNav.is-scrolled { background: rgba(243,238,230,.82); border-bottom-color: rgba(33,27,20,.1); }
.bb-theme-dark  #siteNav.is-scrolled { background: rgba(26,20,13,.82);  border-bottom-color: rgba(237,227,214,.1); }

.bb-brand {
  font-family: 'Golos Text', sans-serif; font-weight: 700; font-size: 16px;
  letter-spacing: .14em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
}
.bb-theme-light .bb-brand { color: var(--ink); }
.bb-theme-dark  .bb-brand { color: #EDE3D6; }

.bb-nav-links { display: flex; align-items: center; gap: clamp(14px, 2.4vw, 34px); font-size: 15px; }
.bb-nav-links a { text-decoration: none; transition: color .3s; }
.bb-theme-light .bb-nav-links a { color: var(--muted); }
.bb-theme-light .bb-nav-links a:hover, .bb-theme-light .bb-nav-links a.is-active { color: var(--ink); }
.bb-theme-dark  .bb-nav-links a { color: #9a8a78; }
.bb-theme-dark  .bb-nav-links a:hover, .bb-theme-dark .bb-nav-links a.is-active { color: #EDE3D6; }
.bb-nav-links a.is-active { color: var(--accent) !important; }

.bb-nav-sep { width: 1px; height: 16px; }
.bb-theme-light .bb-nav-sep { background: rgba(33,27,20,.2); }
.bb-theme-dark  .bb-nav-sep { background: rgba(237,227,214,.2); }

.bb-nav-util { display: flex; align-items: center; gap: 14px; }
.bb-switch {
  font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: .08em;
  display: inline-flex; align-items: center; gap: 6px;
}
.bb-switch a { text-decoration: none; transition: color .3s; }
.bb-theme-light .bb-switch a { color: var(--muted); }
.bb-theme-dark  .bb-switch a { color: #9a8a78; }
.bb-switch a.is-active, .bb-switch a:hover { color: var(--accent); }
.bb-switch .sep { opacity: .4; }

.bb-cart-link { position: relative; display: inline-flex; align-items: center; text-decoration: none; }
.bb-logout { background: none; border: none; cursor: pointer; font: inherit; padding: 0; color: inherit; }

/* hamburger (mobile) */
.bb-burger {
  display: none; flex-direction: column; gap: 5px; width: 30px; height: 22px;
  background: none; border: none; cursor: pointer; padding: 0; z-index: 60;
}
.bb-burger span { display: block; height: 2px; width: 100%; background: currentColor; transition: transform .3s, opacity .3s; }
.bb-theme-light .bb-burger { color: var(--ink); }
.bb-theme-dark  .bb-burger { color: #EDE3D6; }
body.bb-menu-open .bb-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.bb-menu-open .bb-burger span:nth-child(2) { opacity: 0; }
body.bb-menu-open .bb-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* mobile drawer */
.bb-drawer {
  position: fixed; inset: 0; z-index: 55; background: var(--paper);
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 22px;
  padding: 80px 24px 40px; opacity: 0; visibility: hidden; transform: translateY(-12px);
  transition: opacity .35s, transform .35s, visibility .35s;
}
.bb-theme-dark .bb-drawer { background: var(--ink); }
body.bb-menu-open .bb-drawer { opacity: 1; visibility: visible; transform: none; }
.bb-drawer a { text-decoration: none; font-family: 'Alegreya', serif; font-size: 28px; color: inherit; }
.bb-drawer a.is-active { color: var(--accent); }
.bb-drawer .bb-drawer-util { display: flex; align-items: center; gap: 18px; margin-top: 12px; }

/* ===== Progress bar ===== */
.bb-progress-track { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; }
.bb-progress-track > div { height: 100%; width: 0%; background: var(--accent); transition: width .1s linear; }

/* ===== Reveal on scroll ===== */
.reveal {
  opacity: 0; transform: translateY(24px);
  transition: opacity .9s cubic-bezier(.2,.8,.2,1), transform .9s cubic-bezier(.2,.8,.2,1);
}
.reveal.is-in { opacity: 1; transform: none; }

/* ===== Reusable component classes ===== */
.bb-container { max-width: 1160px; margin: 0 auto; }
.bb-section { padding: clamp(60px,10vh,120px) clamp(20px,5vw,64px); }

.bb-eyebrow {
  font-family: 'IBM Plex Mono', monospace; font-size: 13px; letter-spacing: .28em;
  text-transform: uppercase; color: var(--accent);
}
.bb-h1 { font-family: 'Alegreya', serif; font-weight: 800; line-height: .9; letter-spacing: -.02em; margin: 0; }
.bb-h2 { font-family: 'Alegreya', serif; font-weight: 800; line-height: 1; letter-spacing: -.01em; margin: 0; }
.bb-serif { font-family: 'Spectral', serif; }

.bb-cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--accent); color: #F7F2EA; font-weight: 600; font-size: 16px;
  padding: 17px 34px; border-radius: 100px; text-decoration: none; border: none; cursor: pointer;
  transition: transform .4s cubic-bezier(.2,.8,.2,1), box-shadow .4s;
}
.bb-cta:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(180,98,58,.35); }
.bb-cta.bb-cta-ink { background: var(--ink); color: #F3EEE6; }
.bb-cta.bb-cta-ink:hover { box-shadow: 0 16px 34px rgba(33,27,20,.3); }

.bb-link-underline {
  display: inline-flex; align-items: center; gap: 10px; font-weight: 500; font-size: 16px;
  color: inherit; text-decoration: none; border-bottom: 1.5px solid var(--accent); padding-bottom: 3px;
  transition: color .3s;
}
.bb-link-underline:hover { color: var(--accent); }

.bb-card {
  background: var(--paper-card); border: 1px solid rgba(33,27,20,.12); border-radius: 20px;
  padding: clamp(30px,3.5vw,48px); display: flex; flex-direction: column; gap: 22px;
  transition: transform .5s cubic-bezier(.2,.8,.2,1), box-shadow .5s;
}
.bb-card:hover { transform: translateY(-8px); box-shadow: 0 30px 60px rgba(33,27,20,.14); }
.bb-theme-dark .bb-card { background: rgba(237,227,214,.04); border-color: rgba(237,227,214,.12); }
.bb-theme-dark .bb-card:hover { box-shadow: 0 26px 54px rgba(0,0,0,.4); }

/* ===== Responsive layout grids (class hooks so inline styles stay fidelity) ===== */
.bb-grid { display: grid; }
.bb-hero-grid { grid-template-columns: 1.55fr .9fr; gap: clamp(32px,5vw,80px); align-items: center; }
.bb-two-col   { grid-template-columns: 1fr 1fr; gap: 28px; }
.bb-three-col { grid-template-columns: repeat(3,1fr); gap: 24px; }
.bb-reader-grid { grid-template-columns: 260px 1fr; gap: clamp(32px,5vw,72px); align-items: start; }
.bb-author-grid { grid-template-columns: .8fr 1.2fr; gap: clamp(32px,5vw,72px); align-items: center; }
.bb-collectors-grid { grid-template-columns: 1.25fr .85fr; gap: clamp(32px,5vw,72px); align-items: center; }
.bb-about-grid { grid-template-columns: 1fr .85fr; gap: clamp(32px,5vw,72px); align-items: center; }

/* ===== Collectors number grid ===== */
.bb-number-grid { display: grid; grid-template-columns: repeat(11,1fr); gap: 10px; }
.num-cell {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace; font-size: 14px; letter-spacing: .02em;
  transition: transform .3s, background .3s, color .3s; text-decoration: none;
}
.num-taken { background: rgba(237,227,214,.06); color: rgba(237,227,214,.28); text-decoration: line-through; }
.num-free  { background: rgba(198,118,63,.16); color: #E7B98A; border: 1px solid rgba(198,118,63,.4); cursor: pointer; }
.num-free:hover { transform: translateY(-4px); background: var(--accent); color: #211B14; }
.num-pending { background: rgba(198,118,63,.06); color: rgba(231,185,138,.55); border: 1px dashed rgba(198,118,63,.4); cursor: help; }

/* ===== Tooltip ===== */
.bb-tip { position: relative; }
.bb-tip::before,
.bb-tip::after {
  position: absolute; left: 50%; bottom: 100%;
  opacity: 0; pointer-events: none; z-index: 60;
  transition: opacity .28s ease, transform .28s cubic-bezier(.2,.8,.2,1);
}
.bb-tip::after {
  content: attr(data-tip);
  transform: translate(-50%, 6px); margin-bottom: 12px;
  width: max-content; max-width: 220px; white-space: normal;
  text-align: center; text-decoration: none; text-transform: none;
  background: var(--paper-card); color: var(--ink);
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; line-height: 1.5; letter-spacing: .01em;
  padding: 10px 14px; border-radius: 12px;
  border: 1px solid rgba(33,27,20,.12);
  box-shadow: 0 20px 44px rgba(0,0,0,.32);
}
.bb-tip::before {
  content: ''; transform: translate(-50%, 6px); margin-bottom: 1px;
  border: 7px solid transparent; border-top-color: var(--paper-card);
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.12));
}
.bb-tip:hover::before, .bb-tip:hover::after,
.bb-tip:focus-visible::before, .bb-tip:focus-visible::after {
  opacity: 1; transform: translate(-50%, 0);
}

/* ===== TOC ===== */
.toc-link { transition: color .3s; }
.toc-link.is-active { color: #211B14 !important; font-weight: 600; }
.bb-theme-dark .toc-link.is-active { color: #EDE3D6 !important; }

/* ===== Flash messages ===== */
.bb-flash {
  position: fixed; top: 84px; left: 50%; transform: translateX(-50%); z-index: 70;
  padding: 14px 26px; border-radius: 100px; font-size: 15px; font-weight: 500;
  box-shadow: 0 12px 30px rgba(33,27,20,.2); max-width: 90vw;
}
.bb-flash-success { background: #2f6b3f; color: #F3EEE6; }
.bb-flash-error   { background: #a33f2b; color: #F3EEE6; }

/* ===== Modal ===== */
.bb-modal {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px;
  opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s;
}
.bb-modal.is-open { opacity: 1; visibility: visible; }
.bb-modal__backdrop { position: absolute; inset: 0; background: rgba(20,15,9,.55); backdrop-filter: blur(5px); }
.bb-modal__card {
  position: relative; z-index: 1; width: min(420px, 100%);
  background: var(--paper-card); color: var(--ink);
  border: 1px solid rgba(33,27,20,.1); border-radius: 24px;
  padding: clamp(34px,5vw,46px); text-align: center;
  box-shadow: 0 40px 90px rgba(0,0,0,.42);
  transform: translateY(18px) scale(.94); opacity: 0;
  transition: transform .5s cubic-bezier(.2,.8,.2,1), opacity .5s;
}
.bb-modal.is-open .bb-modal__card { transform: none; opacity: 1; }
.bb-modal__icon {
  width: 76px; height: 76px; margin: 0 auto 24px; border-radius: 50%;
  display: grid; place-items: center; font-family: 'Alegreya', serif; font-weight: 800; font-size: 40px; line-height: 1;
  background: rgba(180,98,58,.12); color: var(--accent);
}
.bb-modal__card.is-error .bb-modal__icon { background: rgba(163,63,43,.12); color: #a33f2b; }
.bb-modal__title { font-family: 'Alegreya', serif; font-weight: 800; font-size: clamp(26px,4vw,32px); line-height: 1.05; margin: 0 0 12px; }
.bb-modal__msg { font-family: 'Spectral', serif; font-size: 17px; line-height: 1.6; color: var(--body); margin: 0 0 28px; }
.bb-modal__close { align-self: center; }

/* Animated checkmark */
.bb-check { width: 48px; height: 48px; }
.bb-check__circle { stroke-dasharray: 151; stroke-dashoffset: 151; }
.bb-check__tick { stroke-dasharray: 40; stroke-dashoffset: 40; }
.bb-modal.is-open .bb-check__circle { animation: bbDraw .55s cubic-bezier(.65,0,.45,1) forwards; }
.bb-modal.is-open .bb-check__tick { animation: bbDraw .35s .5s cubic-bezier(.65,0,.45,1) forwards; }
@keyframes bbDraw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .bb-check__circle, .bb-check__tick { stroke-dashoffset: 0; }
  .bb-modal__card { transition: opacity .3s; }
}

/* ===== Forms ===== */
.bb-input {
  width: 100%; background: rgba(33,27,20,.04); border: 1px solid rgba(33,27,20,.18);
  border-radius: 100px; padding: 16px 22px; color: var(--ink);
  font-family: 'Golos Text', sans-serif; font-size: 15px; outline: none; transition: border-color .3s;
}
.bb-input:focus { border-color: var(--accent); }
.bb-input.bb-input-area { border-radius: 20px; resize: vertical; min-height: 120px; }
.bb-theme-dark .bb-input { background: rgba(237,227,214,.06); border-color: rgba(237,227,214,.18); color: #EDE3D6; }

/* ===== Preloader (птицы, разлетающиеся из центра) ===== */
body.is-loading { overflow: hidden; }
.preloader {
  position: fixed; inset: 0;
  background:
    radial-gradient(120% 80% at 50% 42%, rgba(255,255,255,.55), rgba(255,255,255,0) 60%),
    linear-gradient(to bottom, var(--sky-top), var(--sky-bottom));
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}

/* Точка старта строго в центре экрана */
.flock { position: relative; width: 0; height: 0; }
.bird {
  position: absolute; left: 0; top: 0;
  transform-origin: center;
  animation: fly 2.8s cubic-bezier(.4,.02,.4,1) infinite;
  animation-delay: var(--delay, 0s); opacity: 0;
  will-change: transform, opacity;
}
.bird svg {
  display: block; width: 46px; height: 34px; margin: -17px 0 0 -23px;
  transform: rotate(var(--tilt, 0deg)) scaleX(var(--dir, 1));
  filter: drop-shadow(0 4px 5px rgba(60, 50, 40, .16));
}
.bird .body { fill: var(--bird); }
.bird .wing { fill: var(--bird); transform-box: fill-box; }
.bird .wing-left  { transform-origin: 100% 100%; }
.bird .wing-right { transform-origin: 0% 100%; }
.bird .wing-left  { animation: flapL .3s ease-in-out infinite alternate; animation-delay: var(--flap-delay, 0s); }
.bird .wing-right { animation: flapR .3s ease-in-out infinite alternate; animation-delay: var(--flap-delay, 0s); }

@keyframes fly {
  0%   { transform: translate(0, 0) scale(.35) rotate(var(--spin, 0deg)); opacity: 0; }
  14%  { opacity: 1; }
  78%  { opacity: 1; }
  100% { transform: translate(var(--fly-x), var(--fly-y)) scale(1.05); opacity: 0; }
}
@keyframes flapL { from { transform: rotate(-26deg); } to { transform: rotate(14deg); } }
@keyframes flapR { from { transform: rotate(26deg);  } to { transform: rotate(-14deg); } }

.bird:nth-child(1) { --fly-x: -46vw; --fly-y: -40vh; --tilt: -16deg; --dir: -1; --delay: 0s;   --flap-delay: 0s;   --spin: -8deg; }
.bird:nth-child(2) { --fly-x:  48vw; --fly-y: -36vh; --tilt: -12deg; --dir:  1; --delay: .16s; --flap-delay: .1s;  --spin:  8deg; }
.bird:nth-child(3) { --fly-x: -54vw; --fly-y:  -8vh; --tilt:  -4deg; --dir: -1; --delay: .3s;  --flap-delay: .05s; --spin: -4deg; }
.bird:nth-child(4) { --fly-x:  56vw; --fly-y:  -4vh; --tilt:  -4deg; --dir:  1; --delay: .1s;  --flap-delay: .14s; --spin:  4deg; }
.bird:nth-child(5) { --fly-x: -28vw; --fly-y: -48vh; --tilt: -24deg; --dir: -1; --delay: .44s; --flap-delay: .08s; --spin:-10deg; }
.bird:nth-child(6) { --fly-x:  26vw; --fly-y: -50vh; --tilt: -26deg; --dir:  1; --delay: .54s; --flap-delay: .12s; --spin: 10deg; }
.bird:nth-child(7) { --fly-x: -44vw; --fly-y:  24vh; --tilt:  12deg; --dir: -1; --delay: .24s; --flap-delay: .03s; --spin: -6deg; }
.bird:nth-child(8) { --fly-x:  44vw; --fly-y:  22vh; --tilt:  10deg; --dir:  1; --delay: .38s; --flap-delay: .09s; --spin:  6deg; }
.bird:nth-child(9) { --fly-x:   2vw; --fly-y: -54vh; --tilt:  -2deg; --dir:  1; --delay: .62s; --flap-delay: .06s; --spin:  0deg; }

/* Красивая индикация загрузки */
.pl-loader {
  position: absolute; bottom: 16vh; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.pl-text {
  color: var(--pl-text); font-family: Georgia, 'Times New Roman', serif;
  font-size: .95rem; letter-spacing: .42em; text-transform: uppercase; text-indent: .42em;
  animation: breathe 2.8s ease-in-out infinite;
}
.pl-bar {
  position: relative; display: block; width: 168px; height: 2px;
  background: rgba(74, 63, 53, .16); border-radius: 2px; overflow: hidden;
}
.pl-bar i {
  position: absolute; top: 0; left: 0; height: 100%; width: 40%;
  border-radius: 2px; background: linear-gradient(90deg, transparent, var(--bird), transparent);
  animation: plSlide 1.5s cubic-bezier(.65,.05,.35,1) infinite;
}
@keyframes breathe { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }
@keyframes plSlide { 0% { left: -45%; } 100% { left: 105%; } }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .bb-nav-links { display: none; }
  .bb-nav-util  { display: none; }
  .bb-burger    { display: flex; }
  .bb-hero-grid, .bb-two-col, .bb-three-col, .bb-reader-grid,
  .bb-author-grid, .bb-collectors-grid, .bb-about-grid { grid-template-columns: 1fr; }
  .bb-reader-toc { position: static !important; }
  .bb-hero-media { order: -1; max-width: 360px; }
  .bb-number-grid { grid-template-columns: repeat(6,1fr); }
}
@media (max-width: 520px) {
  .bb-number-grid { grid-template-columns: repeat(5,1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1 !important; transform: none !important; }
  .bird, .bird .wing, .pl-text, .pl-bar i { animation: none; }
  .bird { opacity: 1; transform: translate(calc(var(--fly-x) * .3), calc(var(--fly-y) * .3)); }
  .pl-bar i { left: 30%; width: 40%; }
  [style*="animation:bbFloat"], [style*="animation: bbFloat"] { animation: none !important; }
}
