/* ==========================================================================
   Tenor Group — Captive Portal
   Pure monochrome. Montserrat self-hosted. CSS-only animation.
   ========================================================================== */

/* ---- Fonts ---- */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/montserrat-400-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/montserrat-400-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/montserrat-600-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/montserrat-600-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/montserrat-700-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/montserrat-700-vietnamese.woff2') format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}

/* ---- Tokens ---- */
:root {
  --bg: #0a0a0a;
  --fg: #f5f5f5;
  --fg-dim: #a0a0a0;
  --fg-faint: #666666;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --radius: 16px;
  --radius-sm: 12px;
  --blur: blur(20px);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  text-rendering: optimizeLegibility;
}

/* Radial gradient background (signature Tenor OS effect, monochrome) — animated breathing */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse at 15% 50%, rgba(50, 50, 50, 1) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 20%, rgba(30, 30, 30, 0.8) 0%, transparent 60%),
    #0a0a0a;
  pointer-events: none;
  animation: bg-drift 20s ease-in-out infinite alternate;
}

@keyframes bg-drift {
  0%   { background-position: 0% 0%, 100% 0%, 0 0; }
  50%  { background-position: 10% 10%, 90% 15%, 0 0; }
  100% { background-position: 5% 5%, 95% 5%, 0 0; }
}

/* Subtle grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='1'/></svg>");
  mix-blend-mode: overlay;
}

/* ---- Floating particles (ambient) ---- */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particles span {
  position: absolute;
  display: block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
  animation: particle-float 14s linear infinite;
  bottom: -10px;
}

.particles span:nth-child(1)  { left: 8%;  animation-duration: 18s; animation-delay: 0s;    width: 2px; height: 2px; }
.particles span:nth-child(2)  { left: 18%; animation-duration: 22s; animation-delay: 2s;    width: 4px; height: 4px; opacity: 0.6; }
.particles span:nth-child(3)  { left: 28%; animation-duration: 16s; animation-delay: 4s;    width: 2px; height: 2px; }
.particles span:nth-child(4)  { left: 38%; animation-duration: 20s; animation-delay: 1s;    width: 3px; height: 3px; opacity: 0.7; }
.particles span:nth-child(5)  { left: 48%; animation-duration: 25s; animation-delay: 6s;    width: 2px; height: 2px; }
.particles span:nth-child(6)  { left: 58%; animation-duration: 17s; animation-delay: 3s;    width: 4px; height: 4px; opacity: 0.5; }
.particles span:nth-child(7)  { left: 68%; animation-duration: 19s; animation-delay: 8s;    width: 3px; height: 3px; }
.particles span:nth-child(8)  { left: 78%; animation-duration: 23s; animation-delay: 5s;    width: 2px; height: 2px; opacity: 0.6; }
.particles span:nth-child(9)  { left: 88%; animation-duration: 21s; animation-delay: 7s;    width: 3px; height: 3px; }
.particles span:nth-child(10) { left: 95%; animation-duration: 15s; animation-delay: 10s;   width: 2px; height: 2px; opacity: 0.7; }

@keyframes particle-float {
  0%   { transform: translateY(0)     translateX(0);    opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-110vh) translateX(20px); opacity: 0; }
}

/* ---- Portal layout ---- */
.portal {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.stage {
  position: relative;
  width: min(420px, 100%);
  padding: 40px 32px;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  animation:
    stage-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both,
    stage-glow 5s ease-in-out 0.9s infinite;
  z-index: 1;
}

/* Rotating sheen border */
.stage::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from 0deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 15%,
    transparent 30%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  animation: sheen-rotate 8s linear infinite;
  opacity: 0.6;
  pointer-events: none;
}

@keyframes sheen-rotate {
  to { transform: rotate(360deg); }
}

@keyframes stage-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes stage-glow {
  0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 24px 0 rgba(255, 255, 255, 0.04); }
  50%      { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3), 0 0 48px 4px rgba(255, 255, 255, 0.08); }
}

/* ---- Logo ---- */
.logo {
  width: 92px;
  height: 92px;
  margin: 0 auto 28px;
  color: var(--fg);
  animation: logo-float 6s ease-in-out infinite;
  position: relative;
}

.logo::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 65%);
  animation: logo-halo 4s ease-in-out infinite;
  z-index: -1;
}

.logo svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 16px rgba(255, 255, 255, 0.15));
  animation: logo-pulse 3s ease-in-out infinite;
}

/* Draw-in animation for logo strokes on first load */
.logo .logo-t rect {
  animation: logo-pop 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.logo .logo-t rect:nth-child(1) { animation-delay: 0.4s; }
.logo .logo-t rect:nth-child(2) { animation-delay: 0.5s; }

.logo .logo-g path {
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  animation: logo-draw 1.2s cubic-bezier(0.22, 1, 0.36, 1) 0.6s forwards;
}
.logo .logo-g path:nth-child(2) { animation-delay: 1.4s; }

@keyframes logo-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes logo-pop {
  from { transform: scaleY(0); transform-origin: center; opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-6px) rotate(0.5deg); }
}

@keyframes logo-pulse {
  0%, 100% { filter: drop-shadow(0 2px 12px rgba(255, 255, 255, 0.10)); }
  50%      { filter: drop-shadow(0 2px 24px rgba(255, 255, 255, 0.25)); }
}

@keyframes logo-halo {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.15); }
}

/* ---- Brand ---- */
.brand {
  margin-bottom: 36px;
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin: 0 0 16px;
  color: var(--fg);
  background: linear-gradient(
    90deg,
    rgba(245, 245, 245, 0.7) 0%,
    #ffffff 50%,
    rgba(245, 245, 245, 0.7) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  animation:
    text-reveal 0.8s ease 0.8s both,
    text-shine 6s ease-in-out 2s infinite;
}

.tagline, .tagline-en {
  animation: text-reveal 0.6s ease both;
}

.tagline {
  font-size: 15px;
  font-weight: 500;
  color: var(--fg);
  margin: 0 0 4px;
  animation-delay: 1s;
}

.tagline-en {
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-dim);
  margin: 0;
  letter-spacing: 0.02em;
  animation-delay: 1.15s;
}

@keyframes text-reveal {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes text-shine {
  0%, 100% { background-position: -100% 0; }
  50%      { background-position: 200%  0; }
}

/* ---- Agree button ---- */
.agree {
  position: relative;
  width: 100%;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--bg);
  background: var(--fg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
  margin-bottom: 20px;
  opacity: 0;
  animation:
    text-reveal 0.6s ease 1.3s forwards,
    btn-pulse 2.8s ease-in-out 2s infinite;
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.25); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 255, 255, 0); }
}

.agree::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transform: translateX(-100%);
  transition: transform 0.8s ease;
}

.agree:hover {
  background: #ffffff;
  box-shadow: 0 4px 24px rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.agree:hover::before {
  transform: translateX(100%);
}

.agree:active {
  transform: translateY(0) scale(0.98);
}

.agree:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

.agree .arrow {
  display: inline-flex;
  transition: transform 0.3s ease;
}

.agree:hover .arrow {
  transform: translateX(3px);
}

/* Disabled state during connecting */
.agree[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ---- Terms ---- */
.terms {
  font-size: 11px;
  font-weight: 400;
  color: var(--fg-faint);
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1.6;
  animation: text-reveal 0.6s ease 1.5s both;
}

.terms a {
  color: var(--fg-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--border-strong);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.terms a:hover {
  color: var(--fg);
  border-bottom-color: var(--fg);
}

/* ---- Connecting state ---- */
.connecting {
  width: min(420px, 100%);
  padding: 40px 32px;
  border-radius: var(--radius);
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  text-align: center;
  animation: stage-in 0.4s ease both;
}

.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 20px;
  border: 2px solid var(--border);
  border-top-color: var(--fg);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.connecting p {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-dim);
  margin: 0;
  letter-spacing: 0.04em;
}

/* Fade out stage when entering connecting */
.stage[data-state="leaving"] {
  animation: stage-out 0.4s ease forwards;
  pointer-events: none;
}

@keyframes stage-out {
  to {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
    filter: blur(4px);
  }
}

/* ---- Footer ---- */
.foot {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--fg-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.foot .sep {
  margin: 0 8px;
  color: var(--fg-faint);
  opacity: 0.5;
}

.foot a {
  color: var(--fg-faint);
  text-decoration: none;
  transition: color 0.2s ease;
}

.foot a:hover {
  color: var(--fg-dim);
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .portal { padding: 16px; }
  .stage { padding: 32px 24px; }
  .logo { width: 80px; height: 80px; }
  .brand h1 { font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
