/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --red: #ff0019;
  --red-dark: #b30010;
  --white: #ffffff;
  --muted: rgba(255,255,255,0.68);
  --muted-2: rgba(255,255,255,0.42);
  --border: rgba(255,255,255,0.12);
  --card: rgba(255,255,255,0.06);

  --yfl-bg:
    radial-gradient(circle at 76% 25%, rgba(255, 0, 25, 0.16), transparent 24%),
    radial-gradient(circle at 30% 100%, rgba(160, 0, 12, 0.17), transparent 32%),
    linear-gradient(145deg, #050505 0%, #090909 48%, #020202 100%);
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  background: #020202;
}

body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--yfl-bg);
  background-color: #020202;
  color: white;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   BACKGROUND LAYER
   ============================================================ */
.viewport-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--yfl-bg);
  background-color: #020202;
}

.viewport-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(125deg, transparent 0%, transparent 36%, rgba(255,0,25,0.12) 37%, transparent 40%),
    linear-gradient(125deg, transparent 0%, transparent 47%, rgba(255,0,25,0.07) 48%, transparent 50%),
    linear-gradient(125deg, transparent 0%, transparent 56%, rgba(255,255,255,0.035) 57%, transparent 59%);
  opacity: 0.7;
}

/* ============================================================
   APP SHELL — mobile-first, full-height column
   ============================================================ */
.app {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding:
    max(20px, env(safe-area-inset-top))
    clamp(16px, 5vw, 24px)
    max(16px, env(safe-area-inset-bottom));
}

/* ============================================================
   BRAND / LOGO — takes all remaining vertical space on mobile
   ============================================================ */
.brand {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 430px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: brandIntro 0.75s cubic-bezier(.22,.9,.26,1) both;
}

@keyframes brandIntro {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.logo-img {
  width: clamp(220px, 76vw, 380px);
  max-height: clamp(200px, 46svh, 360px);
  object-fit: contain;
  display: block;
  filter:
    drop-shadow(0 22px 42px rgba(0,0,0,0.46))
    drop-shadow(0 0 14px rgba(255,0,25,0.08));
  animation: logoFloat 5.5s ease-in-out infinite;
  will-change: transform;
}

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

/* ============================================================
   BOTTOM ACTIONS — pinned to bottom on mobile
   ============================================================ */
.bottom-actions {
  width: 100%;
  max-width: 430px;
  flex-shrink: 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  animation: actionsIntro 0.7s cubic-bezier(.22,.9,.26,1) 0.12s both;
}

@keyframes actionsIntro {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0);    }
}

.actions {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 50px;
  border-radius: 16px;
  border: none;
  outline: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: white;
  transition:
    transform 0.18s cubic-bezier(.22,.9,.26,1),
    box-shadow 0.22s ease,
    filter 0.22s ease,
    opacity 0.22s ease;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  box-shadow:
    0 18px 38px rgba(255, 0, 25, 0.24),
    inset 0 1px 0 rgba(255,255,255,0.18);
}

.btn-secondary {
  background: transparent;
  border: 1px solid rgba(255, 0, 25, 0.68);
}

@media (hover: hover) and (pointer: fine) {
  body:not(.touch-device) .btn:hover      { filter: brightness(1.07); }
  body:not(.touch-device) .guest:hover    { color: white; background: rgba(255,255,255,0.04); }
}

.btn.pressing  { transform: scale(0.965); filter: brightness(0.94); }
.btn.released  { animation: softRelease 0.22s cubic-bezier(.22,.9,.26,1); }

@keyframes softRelease {
  0%   { transform: scale(0.965); }
  65%  { transform: scale(1.012); }
  100% { transform: scale(1);     }
}

.btn .ripple {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes ripple {
  to { transform: translate(-50%, -50%) scale(16); opacity: 0; }
}

/* ============================================================
   GUEST LINK
   ============================================================ */
.guest {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  cursor: pointer;
  padding: 10px 0;
  border-radius: 14px;
  transition:
    transform 0.18s cubic-bezier(.22,.9,.26,1),
    color 0.22s ease,
    background 0.22s ease;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  will-change: transform;
}

.guest.pressing { transform: scale(0.97); color: var(--red); background: rgba(255,0,25,0.07); }
.guest.released { animation: softTextRelease 0.2s cubic-bezier(.22,.9,.26,1); }

@keyframes softTextRelease {
  0%   { transform: scale(0.97);  }
  70%  { transform: scale(1.012); }
  100% { transform: scale(1);     }
}

/* ============================================================
   MODAL — fixed overlay, anchors sheet to bottom on mobile
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  /* NO min-height — inset:0 already constrains all 4 sides */
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  background: rgba(0,0,0,0.52);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  /* top padding ensures sheet never covers the full screen */
  padding:
    max(60px, calc(env(safe-area-inset-top) + 44px))
    14px
    max(14px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal.active {
  display: flex;
  animation: fadeIn 0.22s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   SHEET — bottom sheet card, constrained so it never overflows
   ============================================================ */
.sheet {
  width: 100%;
  max-width: 430px;
  /* Prevent sheet from overflowing viewport */
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 1;
  border-radius: 30px;
  background: rgba(10,10,10,0.92);
  border: 1px solid var(--border);
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  animation: sheetUp 0.28s cubic-bezier(.22,.9,.26,1) both;
}

@keyframes sheetUp {
  from { opacity: 0; transform: translateY(22px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)    scale(1);     }
}

.popup-logo-box {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -50px 0 -40px;
  padding: 0;
}

.popup-logo {
  width: min(100%, 1260px);
  max-height: 220px;
  object-fit: contain;
  display: block;
  filter:
    drop-shadow(0 18px 38px rgba(0,0,0,0.42))
    drop-shadow(0 0 14px rgba(255,0,25,0.1));
}

.sheet h2 {
  font-size: clamp(20px, 5.5vw, 26px);
  line-height: 1.15;
  letter-spacing: -0.6px;
  margin-bottom: 10px;
}

.sheet p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 18px;
}

.mini-info {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.domain-name {
  color: white;
  font-weight: 600;
}

.sheet-note {
  color: var(--muted-2);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 12px;
  text-align: center;
}

#modalLegal { font-size: 12px; }

/* ============================================================
   RESPONSIVE — compact phones (small height)
   ============================================================ */
@media (max-height: 680px) and (max-width: 639px) {
  .logo-img {
    width: clamp(180px, 64vw, 280px);
    max-height: 34svh;
  }

  .btn {
    height: 46px;
    font-size: 13px;
    border-radius: 14px;
  }

  .actions { gap: 10px; margin-bottom: 8px; }
  .guest   { padding: 7px 0; }

  .popup-logo-box { margin: -28px 0 -22px; }
  .popup-logo     { max-height: 130px; }
  .sheet          { padding: 20px; border-radius: 24px; }
  .sheet h2       { font-size: 19px; }
  .sheet p        { font-size: 14px; margin-bottom: 14px; }
  .mini-info      { padding: 12px; margin-bottom: 14px; }
}

/* ============================================================
   RESPONSIVE — narrow phones
   ============================================================ */
@media (max-width: 374px) {
  .logo-img {
    width: clamp(200px, 72vw, 280px);
  }

  .btn      { height: 46px; font-size: 13px; border-radius: 14px; }
  .sheet    { padding: 18px; border-radius: 24px; }
}

/* ============================================================
   RESPONSIVE — tablet  (≥ 640px)
   Buttons stay visible: logo + actions grouped and centred
   ============================================================ */
@media (min-width: 640px) {
  .app {
    justify-content: center;
    gap: clamp(28px, 4vh, 52px);
    padding:
      max(32px, env(safe-area-inset-top))
      clamp(32px, 6vw, 64px)
      max(32px, env(safe-area-inset-bottom));
  }

  /* Logo no longer needs to flex-grow — centred group instead */
  .brand {
    flex: none;
  }

  .logo-img {
    width: clamp(260px, 38vw, 460px);
    max-height: clamp(240px, 42svh, 440px);
  }

  /* Actions area sits naturally below the logo */
  .bottom-actions {
    padding-bottom: 0;
    max-width: 380px;
    width: 100%;
  }

  /* Sheet centred, not bottom-anchored */
  .modal {
    justify-content: center;
    padding:
      max(32px, env(safe-area-inset-top))
      24px
      max(32px, env(safe-area-inset-bottom));
  }

  .sheet {
    max-width: 480px;
    border-radius: 32px;
  }
}

/* ============================================================
   RESPONSIVE — desktop  (≥ 1024px)
   Split layout: logo left, actions right
   ============================================================ */
@media (min-width: 1024px) {
  .app {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: clamp(48px, 6vw, 100px);
    padding:
      max(48px, env(safe-area-inset-top))
      clamp(60px, 8vw, 120px)
      max(48px, env(safe-area-inset-bottom));
  }

  .brand {
    flex: 1 1 auto;
    max-width: 560px;
    justify-content: flex-end;
    animation-delay: 0s;
  }

  .logo-img {
    width: clamp(320px, 32vw, 560px);
    max-height: 68svh;
  }

  .bottom-actions {
    flex: 0 0 auto;
    width: clamp(280px, 28vw, 380px);
    max-width: 380px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-bottom: 0;
  }

  .actions { gap: 14px; margin-bottom: 14px; }

  .btn { height: 52px; font-size: 15px; border-radius: 17px; }

  .guest { font-size: 15px; }

  .modal {
    padding:
      max(48px, env(safe-area-inset-top))
      32px
      max(48px, env(safe-area-inset-bottom));
  }

  .sheet { max-width: 520px; }
}

/* ============================================================
   RESPONSIVE — wide desktop  (≥ 1440px)
   ============================================================ */
@media (min-width: 1440px) {
  .brand      { max-width: 680px; }
  .logo-img   { width: clamp(400px, 30vw, 660px); }
  .bottom-actions { width: 400px; max-width: 400px; }
  .app        { gap: clamp(80px, 7vw, 140px); }
}

/* ============================================================
   ACCESSIBILITY — reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
