/* css/focus-mode.css */
/* Focus Mode — slide settings/ad out, center the game, show hints */

:root {
  /* tweakable timing */
  --focus-transition: 320ms;
}

/* Smooth transitions for the three columns */
#ad-left,
.settings-panel,
.typing-panel {
  transition:
    width var(--focus-transition) ease,
    max-width var(--focus-transition) ease,
    margin var(--focus-transition) ease,
    padding var(--focus-transition) ease,
    border-color var(--focus-transition) ease,
    opacity var(--focus-transition) ease,
    transform var(--focus-transition) ease;
}

/* Start: normal layout already defined by your existing CSS */

/* Focus mode: center the game; remove gap for perfect centering */
body.focus-mode .container {
  gap: 0;                    /* no phantom spacing from flex gap */
  justify-content: center;   /* flex container centers lone child */
}

/* Slide the ad + settings out and collapse their width (NO display:none) */
body.focus-mode #ad-left,
body.focus-mode .settings-panel {
  transform: translateX(-40px);
  opacity: 0;
  width: 0 !important;
  max-width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  border-width: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
  pointer-events: none !important;
}

/* Let the typing area expand and animate into the center */
.typing-panel {
  position: relative; /* ← makes the pre-game hint anchor to the panel */
  transition:
    transform var(--focus-transition) ease,
    max-width var(--focus-transition) ease;
}


/* Center/limit the game; keep it animatable */
body.focus-mode .typing-panel {
  flex: 0 1 auto !important;      /* don't stretch edge-to-edge */
  width: auto;
  max-width: min(980px, 94vw);    /* desired max width */
  margin: 0 auto !important;      /* center horizontally */
  transform: none !important;     /* cancel any previous transforms */
}

/* Focus mode hints (top-left/top-right) */
.focus-hint {
  position: fixed;
  top: 12px;
  z-index: 50;
  padding: 0.35rem 0.6rem;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid var(--box-border);
  background: color-mix(in srgb, var(--box-bg) 85%, transparent);
  color: var(--correct-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none; /* purely informational */
}
.focus-hint.left  { left: 12px; }
.focus-hint.right { right: 12px; }

body.focus-mode .focus-hint {
  opacity: 0.92;
  transform: translateY(0);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  #ad-left,
  .settings-panel,
  .typing-panel,
  .focus-hint {
    transition: none !important;
  }
}

/* Hide the top ESC/TAB hints when the results overlay is up */
body.game-ended .focus-hint {
  display: none !important;
}

/* Transform fallback (when zoom isn't supported): center scaling nicely */
@supports not (zoom: 1) {
  .typing-panel > * { transform-origin: top center; }
}

:root{
  --ui-font: "Inter", ui-sans-serif, system-ui, -apple-system,
             "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Force the focus-mode corner hints to use the settings/UI font */
.typing-panel .focus-hint,
body.focus-mode .focus-hint,
body.focus-mode #hintEsc,
body.focus-mode #hintTab,
body.focus-mode #hintShiftTab {
  font-family: var(--ui-font) !important;
  font-weight: 800;          /* matches the settings pill look */
  letter-spacing: .02em;
  font-variant-ligatures: common-ligatures contextual;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* === Corner focus-hint responsive shrink (ESC/TAB) ===================== */
:root { --focus-hint-scale: 1; }

/* Step down as viewport height gets shorter */
@media (max-height: 900px) { :root { --focus-hint-scale: .95; } }
@media (max-height: 820px) { :root { --focus-hint-scale: .90; } }
@media (max-height: 740px) { :root { --focus-hint-scale: .85; } }
@media (max-height: 680px) { :root { --focus-hint-scale: .80; } }
@media (max-height: 620px) { :root { --focus-hint-scale: .75; } }
@media (max-height: 560px) { :root { --focus-hint-scale: .70; } }
@media (max-height: 500px) { :root { --focus-hint-scale: .66; } }
@media (max-height: 460px) { :root { --focus-hint-scale: .62; } }
@media (max-height: 420px) { :root { --focus-hint-scale: .58; } }
@media (max-height: 380px) { :root { --focus-hint-scale: .55; } }
@media (max-height: 340px) { :root { --focus-hint-scale: .52; } }

/* Apply the scale without moving them from the corners */
.focus-hint{
  font-size: calc(0.95rem * var(--focus-hint-scale)) !important;
  padding: calc(0.35rem * var(--focus-hint-scale))
           calc(0.60rem * var(--focus-hint-scale)) !important;
  border-radius: calc(8px * var(--focus-hint-scale)) !important;
  /* keep them in the corners; don't change top/left/right */
}

/* If your hint has a kbd-like chip inside, keep it scaled too */
.focus-hint kbd,
.focus-hint .key {
  font-size: 0.95em;
  padding: 0.1em 0.35em;
  border-radius: 0.4em;
}

/* Stack "SHIFT TAB" directly under the right-corner TAB hint */
:root { --focus-hint-stack-gap: 8px; }
/* Approx height of one hint row; respects your scaling var */
:root { --focus-hint-row: calc(40px * var(--focus-hint-scale)); }

#hintShiftTab {
  right: 12px;
  top: calc(12px + var(--focus-hint-row) + var(--focus-hint-stack-gap));
}

/* ===== Pre-game top-center hint INSIDE the typing panel ===== */

.typing-panel .pregame-hint{
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translate(-50%, -6px);
  z-index: 20; /* under the global fixed corner hints (z 50) */
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--box-border);
  background: color-mix(in srgb, var(--box-bg) 85%, transparent);
  color: var(--correct-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  font-family: var(--ui-font) !important;
  font-weight: 800;
  letter-spacing: .02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  opacity: 1;
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none; /* purely informational */
}

/* Scale with your existing focus-hint responsiveness */
.typing-panel .pregame-hint{
  font-size: calc(0.95rem * var(--focus-hint-scale)) !important;
  padding: calc(0.35rem * var(--focus-hint-scale))
           calc(0.60rem * var(--focus-hint-scale)) !important;
  border-radius: calc(8px * var(--focus-hint-scale)) !important;
}

/* Fade it away when a run starts (focus mode) or results are up */
body.focus-mode .typing-panel .pregame-hint,
body.game-ended .typing-panel .pregame-hint{
  opacity: 0;
  transform: translate(-50%, -12px);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce){
  .typing-panel .pregame-hint{ transition: none !important; }
}
