/* =====================================================
   Stack Rush – style.css
   TypingWay | https://www.typingway.com/games/stack-rush
   Light modern theme · Dark-red accent · Mobile-first
   ===================================================== */

/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Palette */
  --clr-bg:          #f5f5f7;
  --clr-surface:     #ffffff;
  --clr-border:      #e0e0e5;
  --clr-primary:     #8b0000;   /* dark-red – main accent */
  --clr-primary-lt:  #b30000;
  --clr-primary-dk:  #600000;
  --clr-text:        #1a1a2e;
  --clr-text-muted:  #6b7280;
  --clr-hud-bg:      rgba(255,255,255,0.92);
  --clr-overlay-bg:  rgba(255,255,255,0.97);

  /* Block palette – vibrant gradient stops */
  --block-1: #e63946;
  --block-2: #f4a261;
  --block-3: #2a9d8f;
  --block-4: #457b9d;
  --block-5: #8b0000;
  --block-6: #6a0572;

  /* Typography */
  --font-ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;

  /* Dimensions */
  --canvas-w:  360px;
  --canvas-h:  540px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  /* Transitions */
  --ease-out:  cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--clr-bg);
  color: var(--clr-text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ── Site Header ──────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
  height: 60px;
  background: var(--clr-surface);
  border-bottom: 2px solid var(--clr-primary);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(139,0,0,0.08);
}

.site-logo {
  text-decoration: none;
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--clr-text);
}

.logo-accent {
  color: var(--clr-primary);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  color: var(--clr-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.site-nav a:hover,
.site-nav a[aria-current] {
  color: var(--clr-primary);
}

/* ── Breadcrumb ───────────────────────────────────── */
.breadcrumb {
  max-width: 800px;
  margin: 0.75rem auto 0;
  padding: 0 1rem;
}

.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  list-style: none;
  font-size: 0.8rem;
  color: var(--clr-text-muted);
}

.breadcrumb a {
  color: var(--clr-primary);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

/* ── Game Section ─────────────────────────────────── */
.game-section {
  padding: 0.5rem 1rem 2rem;
}

/* ── Game Wrapper ─────────────────────────────────── */
.game-wrapper {
  position: relative;
  width: var(--canvas-w);
  max-width: 100%;
  margin: 1rem auto 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(139,0,0,0.15),
    0 2px 8px rgba(0,0,0,0.08);
  background: #1a1a2e;  /* dark base behind canvas */
  /* shake animation target */
  transform-origin: center center;
}

/* Canvas fills wrapper width */
#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── HUD ──────────────────────────────────────────── */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: var(--clr-hud-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--clr-border);
  z-index: 10;
  pointer-events: none;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 60px;
}

.hud-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
}

.hud-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--clr-text);
  line-height: 1;
  transition: transform 0.15s var(--ease-out);
}

/* Combo HUD */
.combo-hud .hud-value {
  color: var(--clr-primary);
}

.combo-hud.combo-active .hud-value {
  transform: scale(1.15);
  color: var(--clr-primary-lt);
}

/* Pop animation on score change */
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.score-pop {
  animation: pop 0.25s var(--ease-out);
}

/* ── Overlay (Start / Game Over) ──────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  background: var(--clr-overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 20;
  padding: 2rem 1.5rem;
  transition: opacity 0.3s var(--ease-out);
}

.overlay.hidden {
  display: none;
}

.overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

/* Game logo on start screen */
.game-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(139,0,0,0.2);
}

.overlay-title {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 900;
  color: var(--clr-primary);
  letter-spacing: -0.5px;
  text-align: center;
  line-height: 1.1;
}

.overlay-subtitle {
  font-size: 0.95rem;
  color: var(--clr-text-muted);
  text-align: center;
  max-width: 260px;
}

.overlay-hint {
  font-size: 0.78rem;
  color: var(--clr-text-muted);
  letter-spacing: 0.05em;
  text-align: center;
  margin-top: 0.25rem;
}

/* ── Buttons ──────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 2.2rem;
  background: var(--clr-primary);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-ui);
  cursor: pointer;
  letter-spacing: 0.03em;
  transition:
    background 0.2s,
    transform 0.15s var(--ease-out),
    box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(139,0,0,0.35);
  min-width: 160px;
}

.btn-primary:hover {
  background: var(--clr-primary-lt);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(139,0,0,0.4);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(139,0,0,0.3);
}

/* ── Result Box (Game Over) ───────────────────────── */
.result-box {
  display: flex;
  gap: 2rem;
  background: var(--clr-bg);
  border: 1.5px solid var(--clr-border);
  border-radius: var(--radius-md);
  padding: 1rem 2rem;
}

.result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.result-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--clr-text-muted);
}

.result-value {
  font-size: 2rem;
  font-weight: 900;
  color: var(--clr-text);
  line-height: 1;
}

.new-best {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--clr-primary);
  background: rgba(139,0,0,0.08);
  border: 1.5px solid rgba(139,0,0,0.2);
  border-radius: 50px;
  padding: 0.4rem 1.2rem;
}

.new-best.hidden {
  display: none;
}

/* ── Shake animation ──────────────────────────────── */
@keyframes shake {
  0%   { transform: translate(0, 0)        rotate(0deg);   }
  15%  { transform: translate(-4px, 2px)   rotate(-0.5deg);}
  30%  { transform: translate(4px, -2px)   rotate(0.5deg); }
  45%  { transform: translate(-3px, 1px)   rotate(-0.3deg);}
  60%  { transform: translate(3px, -1px)   rotate(0.3deg); }
  75%  { transform: translate(-2px, 1px)   rotate(0deg);   }
  90%  { transform: translate(2px, 0px)    rotate(0deg);   }
  100% { transform: translate(0, 0)        rotate(0deg);   }
}

.shake {
  animation: shake 0.35s var(--ease-out);
}

/* ── Perfect floating text ────────────────────────── */
@keyframes floatUp {
  0%   { opacity: 1;   transform: translateY(0)   scale(1);    }
  70%  { opacity: 1;   transform: translateY(-40px) scale(1.1); }
  100% { opacity: 0;   transform: translateY(-60px) scale(0.9); }
}

.perfect-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateX(-50%);
  background: var(--clr-primary);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.35rem 1rem;
  border-radius: 50px;
  pointer-events: none;
  z-index: 30;
  animation: floatUp 0.9s var(--ease-out) forwards;
  white-space: nowrap;
}

/* ── SEO Content Section ──────────────────────────── */
.seo-content {
  max-width: 800px;
  margin: 3rem auto 0;
  padding: 0 1.25rem 4rem;
}

.seo-content h1 {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 900;
  color: var(--clr-primary);
  margin-bottom: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.4px;
}

.seo-content h2 {
  font-size: clamp(1.1rem, 3vw, 1.35rem);
  font-weight: 800;
  color: var(--clr-primary-dk);
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid rgba(139,0,0,0.15);
  letter-spacing: -0.2px;
}

.seo-content p {
  color: #374151;
  font-size: 0.97rem;
  line-height: 1.8;
  margin-bottom: 0.85rem;
}

.seo-content ul {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.seo-content li {
  padding-left: 1.4rem;
  position: relative;
  color: #374151;
  font-size: 0.96rem;
  line-height: 1.7;
}

.seo-content li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--clr-primary);
  font-size: 0.8em;
  top: 0.2em;
}

.seo-content strong {
  color: var(--clr-text);
  font-weight: 700;
}

.seo-content code {
  background: rgba(139,0,0,0.07);
  color: var(--clr-primary-dk);
  padding: 0.1em 0.45em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
}

/* ── Site Footer ──────────────────────────────────── */
.site-footer {
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.82rem;
  color: var(--clr-text-muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
}

.site-footer a {
  color: var(--clr-primary);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.site-footer nav {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

/* ── Responsive Breakpoints ───────────────────────── */
@media (max-width: 400px) {
  :root {
    --canvas-w: 100%;
  }

  .game-wrapper {
    border-radius: 0;
    box-shadow: none;
    margin-top: 0.5rem;
  }

  .hud-value {
    font-size: 1rem;
  }

  .result-box {
    gap: 1.5rem;
    padding: 0.85rem 1.5rem;
  }

  .result-value {
    font-size: 1.6rem;
  }
}

@media (min-width: 600px) {
  :root {
    --canvas-w: 400px;
    --canvas-h: 600px;
  }
}

@media (min-width: 900px) {
  :root {
    --canvas-w: 420px;
    --canvas-h: 620px;
  }

  .game-section {
    padding-bottom: 3rem;
  }
}

/* ── Focus styles for accessibility ──────────────── */
.btn-primary:focus-visible {
  outline: 3px solid var(--clr-primary);
  outline-offset: 4px;
}

button:focus-visible {
  outline: 3px solid var(--clr-primary);
  outline-offset: 3px;
}

/* ── Scrollbar style (WebKit) ─────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--clr-bg);
}

::-webkit-scrollbar-thumb {
  background: rgba(139,0,0,0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--clr-primary);
}
