/* HUD layer (18.11, Barın: "telefondaki halini öyle fütüristik yap ki insanın ağzı açık kalsın").
   Visual only: it never changes the phone layout (keyboard / visible-viewport rules stay in
   app.css). Everything here is transform/opacity animation so the iPhone stays smooth, and
   prefers-reduced-motion turns the motion off. */

@property --hud-a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

:root {
  --hud-cyan: #3ff0ff;
  --hud-cyan-2: #00b7ff;
  --hud-violet: #b67cff;
  --hud-amber: #ffb547;
  --hud-ink: #dff9ff;
  --hud-dim: rgba(150, 225, 255, .55);
  --hud-line: rgba(63, 240, 255, .28);
  --hud-bg: #01040b;
  --hud-panel: rgba(2, 14, 26, .78);
  --hud-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- space ---------- */
body {
  background:
    radial-gradient(ellipse 90% 55% at 50% -5%, rgba(0, 183, 255, .22), transparent 62%),
    radial-gradient(ellipse 60% 40% at 50% 110%, rgba(182, 124, 255, .16), transparent 70%),
    var(--hud-bg);
}
body::after { /* the perspective floor: brighter, and it moves toward you */
  opacity: .55;
  background:
    linear-gradient(rgba(63, 240, 255, .26) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63, 240, 255, .26) 1px, transparent 1px);
  background-size: 46px 30px;
  animation: hud-floor 3.6s linear infinite;
}
@keyframes hud-floor { to { background-position: 0 30px, 0 0; } }
.planet-violet { opacity: .55; }
.planet-cyan { opacity: .7; }

.hud-scan { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.hud-scan::before { /* fine scanlines + edge vignette */
  content: ""; position: absolute; inset: 0;
  background:
    repeating-linear-gradient(to bottom, rgba(120, 230, 255, .035) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse 120% 90% at 50% 45%, transparent 60%, rgba(0, 0, 0, .55) 100%);
}
.hud-scan::after { /* a sweep of light every few seconds */
  content: ""; position: absolute; left: 0; right: 0; top: -20%; height: 18%;
  background: linear-gradient(to bottom, transparent, rgba(63, 240, 255, .07) 60%, rgba(63, 240, 255, .14), transparent);
  animation: hud-sweep 7s cubic-bezier(.6, 0, .4, 1) infinite;
}
@keyframes hud-sweep { 0%, 55% { transform: translateY(0); } 100% { transform: translateY(700%); } }

/* ---------- the frame around the chat: a thin HUD frame instead of a blurred slab ---------- */
.shell::before {
  backdrop-filter: none;
  background:
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 22px 2px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 2px 22px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top right / 22px 2px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top right / 2px 22px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom left / 22px 2px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom left / 2px 22px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 22px 2px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 2px 22px no-repeat,
    linear-gradient(180deg, rgba(0, 30, 50, .35), rgba(0, 8, 18, .55));
  border-color: rgba(63, 240, 255, .14);
  box-shadow: inset 0 0 60px rgba(0, 183, 255, .08), 0 0 40px rgba(0, 183, 255, .06);
}

/* ---------- header ---------- */
.topbar { border-bottom-color: rgba(63, 240, 255, .22); }
.brand strong {
  background: linear-gradient(90deg, #8ff6ff, #ffffff 40%, #8ff6ff 60%, var(--hud-violet));
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: hud-shimmer 5s linear infinite;
  text-shadow: none; filter: drop-shadow(0 0 10px rgba(63, 240, 255, .55));
}
@keyframes hud-shimmer { to { background-position: -250% 0; } }
.brand small { color: var(--hud-dim); font-family: var(--hud-mono); }
.mark { border-color: var(--hud-cyan); box-shadow: 0 0 22px rgba(63, 240, 255, .7), inset 0 0 12px rgba(63, 240, 255, .45); }
.mark::before { /* a turning arc around the brand dot */
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--hud-cyan); border-right-color: rgba(63, 240, 255, .35);
  animation: hud-turn 2.4s linear infinite;
}
.mark::after { animation: hud-breathe 2.4s ease-in-out infinite; }
.menu-toggle { border-color: rgba(63, 240, 255, .45) !important; box-shadow: 0 0 16px rgba(63, 240, 255, .18); }

/* ---------- live readout strip ---------- */
.interface-readout { color: var(--hud-dim); }
.interface-readout .hud-live { font-weight: 700; color: var(--hud-cyan); text-shadow: 0 0 8px rgba(63, 240, 255, .6); }
@media (max-width: 760px) {
  .interface-readout { font-size: 9px; letter-spacing: .14em; }
  .interface-readout span:last-child { display: inline; }
  .planet-violet { display: none; }
}
.interface-readout .hud-dot { display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: #39f0a5; box-shadow: 0 0 8px #39f0a5; animation: hud-blink 1.6s steps(2) infinite; vertical-align: 1px; }

/* ---------- the reactor behind the conversation ---------- */
.hud-core {
  position: absolute; z-index: -1; left: 50%; top: 44%;
  width: min(74vw, 330px); aspect-ratio: 1; transform: translate(-50%, -50%);
  pointer-events: none; transition: opacity .8s ease, transform .8s ease;
}
.hud-core i { position: absolute; border-radius: 50%; }
.hud-core .r1 { inset: 0; border: 1px solid rgba(63, 240, 255, .22);
  background: repeating-conic-gradient(rgba(63, 240, 255, .55) 0 1.2deg, transparent 1.2deg 6deg);
  -webkit-mask: radial-gradient(circle, transparent 66%, #000 67% 70%, transparent 71%);
          mask: radial-gradient(circle, transparent 66%, #000 67% 70%, transparent 71%);
  animation: hud-turn 40s linear infinite; }
.hud-core .r2 { inset: 9%; border: 2px solid transparent; border-top-color: var(--hud-cyan); border-bottom-color: rgba(182, 124, 255, .8);
  filter: drop-shadow(0 0 6px var(--hud-cyan)); animation: hud-turn 6s linear infinite reverse; }
.hud-core .r3 { inset: 20%; border: 1px dashed rgba(63, 240, 255, .45); animation: hud-turn 14s linear infinite; }
.hud-core .r4 { inset: 30%;
  background: conic-gradient(from 0deg, transparent 0 20%, rgba(63, 240, 255, .9) 25%, transparent 30% 45%,
                             rgba(63, 240, 255, .9) 50%, transparent 55% 70%, rgba(63, 240, 255, .9) 75%, transparent 80%);
  -webkit-mask: radial-gradient(circle, transparent 62%, #000 63% 74%, transparent 75%);
          mask: radial-gradient(circle, transparent 62%, #000 63% 74%, transparent 75%);
  animation: hud-turn 3.2s cubic-bezier(.5, 0, .5, 1) infinite; }
.hud-core .core { inset: 41%; background: radial-gradient(circle, #ffffff 0 18%, #9ff8ff 30%, rgba(0, 183, 255, .65) 55%, transparent 72%);
  box-shadow: 0 0 40px 12px rgba(0, 183, 255, .45), 0 0 120px 40px rgba(0, 120, 255, .22);
  animation: hud-breathe 2.6s ease-in-out infinite; }
.hud-core .label { position: absolute; left: 50%; top: calc(100% + 10px); transform: translateX(-50%);
  white-space: nowrap; font: 700 9px/1 var(--hud-mono); letter-spacing: .38em; color: rgba(150, 225, 255, .55); }
.hud-busy .hud-core { opacity: .16; transform: translate(-50%, -50%) scale(.86); }
.messages::before, .messages::after { content: none; }

/* ---------- messages ---------- */
.message { animation: hud-in .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes hud-in { from { opacity: 0; transform: translateY(12px) scale(.97); filter: blur(5px); } }
.avatar {
  border-radius: 0; border: 0;
  clip-path: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0 50%);
  background: linear-gradient(145deg, rgba(63, 240, 255, .55), rgba(0, 90, 160, .55));
  color: #eaffff; font-family: var(--hud-mono); text-shadow: 0 0 8px #3ff0ff;
}
.user .avatar { background: linear-gradient(145deg, rgba(182, 124, 255, .6), rgba(70, 40, 150, .6)); text-shadow: 0 0 8px var(--hud-violet); }
.bubble {
  position: relative;
  border-radius: 4px 14px 14px 14px;
  border: 1px solid var(--hud-line);
  backdrop-filter: none;
  color: var(--hud-ink);
  background:
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 12px 1.5px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 1.5px 12px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 12px 1.5px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 1.5px 12px no-repeat,
    linear-gradient(135deg, rgba(4, 34, 56, .82), rgba(2, 12, 24, .86));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35), 0 10px 30px rgba(0, 0, 0, .35), inset 0 0 24px rgba(63, 240, 255, .06);
}
.message.assistant .bubble::before {
  content: "J.A.R.V.I.S"; display: block; margin: -2px 0 6px;
  font: 700 8.5px/1 var(--hud-mono); letter-spacing: .32em; color: rgba(63, 240, 255, .7);
}
.user .bubble {
  border-radius: 14px 4px 14px 14px; border-color: rgba(182, 124, 255, .4);
  background:
    linear-gradient(var(--hud-violet), var(--hud-violet)) top right / 12px 1.5px no-repeat,
    linear-gradient(var(--hud-violet), var(--hud-violet)) top right / 1.5px 12px no-repeat,
    linear-gradient(135deg, rgba(60, 26, 110, .78), rgba(18, 16, 52, .86));
}
.bubble a { color: #8ff6ff; }
.meta { color: var(--hud-dim); font-family: var(--hud-mono); font-size: 10px; letter-spacing: .06em; }

/* ---------- composer: a holographic ring runs around it ---------- */
.composer { background: rgba(1, 10, 20, .88); border-color: rgba(63, 240, 255, .22); backdrop-filter: none; }
.composer::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1.5px; pointer-events: none;
  background: conic-gradient(from var(--hud-a), transparent 0 55%, rgba(63, 240, 255, .9) 72%, var(--hud-violet) 82%, transparent 95%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: hud-ring 4s linear infinite;
}
@keyframes hud-ring { to { --hud-a: 360deg; } }
.composer:focus-within { border-color: rgba(63, 240, 255, .6); box-shadow: 0 0 0 3px rgba(63, 240, 255, .10), 0 0 40px rgba(0, 183, 255, .25); }
.composer:focus-within::before { animation-duration: 1.6s; }
textarea { color: var(--hud-ink); caret-color: var(--hud-cyan); }
/* The placeholder may be smaller than 16px (iOS zooms by the field's own font size). */
textarea::placeholder { color: rgba(150, 225, 255, .45); letter-spacing: .02em; font-size: 14px; }
#sendButton {
  position: relative; overflow: hidden;
  background: linear-gradient(120deg, #00e1ff, #0091ff 45%, #8d5bff) !important;
  box-shadow: 0 0 18px rgba(0, 183, 255, .55), inset 0 0 10px rgba(255, 255, 255, .25) !important;
}
#sendButton::after { /* a light that runs across the button */
  content: ""; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
  transform: skewX(-20deg); animation: hud-glint 3.4s ease-in-out infinite;
}
@keyframes hud-glint { 0%, 60% { left: -60%; } 100% { left: 130%; } }
.composer .voice-button {
  border: 1px solid rgba(63, 240, 255, .55) !important; background: radial-gradient(circle, rgba(0, 120, 180, .55), rgba(1, 12, 24, .9)) !important;
  box-shadow: 0 0 16px rgba(63, 240, 255, .35), inset 0 0 12px rgba(63, 240, 255, .25);
}
.composer .voice-button .voice-initial { color: #eaffff; text-shadow: 0 0 10px var(--hud-cyan), 0 0 22px var(--hud-cyan); }
.composer .attach-button { border-color: rgba(63, 240, 255, .3) !important; background: rgba(1, 16, 28, .9) !important; color: #9ff8ff !important; }
.privacy { color: rgba(150, 225, 255, .4); font-family: var(--hud-mono); font-size: 10px; letter-spacing: .08em; }

/* ---------- the menu: a holographic panel of tiles ---------- */
@media (max-width: 760px) {
  .top-actions.open {
    background:
      linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 18px 2px no-repeat,
      linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 2px 18px no-repeat,
      linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 18px 2px no-repeat,
      linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 2px 18px no-repeat,
      linear-gradient(170deg, rgba(1, 18, 32, .97), rgba(1, 6, 14, .98));
    border-color: rgba(63, 240, 255, .35); border-radius: 8px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, .7), 0 0 50px rgba(0, 183, 255, .2);
    animation: hud-sheet .32s cubic-bezier(.2, .8, .2, 1);
  }
  .top-actions.open .menu-group-title { color: var(--hud-cyan); text-shadow: 0 0 8px rgba(63, 240, 255, .6); }
  .top-actions.open .menu-group-title::before { content: "▸ "; }
  .top-actions.open .utility, .top-actions.open .logout {
    border-radius: 4px; border-color: rgba(63, 240, 255, .25); color: #c9f6ff;
    background: linear-gradient(160deg, rgba(0, 60, 90, .35), rgba(0, 14, 26, .6));
    font-family: var(--hud-mono); letter-spacing: .02em;
    animation: hud-tile .4s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 16ms);
  }
  .top-actions.open .utility:active { background: rgba(63, 240, 255, .25); box-shadow: 0 0 18px rgba(63, 240, 255, .45); }
}
@keyframes hud-sheet { from { opacity: 0; transform: translateY(-8px) scaleY(.96); } }
@keyframes hud-tile { from { opacity: 0; transform: translateY(6px); filter: blur(3px); } }

/* ---------- panels and dialogs ---------- */
dialog {
  border-color: rgba(63, 240, 255, .4); border-radius: 10px;
  background:
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 18px 2px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) top left / 2px 18px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 18px 2px no-repeat,
    linear-gradient(var(--hud-cyan), var(--hud-cyan)) bottom right / 2px 18px no-repeat,
    linear-gradient(165deg, #031424, #010711);
  box-shadow: 0 30px 90px #000, 0 0 60px rgba(0, 183, 255, .18);
}
dialog[open] { animation: hud-sheet .3s cubic-bezier(.2, .8, .2, 1); }
.data-row, .action-card, .export-panel, .inv-tile, .inv-card { border-color: rgba(63, 240, 255, .18); background: rgba(1, 16, 28, .75); }
.toast { border-color: rgba(63, 240, 255, .6); background: linear-gradient(135deg, #032033, #0b1636); box-shadow: 0 0 24px rgba(0, 183, 255, .3); }

/* ---------- boot sequence (once per session) ---------- */
.hud-boot {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; align-content: center; gap: 18px;
  background: radial-gradient(ellipse 70% 50% at 50% 42%, rgba(0, 120, 200, .25), transparent 70%), #000;
  color: var(--hud-ink); font-family: var(--hud-mono); transition: opacity .6s ease, filter .6s ease;
}
.hud-boot.done { opacity: 0; filter: blur(8px); pointer-events: none; }
.hud-boot .hud-core { position: relative; left: auto; top: auto; transform: none; width: min(56vw, 240px); z-index: 0;
  animation: hud-ignite 1.2s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes hud-ignite { from { opacity: 0; transform: scale(.4) rotate(-90deg); filter: brightness(3); } }
.hud-boot-title { font: 800 22px/1 var(--hud-mono); letter-spacing: .55em; padding-left: .55em; color: #eaffff;
  text-shadow: 0 0 14px var(--hud-cyan), 0 0 30px var(--hud-cyan-2); animation: hud-flicker 1.4s steps(1) both; }
@keyframes hud-flicker { 0% { opacity: 0; } 10% { opacity: 1; } 14% { opacity: .2; } 18%, 100% { opacity: 1; } }
.hud-boot-lines { width: min(84vw, 330px); min-height: 104px; font-size: 11px; line-height: 1.75; color: rgba(160, 235, 255, .85); }
.hud-boot-lines div { display: flex; justify-content: space-between; gap: 10px; white-space: nowrap; overflow: hidden;
  animation: hud-type .35s steps(28) both; }
.hud-boot-lines div b { flex: none; color: #39f0a5; font-weight: 700; }
.hud-boot-lines div.final { white-space: normal; }
.hud-boot-lines div.final { color: #eaffff; text-shadow: 0 0 10px var(--hud-cyan); }
@keyframes hud-type { from { width: 0; } to { width: 100%; } }
.hud-boot-bar { width: min(84vw, 330px); height: 2px; background: rgba(63, 240, 255, .15); overflow: hidden; }
.hud-boot-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--hud-cyan), var(--hud-violet));
  box-shadow: 0 0 10px var(--hud-cyan); transform-origin: left; animation: hud-load 2.3s cubic-bezier(.4, 0, .2, 1) both; }
@keyframes hud-load { from { transform: scaleX(0); } }
.hud-boot-skip { font-size: 9px; letter-spacing: .3em; color: rgba(150, 225, 255, .35); }

/* ---------- shared motion ---------- */
@keyframes hud-turn { to { transform: rotate(360deg); } }
@keyframes hud-breathe { 50% { transform: scale(.86); opacity: .8; } }
@keyframes hud-blink { 50% { opacity: .25; } }

@media (prefers-reduced-motion: reduce) {
  .hud-core *, .mark::before, .mark::after, .composer::before, #sendButton::after, .hud-scan::after,
  body::after, .brand strong, .message, .interface-readout .hud-dot { animation: none !important; }
}
/* Keyboard up: keep only what helps typing. */
.keyboard-open .hud-core { opacity: .08; }
.keyboard-open .hud-scan::after { animation: none; }
