/* =============================================================
   V26 — Android Boot Sequence
   Palette: #0a0a0a bg | #00ff41 terminal green | #e0ffe0 text
   Fonts: Fira Code (logs) | Roboto Mono (system labels)
   Mobile-first, WCAG AA contrast ≥ 4.5:1
   ============================================================= */

/* ---------- Custom properties ---------- */
:root {
  --green:       #00ff41;
  --green-dim:   #00cc33;
  --green-faint: #003a0f;
  --bg:          #0a0a0a;
  --surface:     #0f150f;
  --text:        #e0ffe0;
  --text-dim:    #7ab87a;
  --white:       #ffffff;

  --font-log:    'Fira Code', 'Courier New', monospace;
  --font-sys:    'Roboto Mono', 'Courier New', monospace;

  --radius:      4px;
  --transition:  0.3s ease;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
}

body {
  min-height: 100dvh;
  font-family: var(--font-log);
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

/* ---------- Screen-reader only helper ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- CRT scanline overlay ---------- */
.scanline-overlay {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 65, 0.015) 2px,
    rgba(0, 255, 65, 0.015) 4px
  );
  pointer-events: none;
  z-index: 100;
  animation: scanlines 8s linear infinite;
}

@keyframes scanlines {
  0%   { background-position: 0 0; }
  100% { background-position: 0 100px; }
}

/* ---------- Boot screen layout ---------- */
.boot-screen {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
  padding: 20px 16px 24px;
  max-width: 860px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
.boot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--green-faint);
}

.boot-version {
  font-family: var(--font-sys);
  font-weight: 700;
  font-size: clamp(0.75rem, 3vw, 0.9rem);
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.boot-version .accent {
  color: var(--green);
}

/* ---------- CSS border spinner ---------- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--green-faint);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Spinner hidden once boot completes */
.spinner.done {
  animation: none;
  border-top-color: var(--green-faint);
  opacity: 0.3;
}

/* ---------- Boot log ---------- */
.boot-log {
  flex: 1 1 auto;
  /* Constrain height on tall viewports; JS auto-scrolls */
  max-height: clamp(220px, 45dvh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--green-faint) transparent;
  padding-right: 4px;
}

.boot-log::-webkit-scrollbar {
  width: 4px;
}

.boot-log::-webkit-scrollbar-thumb {
  background: var(--green-faint);
  border-radius: 2px;
}

/* ---------- Individual log line ---------- */
.log-line {
  display: block;
  font-family: var(--font-log);
  font-size: clamp(0.7rem, 2.5vw, 0.82rem);
  line-height: 1.6;
  color: var(--text);
  white-space: pre;              /* preserve spacing/alignment */
  overflow: hidden;
  /* Typewriter: width animates from 0 to 100% in discrete steps */
  width: 0;
  animation: typewriter var(--type-dur, 0.4s) steps(var(--char-count, 40), end) forwards;
}

/* Timestamp portion in dimmer green */
.log-line .ts {
  color: var(--text-dim);
}

/* [OK] tag in bright green */
.log-line .ok {
  color: var(--green);
  font-weight: 700;
}

/* [WARN] tag in amber — keeps contrast */
.log-line .warn {
  color: #ffcc00;
}

/* [ERR] tag in red */
.log-line .err {
  color: #ff4444;
}

/* Blinking cursor on the most-recent incomplete line */
.log-line.typing::after {
  content: '|';
  color: var(--green);
  animation: blink-cursor 0.7s step-end infinite;
}

/* Remove cursor once line is done */
.log-line.typed::after {
  content: none;
}

@keyframes typewriter {
  from { width: 0; }
  to   { width: 100%; }
}

@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ---------- Progress section ---------- */
.progress-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.progress-bar {
  flex: 1;
  height: 14px;
  background: var(--green-faint);
  border: 1px solid var(--green-dim);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

/* Animated gradient shimmer on fill */
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(
    90deg,
    var(--green-dim) 0%,
    var(--green) 50%,
    var(--green-dim) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--radius);
  transition: width 0.35s ease-out;
  animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.progress-text {
  font-family: var(--font-sys);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--green);
  min-width: 46px;
  text-align: right;
  letter-spacing: 0.05em;
}

/* ---------- System ready panel ---------- */
.system-ready {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border: 1px solid var(--green);
  border-radius: var(--radius);
  background: rgba(0, 255, 65, 0.04);
  box-shadow:
    0 0 20px rgba(0, 255, 65, 0.12),
    inset 0 0 20px rgba(0, 255, 65, 0.03);
  text-align: center;
  /* Hidden until JS adds .visible */
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}

.system-ready.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Hide from assistive tech until visible */
.system-ready[aria-hidden="true"] {
  visibility: hidden;
}

.system-ready[aria-hidden="false"] {
  visibility: visible;
}

.system-ready-title {
  font-family: var(--font-sys);
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.2em;
  text-shadow:
    0 0 10px rgba(0, 255, 65, 0.8),
    0 0 30px rgba(0, 255, 65, 0.4);
  /* Pulsing glow once visible */
  animation: ready-glow 2s ease-in-out infinite;
}

@keyframes ready-glow {
  0%, 100% { text-shadow: 0 0 10px rgba(0, 255, 65, 0.8), 0 0 30px rgba(0, 255, 65, 0.4); }
  50%       { text-shadow: 0 0 20px rgba(0, 255, 65, 1),   0 0 60px rgba(0, 255, 65, 0.6); }
}

.system-ready-sub {
  font-family: var(--font-log);
  font-size: clamp(0.7rem, 2.5vw, 0.85rem);
  color: var(--text-dim);
  letter-spacing: 0.15em;
}

/* ---------- Enter button — min 44px touch target ---------- */
.enter-btn {
  margin-top: 8px;
  padding: 14px 36px;
  min-height: 48px;               /* touch target ≥ 44px */
  min-width: 200px;
  font-family: var(--font-sys);
  font-size: clamp(0.85rem, 3vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--bg);
  background: var(--green);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background var(--transition), box-shadow var(--transition), transform 0.1s ease;
  /* Subtle progress-dots suffix animated via ::after */
}

.enter-btn::before {
  /* Hover sweep */
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  transform: translateX(-110%) skewX(-15deg);
  transition: transform 0.4s ease;
}

.enter-btn:hover::before,
.enter-btn:focus-visible::before {
  transform: translateX(110%) skewX(-15deg);
}

.enter-btn:hover,
.enter-btn:focus-visible {
  background: var(--white);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.6);
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.enter-btn:active {
  transform: scale(0.97);
}

/* Loading dots on button while redirecting */
.enter-btn.loading {
  background: var(--green-dim);
  cursor: not-allowed;
  pointer-events: none;
}

.enter-btn.loading::after {
  content: '...';
  /* CSS-only cycling dots using animation */
  display: inline-block;
  overflow: hidden;
  width: 0;
  vertical-align: bottom;
  animation: dots-cycle 1s steps(4, end) infinite;
}

@keyframes dots-cycle {
  0%   { width: 0; }
  25%  { width: 0.6em; }
  50%  { width: 1.2em; }
  75%  { width: 1.8em; }
  100% { width: 0; }
}

/* ---------- Responsive tweaks ---------- */
@media (min-width: 480px) {
  .boot-screen {
    padding: 28px 24px;
    gap: 20px;
  }
}

@media (min-width: 768px) {
  .boot-screen {
    padding: 40px 32px;
    gap: 24px;
  }

  .boot-log {
    max-height: 50dvh;
  }

  .log-line {
    font-size: 0.88rem;
  }
}

/* ---------- Reduced-motion: disable all animations ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  /* Force log lines to full width immediately */
  .log-line {
    width: 100% !important;
  }

  /* Keep spinner visible but static */
  .spinner {
    border-top-color: var(--green);
  }
}
