/* ============================================================================
   theme.css - Sophia chat page frame
   Brand-matched Novar/Sophia shell for a centered, production chat experience.
   ========================================================================== */

:root {
  --bg: #030812;
  --bg-2: #071527;
  --ink: #f6fbff;
  --muted: #9db2cf;
  --muted-strong: #cad8ea;
  --line: rgba(120, 178, 255, 0.24);
  --line-strong: rgba(117, 211, 255, 0.46);
  --brand-blue: #0075d5;
  --brand-blue-deep: #00528f;
  --brand-blue-soft: #30b9ff;
  --cyan: #75e4ff;
  --green: #1cbf63;
  --amber: #ffb84a;

  --chat-frame: #06101f;
  --chat-panel: #ffffff;
  --chat-body: #eef2f6;
  --chat-body-2: #e7edf4;
  --chat-divider: #d8e1ed;
  --chat-ink: #12233b;
  --chat-muted: #66788e;
  --input-bg: #fbfdff;
  --input-line: #cfdbe8;

  --font-body: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

  --brand-height: 58px;
  --shell-max: 1180px;
  --shell-height: min(76vh, 690px);
  --radius-sm: 8px;
  --shadow: 0 34px 90px rgba(0, 0, 0, 0.44);

  --bs-primary: var(--brand-blue);
  --bs-primary-rgb: 0, 117, 213;
  --bs-body-font-family: var(--font-body);
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--bg);
  --bs-border-radius: var(--radius-sm);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(117, 228, 255, 0.08) 0 1px, transparent 1px 18px),
    linear-gradient(180deg, #030812 0%, #071628 46%, #030812 100%);
  line-height: 1.5;
  overflow: hidden;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 var(--radius-sm) 0;
  background: var(--brand-blue);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
}

.skip-link:focus {
  left: 0;
}

.noise-overlay,
.circuit-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.noise-overlay {
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
}

.circuit-field {
  opacity: 0.58;
  background:
    linear-gradient(90deg, rgba(117, 228, 255, 0.08) 1px, transparent 1px) 0 0 / 72px 72px,
    linear-gradient(0deg, rgba(117, 228, 255, 0.055) 1px, transparent 1px) 0 0 / 72px 72px,
    linear-gradient(135deg, transparent 0 46%, rgba(0, 117, 213, 0.16) 46% 47%, transparent 47% 100%);
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000 76%, transparent);
}

.brand-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--brand-height);
  padding: 10px 0;
  background:
    linear-gradient(90deg, rgba(2, 22, 42, 0.72), transparent 22% 78%, rgba(2, 22, 42, 0.72)),
    linear-gradient(180deg, #0064a8 0%, #004c85 100%);
  border-bottom: 1px solid rgba(178, 224, 255, 0.28);
  box-shadow: 0 12px 36px rgba(0, 30, 64, 0.36);
}

.brand-bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(117, 228, 255, 0.86), transparent);
  animation: signal-sweep 5.6s ease-in-out infinite;
}

.brand-bar__logo {
  width: clamp(118px, 12vw, 158px);
  max-height: calc(var(--brand-height) - 20px);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.22));
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100dvh - var(--brand-height));
  padding: clamp(16px, 4vh, 34px) clamp(16px, 4vw, 54px);
  overflow: hidden;
}

.app-rail {
  position: absolute;
  top: 12%;
  bottom: 12%;
  width: min(18vw, 210px);
  border: 1px solid rgba(117, 228, 255, 0.14);
  opacity: 0.58;
  pointer-events: none;
}

.app-rail::before,
.app-rail::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(117, 228, 255, 0.75), transparent);
}

.app-rail::before {
  top: 22%;
}

.app-rail::after {
  bottom: 18%;
}

.app-rail--left {
  left: -70px;
  border-right: 0;
  transform: skewY(-8deg);
}

.app-rail--right {
  right: -70px;
  border-left: 0;
  transform: skewY(8deg);
}

.chat-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  max-width: var(--shell-max);
  height: var(--shell-height);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid rgba(170, 213, 255, 0.42);
  border-radius: var(--radius-sm);
  background: var(--chat-panel);
  box-shadow:
    var(--shadow),
    0 0 0 10px rgba(3, 13, 28, 0.7),
    0 0 72px rgba(0, 117, 213, 0.23);
  animation: shell-enter 0.72s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.chat-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

@keyframes shell-enter {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes signal-sweep {
  0%, 100% {
    opacity: 0.35;
    transform: scaleX(0.42);
  }
  50% {
    opacity: 1;
    transform: scaleX(1);
  }
}

@media (max-width: 900px) {
  :root {
    --shell-height: calc(100dvh - var(--brand-height) - 24px);
  }

  .app {
    padding: 12px;
  }

  .app-rail {
    display: none;
  }

  .chat-shell {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  :root {
    --brand-height: 56px;
    --shell-height: 100%;
  }

  .brand-bar {
    padding: 10px 0;
  }

  .brand-bar__logo {
    width: clamp(124px, 34vw, 154px);
    max-height: 34px;
  }

  .app {
    height: calc(100% - var(--brand-height));
    min-height: 0;
    padding: 0;
    align-items: stretch;
  }

  .chat-shell {
    height: var(--shell-height);
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

}
