/* ==========================================================
   Intent Gateway - mobile-first single input bar.
   Matches DreamerOS design system tokens from includes/styles.php.
   ASCII only. Spaced hyphens only. No em dashes.
   ========================================================== */

.gw-body { background: var(--bg); color: var(--ink); }

.gw-skip {
  position: absolute; left: -9999px; top: auto;
  width: 1px; height: 1px; overflow: hidden;
}
.gw-skip:focus {
  position: fixed; left: 12px; top: 12px;
  width: auto; height: auto; padding: 10px 14px;
  background: var(--bg-card); color: var(--ink);
  border: 1px solid var(--border-h); border-radius: 8px;
  z-index: 9999;
}

.gw-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.gw-main { min-height: 70vh; }
.gw-container { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px; }

.gw-hero {
  padding: clamp(28px, 6vw, 64px) 0 clamp(24px, 5vw, 56px);
  position: relative;
}

.gw-title {
  font-family: var(--fb, 'Outfit', system-ui, sans-serif);
  font-size: clamp(26px, 5.4vw, 44px);
  font-weight: 700; line-height: 1.12;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
  text-align: center;
}
.gw-sub {
  font-size: clamp(14px, 2.2vw, 17px);
  color: var(--ink-s);
  text-align: center;
  margin: 0 auto 24px;
  max-width: 560px;
  line-height: 1.55;
}

/* ============ INPUT BAR ============ */
.gw-bar {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.35), 0 0 30px rgba(139,92,246,0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.gw-bar:focus-within {
  border-color: var(--border-accent);
  box-shadow: 0 10px 40px rgba(0,0,0,0.45), 0 0 0 3px rgba(139,92,246,0.18);
}

.gw-bar-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px;
}

.gw-input {
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 16px; /* >=16px to prevent iOS zoom on focus */
  line-height: 1.5;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  padding: 10px 6px;
  width: 100%;
}
.gw-input::placeholder { color: var(--ink-f); }

.gw-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.gw-icon-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  padding: 0;
}
.gw-icon-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--border-h); }
.gw-icon-btn:focus-visible {
  outline: 2px solid var(--accent-light);
  outline-offset: 2px;
}
.gw-icon-btn:active { transform: scale(0.96); }
.gw-icon-btn svg { width: 20px; height: 20px; }

.gw-mic[aria-pressed="true"] {
  background: rgba(248,113,113,0.18);
  border-color: rgba(248,113,113,0.55);
  color: var(--red);
  animation: gwMicPulse 1.4s ease-in-out infinite;
}
@keyframes gwMicPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.45); }
  50% { box-shadow: 0 0 0 10px rgba(248,113,113,0); }
}

.gw-send {
  background: var(--grad-purple);
  border-color: transparent;
  color: #fff;
}
.gw-send:hover { filter: brightness(1.08); }

/* ============ RECORDING BAR ============ */
.gw-record-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--ink-s);
}
.gw-rec-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--red);
  animation: gwRecBlink 1s ease-in-out infinite;
}
@keyframes gwRecBlink { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.gw-wave {
  display: flex; align-items: center; gap: 3px;
  flex: 1; height: 24px;
}
.gw-wave span {
  display: block;
  width: 3px; min-height: 4px;
  background: linear-gradient(to top, var(--purple), var(--cyan));
  border-radius: 3px;
  animation: gwWave 0.9s ease-in-out infinite;
}
.gw-wave span:nth-child(1) { animation-delay: 0.00s; }
.gw-wave span:nth-child(2) { animation-delay: 0.08s; }
.gw-wave span:nth-child(3) { animation-delay: 0.16s; }
.gw-wave span:nth-child(4) { animation-delay: 0.24s; }
.gw-wave span:nth-child(5) { animation-delay: 0.32s; }
.gw-wave span:nth-child(6) { animation-delay: 0.40s; }
.gw-wave span:nth-child(7) { animation-delay: 0.48s; }
.gw-wave span:nth-child(8) { animation-delay: 0.56s; }
.gw-wave span:nth-child(9) { animation-delay: 0.64s; }
.gw-wave span:nth-child(10){ animation-delay: 0.72s; }
@keyframes gwWave {
  0%,100% { height: 6px; }
  50% { height: 22px; }
}
.gw-rec-timer {
  font-family: var(--fm, 'DM Mono', monospace);
  font-size: 12px;
  color: var(--ink-f);
  min-width: 36px;
  text-align: right;
}

/* ============ IMAGE PREVIEW ============ */
.gw-img-preview {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.gw-img-preview img {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.gw-img-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink-s);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.gw-img-clear:hover { border-color: var(--border-h); color: var(--ink); }

.gw-hint {
  font-size: 12px; color: var(--ink-f);
  text-align: center;
  margin: 10px 4px 4px;
  line-height: 1.5;
}

/* ============ OUTPUT PANEL ============ */
.gw-output {
  margin-top: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.gw-output-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}
.gw-output-label {
  font-family: var(--fm, 'DM Mono', monospace);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-f);
}
.gw-speaker {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; color: var(--ink-s);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.gw-speaker:hover { color: var(--ink); border-color: var(--border-h); }
.gw-speaker[aria-pressed="true"] {
  color: var(--accent-light);
  border-color: var(--border-accent);
  background: rgba(139,92,246,0.08);
}
.gw-speaker svg { width: 18px; height: 18px; }

.gw-output-body {
  padding: 16px 18px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  min-height: 84px;
}
.gw-output-empty { color: var(--ink-f); margin: 0; font-style: italic; }
.gw-output-body.is-loading::before {
  content: 'Thinking...';
  display: inline-block;
  color: var(--ink-f);
  font-family: var(--fm, 'DM Mono', monospace);
  font-size: 13px;
  letter-spacing: 0.04em;
  animation: gwDots 1.2s ease-in-out infinite;
}
@keyframes gwDots {
  0%,100% { opacity: 0.4; }
  50% { opacity: 1; }
}
.gw-output-body.is-error { color: var(--red); }

/* ============ PREFS ROW ============ */
.gw-prefs {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center;
  margin-top: 20px;
}
.gw-pref {
  background: rgba(255,255,255,0.03);
  color: var(--ink-s);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.gw-pref:hover { color: var(--ink); border-color: var(--border-h); }
.gw-pref[aria-pressed="true"] {
  background: rgba(139,92,246,0.12);
  color: var(--accent-light);
  border-color: var(--border-accent);
}

.gw-foot-note {
  text-align: center;
  font-size: 13px;
  color: var(--ink-f);
  margin: 20px 0 0;
  font-style: italic;
}

/* ============ HIGH CONTRAST ============ */
.gw-body.is-contrast {
  --ink: #ffffff;
  --ink-s: #f0f0f0;
  --ink-f: #d0d0d0;
  --bg: #000000;
  --bg-card: #0a0a0a;
  --border: rgba(255,255,255,0.45);
  --border-h: rgba(255,255,255,0.7);
}

/* ============ DYSLEXIC-FRIENDLY ============ */
.gw-body.is-dyslexic .gw-title,
.gw-body.is-dyslexic .gw-sub,
.gw-body.is-dyslexic .gw-input,
.gw-body.is-dyslexic .gw-output-body,
.gw-body.is-dyslexic .gw-hint {
  font-family: Verdana, Tahoma, 'Trebuchet MS', sans-serif;
  letter-spacing: 0.02em;
  word-spacing: 0.05em;
  line-height: 1.75;
}

/* ============ REDUCED MOTION ============ */
.gw-body.is-reduce-motion *,
.gw-body.is-reduce-motion *::before,
.gw-body.is-reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============ MOBILE (<= 640px) ============ */
@media (max-width: 640px) {
  .gw-container { padding: 0 12px; }
  .gw-hero { padding: 20px 0 32px; }
  .gw-title { font-size: 26px; text-align: left; }
  .gw-sub { text-align: left; margin-left: 0; font-size: 15px; }

  .gw-bar {
    margin: 0 -12px;
    border-radius: 18px 18px 0 0;
    border-left: 0; border-right: 0;
    padding: 6px;
  }
  .gw-bar-inner { gap: 6px; padding: 6px; }
  .gw-icon-btn { width: 48px; height: 48px; border-radius: 14px; }
  .gw-icon-btn svg { width: 22px; height: 22px; }
  .gw-input { font-size: 16px; padding: 12px 6px; }

  .gw-output { border-radius: 14px; }
  .gw-output-body { font-size: 16px; }
  .gw-hint { font-size: 12px; }
}

/* ============ VERY NARROW (<= 360px) ============ */
@media (max-width: 360px) {
  .gw-actions { gap: 4px; }
  .gw-icon-btn { width: 44px; height: 44px; }
}

/* ============ LIGHT MODE OVERRIDES (auto via system token) ============ */
@media (prefers-color-scheme: light) {
  .gw-body:not([data-theme="dark"]) .gw-bar { box-shadow: 0 6px 28px rgba(0,0,0,0.08); }
}
