/* =====================================================
   ORI extras: emotions, palette, warp transition,
   takeover, pings, theme toggle, scanline wipes
   ===================================================== */

/* ===== ORI emotions (color tints / animations) ===== */
.ori { transition: filter 0.5s ease; will-change: transform, filter; }
.ori.em-idle .ori-core { background: radial-gradient(circle at 35% 35%, #b6f0ff, #4ad6ff 35%, #2a7eff 70%, #0c2a6b 100%); }
.ori.em-thinking { filter: hue-rotate(-20deg) brightness(0.95); }
.ori.em-thinking .ori-ring,
.ori.em-thinking .ori-ring.r2,
.ori.em-thinking .ori-ring.r3 { animation-duration: 12s !important; opacity: 0.6 !important; }
.ori.em-excited { filter: hue-rotate(15deg) brightness(1.25) saturate(1.4); }
.ori.em-excited .ori-core { animation: oriExcitePulse 0.7s ease-in-out infinite; }
.ori.em-warning { filter: hue-rotate(180deg) saturate(1.5) brightness(1.1); }
.ori.em-warning .ori-core { animation: oriWarn 0.8s ease-in-out infinite; }
.ori.em-happy { filter: hue-rotate(-50deg) brightness(1.3) saturate(1.5); }
.ori.em-happy .ori-core {
  background: radial-gradient(circle at 35% 35%, #fff7c8, #ffd24a 35%, #ff8a4a 70%, #6b2a0c 100%);
  animation: oriHappyBob 0.5s ease-in-out infinite alternate;
}

@keyframes oriExcitePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
@keyframes oriWarn {
  0%, 100% { box-shadow: 0 0 30px #ff4a6b, 0 0 60px #ff4a6b; }
  50% { box-shadow: 0 0 18px #ff4a6b, 0 0 30px #ff4a6b; }
}
@keyframes oriHappyBob {
  0% { transform: scale(1.05) rotate(-3deg); }
  100% { transform: scale(1.15) rotate(3deg); }
}

/* Tooltip positioning: ORI is on the RIGHT, so tooltip opens to the LEFT by default.
   Override the original .ori-tooltip { right: ... } from styles.css */
.ori-tooltip {
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
}
.ori-tooltip.pos-left {
  right: 100% !important;
  left: auto !important;
  top: 50% !important;
  bottom: auto !important;
  transform: translate(-12px, -50%) !important;
  margin-right: 16px;
}
.ori-tooltip.pos-right {
  left: 100% !important;
  right: auto !important;
  top: 50% !important;
  bottom: auto !important;
  transform: translate(12px, -50%) !important;
  margin-left: 16px;
}
.ori-tooltip.pos-top {
  bottom: 100% !important;
  top: auto !important;
  left: 50% !important;
  right: auto !important;
  transform: translate(-50%, -12px) !important;
  margin-bottom: 14px;
}
.ori-tooltip.pos-bottom {
  top: 100% !important;
  bottom: auto !important;
  left: 50% !important;
  right: auto !important;
  transform: translate(-50%, 12px) !important;
  margin-top: 14px;
}
.ori-tooltip.show {
  /* lock translate values that match position */
  opacity: 1 !important;
}
.ori-tooltip {
  max-width: 320px !important;
  width: max-content;
  white-space: normal !important;
  line-height: 1.45;
  font-size: 13px;
  padding: 14px 18px !important;
}

/* Click ping */
.ori-click-ping {
  position: fixed;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--cyan, #4ad6ff);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(0.6);
  animation: clickPing 0.9s ease-out forwards;
}
@keyframes clickPing {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(4); opacity: 0; }
}

/* Conjure burst (when ORI produces something) */
.conjure-burst {
  position: fixed;
  pointer-events: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff, #4ad6ff 40%, transparent 70%);
  transform: translate(-50%, -50%);
  z-index: 9998;
  animation: conjureBurst 0.9s ease-out forwards;
  box-shadow: 0 0 30px #4ad6ff, 0 0 60px #4ad6ff;
}
@keyframes conjureBurst {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(8); opacity: 0; }
}
.conjure-ring {
  position: fixed;
  pointer-events: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid #ffd24a;
  transform: translate(-50%, -50%);
  z-index: 9998;
  animation: conjureRing 1.2s ease-out forwards;
}
@keyframes conjureRing {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; border-width: 3px; }
  100% { transform: translate(-50%, -50%) scale(12); opacity: 0; border-width: 1px; }
}

/* ===== Slash command palette ===== */
.ori-cmd {
  position: fixed; inset: 0;
  background: rgba(4, 8, 22, 0.85);
  backdrop-filter: blur(16px);
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  font-family: 'JetBrains Mono', monospace;
}
.ori-cmd.open { display: flex; animation: cmdFadeIn 0.25s ease-out; }
@keyframes cmdFadeIn { from { opacity: 0; } to { opacity: 1; } }
.ori-cmd-inner {
  width: min(620px, 92vw);
  background: linear-gradient(180deg, rgba(10, 18, 40, 0.96), rgba(4, 8, 22, 0.98));
  border: 1px solid rgba(74, 214, 255, 0.35);
  border-radius: 16px;
  box-shadow: 0 0 80px rgba(74, 214, 255, 0.18), 0 30px 80px rgba(0, 0, 0, 0.6);
  padding: 22px;
  position: relative;
}
.ori-cmd-inner::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 16px;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(74, 214, 255, 0.04));
}
.ori-cmd-prompt {
  color: #4ad6ff;
  font-size: 11px;
  letter-spacing: 0.3em;
  margin-bottom: 12px;
  opacity: 0.7;
}
.ori-cmd-input {
  width: 100%;
  background: transparent;
  border: 0;
  outline: 0;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  padding: 8px 0 14px;
  border-bottom: 1px solid rgba(74, 214, 255, 0.25);
  letter-spacing: 0.04em;
}
.ori-cmd-input::placeholder { color: rgba(255,255,255,0.3); }
.ori-cmd-list {
  margin-top: 14px;
  max-height: 50vh;
  overflow-y: auto;
}
.ori-cmd-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, transform 0.15s;
}
.ori-cmd-item:hover {
  background: rgba(74, 214, 255, 0.1);
  transform: translateX(4px);
}
.ori-cmd-item .n {
  color: #4ad6ff;
  font-weight: 500;
}
.ori-cmd-item .d {
  color: rgba(255,255,255,0.55);
  font-size: 12px;
}

/* ===== Warp transition between pages ===== */
.warp-overlay {
  position: fixed; inset: 0;
  z-index: 99999;
  background: #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.warp-overlay.go { opacity: 1; }
.warp-tunnel {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%,
    rgba(74,214,255,0.4) 0%,
    rgba(120,90,255,0.3) 30%,
    rgba(0,0,0,1) 70%);
  animation: warpTunnel 0.7s ease-in forwards;
}
@keyframes warpTunnel {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.5); opacity: 1; }
  100% { transform: scale(6); opacity: 0; }
}
.warp-streaks {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0, transparent 6px, rgba(74,214,255,0.6) 6px, rgba(74,214,255,0.6) 7px),
    repeating-linear-gradient(90deg, transparent 0, transparent 12px, rgba(120,90,255,0.4) 12px, rgba(120,90,255,0.4) 13px);
  mix-blend-mode: screen;
  animation: warpStreaks 0.7s linear forwards;
  opacity: 0;
}
@keyframes warpStreaks {
  0% { transform: scale(0.5); opacity: 0; }
  40% { opacity: 0.9; }
  100% { transform: scale(2.4); opacity: 0; }
}
.warp-ori {
  position: absolute;
  width: 80px; height: 80px;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #4ad6ff 40%, #1f4adf 80%);
  box-shadow: 0 0 80px #4ad6ff, 0 0 200px #4ad6ff;
  animation: warpOri 0.7s ease-out forwards;
}
@keyframes warpOri {
  0% { transform: translate(-50%, -50%) scale(0); }
  60% { transform: translate(-50%, -50%) scale(1.2); }
  100% { transform: translate(calc(100vw + 100px), -50%) scale(0.4); }
}

/* ===== ORI takeover (Konami) ===== */
.ori-takeover {
  animation: takeoverShake 0.2s ease-in-out infinite;
}
.ori-takeover::before {
  content: 'XPLOREMINDS // SYSTEM TAKEOVER';
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8vw;
  font-weight: 700;
  color: rgba(74,214,255,0.15);
  pointer-events: none;
  z-index: 9000;
  text-shadow: 0 0 40px rgba(74,214,255,0.5);
  letter-spacing: 0.1em;
  animation: takeoverText 4.5s ease-in-out forwards;
}
@keyframes takeoverShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2px, 1px); }
  75% { transform: translate(2px, -1px); }
}
@keyframes takeoverText {
  0% { opacity: 0; transform: scale(0.8); }
  20%, 70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1); }
}

/* ===== Hero boot sequence ===== */
.boot-sequence {
  position: fixed; inset: 0;
  background: #000;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  color: #4ad6ff;
  font-size: 13px;
  transition: opacity 0.6s ease;
}
.boot-sequence.fade { opacity: 0; pointer-events: none; }
.boot-inner {
  width: min(560px, 88vw);
  padding: 24px;
  border: 1px solid rgba(74,214,255,0.3);
  border-radius: 8px;
  background: rgba(10, 18, 40, 0.6);
  position: relative;
}
.boot-inner::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 8px;
  background: linear-gradient(transparent 50%, rgba(74,214,255,0.03) 50%);
  background-size: 100% 4px;
  pointer-events: none;
}
.boot-line {
  opacity: 0;
  margin: 4px 0;
  letter-spacing: 0.04em;
}
.boot-line.show { opacity: 1; animation: bootLine 0.3s ease-out; }
.boot-line.ok::after { content: ' [OK]'; color: #4afaa7; }
.boot-line.err::after { content: ' [ERR]'; color: #ff4a6b; }
@keyframes bootLine {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.boot-cursor::after {
  content: '_';
  animation: blink 0.7s steps(2) infinite;
  color: #4ad6ff;
}
@keyframes blink { 50% { opacity: 0; } }

/* ===== Section scanline wipe ===== */
.section-wipe {
  position: fixed;
  left: 0; right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--steel-edge) 30%, var(--gold) 50%, var(--steel-edge) 70%, transparent);
  box-shadow: 0 0 20px rgba(244, 168, 44, 0.5);
  z-index: 9997;
  pointer-events: none;
  animation: sectionWipe 0.8s ease-in-out forwards;
}
@keyframes sectionWipe {
  0% { transform: translateY(-2px); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* ===== Sound toggle pill ===== */
.sound-pill {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  background: rgba(10, 18, 40, 0.85);
  border: 1px solid rgba(74,214,255,0.3);
  color: #4ad6ff;
  padding: 8px 14px;
  border-radius: 999px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.15em;
  cursor: pointer;
  user-select: none;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.sound-pill:hover { border-color: #4ad6ff; box-shadow: 0 0 20px rgba(74,214,255,0.3); }
.sound-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #4afaa7; box-shadow: 0 0 10px #4afaa7; }
.sound-pill.off .dot { background: #555; box-shadow: none; }
@media (max-width: 767px) {
  .sound-pill { display: none; }
}

/* ===== Theme toggle (light mode) ===== */
html.theme-light {
  --bg: #f4f1ea;
  --text: #1a1a1a;
  --text-dim: #555;
  --line: rgba(0,0,0,0.12);
  --indigo: #1f4adf;
  --cyan: #008fc9;
  --gold: #b8860b;
}
html.theme-light body { background: #f4f1ea; color: #1a1a1a; }
html.theme-light .bg-stack,
html.theme-light .stars,
html.theme-light .vignette,
html.theme-light .aurora { opacity: 0.15 !important; }
html.theme-light .nav { background: rgba(244,241,234,0.85); }
html.theme-light .domain-card,
html.theme-light .about-card,
html.theme-light .testimonial,
html.theme-light .case-card,
html.theme-light .cap-card,
html.theme-light .stat,
html.theme-light .imagery-tile,
html.theme-light .contact-form,
html.theme-light .contact-info {
  background: rgba(255,255,255,0.7) !important;
  color: #1a1a1a;
}
html.theme-light h1,
html.theme-light h2,
html.theme-light h3,
html.theme-light h4 { color: #0a0a0a; }
html.theme-light .ori-core {
  background: radial-gradient(circle at 35% 35%, #fff7c8, #ffd24a 35%, #b8860b 70%, #4a2c00 100%) !important;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .ori, .ori-ring, .ori-core,
  .stars, .aurora, .grid-bg,
  .conjure-burst, .conjure-ring, .ori-click-ping,
  .warp-overlay, .warp-tunnel, .warp-ori, .warp-streaks,
  .ori-takeover, .ori-takeover::before {
    animation: none !important;
    transition: none !important;
  }
  .ori-particle { display: none !important; }
}

/* ===== Mobile ORI ===== */
@media (max-width: 767px) {
  .ori { width: 70px !important; height: 70px !important; }
  .ori-tooltip { max-width: 220px !important; font-size: 12px; padding: 10px 14px !important; }
  .ori-cmd-inner { width: 94vw; padding: 14px; }
  .ori-cmd-input { font-size: 15px; }
}

/* ===== Halo behind ORI to anchor it visually ===== */
.ori::before {
  content: '';
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74,214,255,0.25), transparent 70%);
  pointer-events: none;
  z-index: -1;
  animation: oriHalo 4s ease-in-out infinite;
}
@keyframes oriHalo {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.15); }
}

/* ===== Conjure trail (content flying from ORI) =====
   Note: styles.css declares an aggressive initial state for .fly-from-ori
   (opacity:0, scale(0.05), blur(14px)). We override here with a tamer
   start state, run the keyframe with `forwards` so elements stay visible,
   and add a safety .flown class that pins the final visible state. */
.fly-from-ori {
  --ori-fx: 50vw;
  --ori-fy: 50vh;
  opacity: 0;
  /* Override styles.css initial transform/filter so a missed animation
     still leaves something readable instead of a blurry speck. */
  transform: translateY(20px) scale(0.96);
  filter: blur(6px);
  transition: opacity .35s ease, transform .35s ease, filter .35s ease;
}
.fly-from-ori.flying {
  animation: flyFromOri 0.55s cubic-bezier(0.2, 0.85, 0.25, 1) forwards;
}
.fly-from-ori.flown,
.fly-from-ori.flying {
  /* Static safety net: if the animation is interrupted or stripped, the
     element still settles to a fully visible state. */
}
.fly-from-ori.flown {
  opacity: 1 !important;
  transform: translate(0, 0) scale(1) rotate(0deg) !important;
  filter: none !important;
}
@keyframes flyFromOri {
  0% {
    opacity: 0;
    transform: translate(calc(var(--ori-fx) * 0.4 - 20%), calc(var(--ori-fy) * 0.4 - 20%)) scale(0.7) rotate(-3deg);
    filter: blur(6px) brightness(1.4);
  }
  55% {
    opacity: 1;
    filter: blur(1px) brightness(1.1);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0) scale(1) rotate(0deg);
    filter: blur(0) brightness(1);
  }
}

/* Mobile: drop the GPU-expensive blur filter, shorter animation, smaller
   transform delta — keeps the materialization feel without the lag. */
@media (max-width: 767px) {
  .fly-from-ori {
    transform: translateY(14px);
    filter: none;
  }
  .fly-from-ori.flying {
    animation: flyFromOriMobile 0.4s ease-out forwards;
  }
  @keyframes flyFromOriMobile {
    0%   { opacity: 0; transform: translateY(14px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
  }
}
