/* Mavi — Sıfır Atık Vakfı ekolojik asistanı
   Variant C: fok × yazı markası kompozisyonu, dalga geçişli sığ su paneli */

:root {
  --abyss: #061423;
  --deep: #0B2238;
  --mid: #123A4E;
  --glow: #5EE6D2;
  --glow-soft: #9FF3E4;
  --shallow: #EEF5F5;
  --shallow-2: #E2EDEE;
  --ink: #10222E;
  --ink-soft: #4B6270;
  --teal: #0F6E75;
  --teal-dark: #0B575D;
  --line: #C6D8DA;
  --foam: #F7FBFB;

  --display: "Bricolage Grotesque", "Archivo Black", "Arial Black", Arial, sans-serif;
  --body: "Manrope", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --ease-out: cubic-bezier(.16, .84, .3, 1);
  --composer-h: 150px;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--abyss); scroll-behavior: auto; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--shallow);
  overflow-x: clip;
  overflow-anchor: none;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--composer-h);
  min-height: 100vh;
}

a { color: var(--teal); }
button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--glow);
  outline-offset: 3px;
}
.panel :focus-visible, .composer :focus-visible {
  outline-color: var(--teal);
}

/* ---------- üst çubuk ---------- */

.topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px clamp(16px, 4vw, 40px);
  color: #C7D8E0;
  font-size: 14px;
  font-weight: 600;
}
.topbar-link {
  color: var(--glow-soft);
  text-decoration: none;
  border-bottom: 1px solid rgba(159, 243, 228, .35);
  font-weight: 500;
}
.topbar-link:hover { border-bottom-color: var(--glow-soft); }

/* ---------- hero: derin su ---------- */

.hero {
  position: relative;
  overflow: clip;
  background:
    linear-gradient(180deg, var(--abyss) 0%, var(--deep) 62%, #0E2C42 100%);
  color: #E4EFF2;
  padding: clamp(96px, 14vh, 150px) clamp(16px, 4vw, 40px) 120px;
  isolation: isolate;
}

/* ışık huzmeleri: yukarıdan süzülen, hafif eğik, çok düşük yoğunluk */
.shafts { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.shafts i {
  position: absolute;
  top: -20%;
  height: 130%;
  width: clamp(120px, 20vw, 320px);
  background: linear-gradient(90deg,
    rgba(159, 243, 228, 0) 0%,
    rgba(159, 243, 228, .075) 45%,
    rgba(159, 243, 228, .09) 55%,
    rgba(159, 243, 228, 0) 100%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,.6) 55%, transparent 100%);
          mask-image: linear-gradient(180deg, #000 0%, rgba(0,0,0,.6) 55%, transparent 100%);
  transform: skewX(-14deg);
  animation: shaft-settle 1.8s var(--ease-out) both, shaft-drift 16s ease-in-out infinite alternate;
}
.shafts i:nth-child(1) { left: 6%;  animation-delay: 0s, 0s; }
.shafts i:nth-child(2) { left: 38%; width: clamp(80px, 12vw, 200px); animation-delay: .25s, -6s; }
.shafts i:nth-child(3) { left: 66%; animation-delay: .5s, -11s; }

@keyframes shaft-settle {
  from { opacity: 0; transform: skewX(-14deg) translateX(-40px); }
  to   { opacity: 1; transform: skewX(-14deg) translateX(0); }
}
@keyframes shaft-drift {
  from { transform: skewX(-14deg) translateX(-14px); }
  to   { transform: skewX(-14deg) translateX(18px); }
}

/* plankton / kabarcık zerreleri */
.particles { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.particles i {
  position: absolute;
  border-radius: 50%;
  background: rgba(159, 243, 228, .5);
  opacity: 0;
  animation: drift var(--d, 14s) linear infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  20%  { opacity: .55; }
  80%  { opacity: .35; }
  100% { transform: translate3d(var(--dx, 10px), -90px, 0); opacity: 0; }
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  text-align: center;
}

/* ---------- imza: fok × yazı markası ---------- */

.mark {
  position: relative;
  display: inline-block;
  font-size: clamp(100px, 21vw, 232px);
  line-height: 1;
  margin: 0 auto 8px;
  padding-top: .38em;          /* fokun başı ve kabarcıklar için yer */
  /* display fontu hazır olana kadar gizli: fallback metrikleriyle fok yanlış harfe düşmesin.
     app.js font yüklenince .is-ready ekler; giriş animasyonları da o anda başlar. */
  visibility: hidden;
}
.mark.is-ready { visibility: visible; }
.mark:not(.is-ready) .wordmark,
.mark:not(.is-ready) .hero-seal { animation-play-state: paused; }

.wordmark {
  position: relative;
  margin: 0;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-weight: 800;
  font-size: 1em;
  line-height: 1;
  letter-spacing: -.035em;
  color: #E9F5F5;
  animation: rise-in 1.1s var(--ease-out) both;
  animation-delay: .15s;
}
.wordmark { z-index: 2; }
.wordmark span { position: relative; display: inline-block; }

/* Fok harflerin arasına yerleşir: gövdesi ve kuyruğu "M" ile "av"ın arkasında,
   başı "i"nin üzerinde, ön yüzgeci "v"nin önünde. Aynı SVG iki kez çizilir;
   öndeki kopya yalnızca baş + ön yüzgeç bölgesine kırpılır. */
.hero-seal {
  position: absolute;
  top: .15em;
  left: .36em;
  width: 1.60em;
  animation: seal-arrive 1.6s var(--ease-out) both;
  animation-delay: .35s;
}
.hero-seal--back  { z-index: 1; }
.hero-seal--front {
  z-index: 3;
  clip-path: polygon(72% 0, 100% 0, 100% 100%, 53% 100%, 53% 64%, 64% 60%, 72% 44%);
}
.hero-seal .seal-wrap {
  animation: seal-bob 7.5s ease-in-out infinite;
  animation-delay: 1.9s;
  will-change: transform;
}
.seal { display: block; width: 100%; height: auto; overflow: visible; }

@keyframes seal-arrive {
  from { opacity: 0; transform: translate3d(-6%, 10%, 0) rotate(-4deg); }
  to   { opacity: 1; transform: translate3d(0, 0, 0) rotate(0); }
}
@keyframes seal-bob {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%      { transform: translate3d(0, -2.2%, 0) rotate(1.2deg); }
}
@keyframes rise-in {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* kompozisyondan yükselen kabarcıklar */
.rise { position: absolute; inset: 0; pointer-events: none; }
.rise i {
  position: absolute;
  bottom: .30em;
  width: .05em;
  height: .05em;
  border-radius: 50%;
  border: 1.5px solid rgba(159, 243, 228, .7);
  opacity: 0;
  animation: bubble-rise 6s ease-out infinite;
}
.rise i:nth-child(1) { left: 1.02em; animation-delay: 1.8s; }
.rise i:nth-child(2) { left: .62em; width: .035em; height: .035em; animation-delay: 3.1s; animation-duration: 5s; }
.rise i:nth-child(3) { left: 1.32em; width: .04em; height: .04em; animation-delay: 4.4s; }
.rise i:nth-child(4) { left: .30em; width: .03em; height: .03em; animation-delay: 5.6s; animation-duration: 7s; }
.rise i:nth-child(5) { left: .86em; width: .04em; height: .04em; animation-delay: 7.2s; }
@keyframes bubble-rise {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  12%  { opacity: .75; }
  70%  { opacity: .45; }
  100% { transform: translate3d(.08em, -1.35em, 0); opacity: 0; }
}

/* ---------- fokun canlılığı (hero ve avatar için ortak) ---------- */

.seal-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: seal-blink 5.4s ease-in-out infinite;
  animation-delay: 2.6s;
}
@keyframes seal-blink {
  0%, 93%, 100% { transform: scaleY(1); }
  95.5%         { transform: scaleY(.08); }
  98%           { transform: scaleY(1); }
}
.seal-flipper {
  transform-box: view-box;
  transform-origin: 293px 166px;
  animation: seal-paddle 4.6s ease-in-out infinite;
}
@keyframes seal-paddle {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(-7deg); }
}
.seal-tail {
  transform-box: view-box;
  transform-origin: 56px 104px;
  animation: seal-tail 6.2s ease-in-out infinite;
  animation-delay: -2s;
}
@keyframes seal-tail {
  0%, 100% { transform: rotate(0deg); }
  50%      { transform: rotate(4deg); }
}
.seal-bubbles circle {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
}

/* düşünme durumu: metne doğru eğilir, gözler kısılır, burundan kabarcık çıkar */
.seal { transition: transform .9s var(--ease-out); transform-origin: 60% 60%; }
.is-thinking .seal { transform: rotate(-5deg) translate3d(2%, -1%, 0); }
.is-thinking .seal-eye { animation: seal-squint 2.4s ease-in-out infinite; }
@keyframes seal-squint {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(.72); }
}
.is-thinking .seal-bubbles circle { animation: nose-bubble 2.1s ease-out infinite; }
.is-thinking .seal-bubbles .b2 { animation-delay: .7s; }
.is-thinking .seal-bubbles .b3 { animation-delay: 1.4s; }
@keyframes nose-bubble {
  0%   { transform: translate3d(0, 0, 0) scale(.6); opacity: 0; }
  20%  { opacity: .85; }
  100% { transform: translate3d(6px, -34px, 0) scale(1); opacity: 0; }
}

/* ---------- hero metinleri ---------- */

.lede {
  max-width: 640px;
  margin: 18px auto 0;
  font-size: clamp(16px, 1.9vw, 19px);
  line-height: 1.55;
  color: #D6E5EA;
  animation: rise-in 1s var(--ease-out) both;
  animation-delay: .55s;
}
.caption {
  margin: 12px auto 0;
  font-size: 14.5px;
  color: #93AEBB;
  animation: rise-in 1s var(--ease-out) both;
  animation-delay: .7s;
}
.caption b { font-weight: 700; color: var(--glow-soft); }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px 10px;
  margin: 26px auto 0;
  animation: rise-in 1s var(--ease-out) both;
  animation-delay: .85s;
}
.chips-label {
  font-size: 14px;
  color: #93AEBB;
  margin-right: 4px;
}
.chip {
  border: 1px solid rgba(159, 243, 228, .35);
  background: rgba(14, 44, 66, .55);
  color: #E4EFF2;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  transition: background .2s var(--ease-out), border-color .2s var(--ease-out), transform .2s var(--ease-out);
}
.chip:hover { background: rgba(94, 230, 210, .14); border-color: var(--glow-soft); }
.chip:active { transform: translateY(1px); }

/* dalga geçişi: derinden sığ suya */
.wave {
  position: absolute;
  z-index: 2;
  left: 0; right: 0; bottom: -1px;
  width: 100%;
  height: clamp(44px, 7vw, 90px);
  display: block;
  fill: var(--shallow);
}

/* ---------- sığ su: sohbet paneli ---------- */

.panel {
  position: relative;
  z-index: 3;
  background: var(--shallow);
  margin-top: -2px;           /* dalga kenarındaki alt piksel dikişini örter */
  padding: 28px clamp(16px, 4vw, 24px) 24px;
}
.panel-inner { max-width: 752px; margin: 0 auto; }

.chat { display: flex; flex-direction: column; gap: 22px; }
/* sohbet boşken panel çok küçük kalır; alt composer'ın altına yığılmasın diye asgari yükseklik */
.chat:empty { min-height: 40px; }

.message { display: flex; gap: 12px; align-items: flex-start; }
.message.user { justify-content: flex-end; }
.message.user .bubble {
  max-width: min(78%, 560px);
  background: var(--mid);
  color: #F0F7F8;
  padding: 11px 16px;
  border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.message.assistant .bubble {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 68ch;
  padding-top: 8px;
  overflow-wrap: anywhere;
}
.message.assistant .bubble.error { color: #8A2A2A; }

/* avatar: fokun portre kırpımı (baş, göz, bıyıklar) — yuvarlak pencereden bakar */
.avatar {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  /* fokun başı (#8EA3B4 civarı) koyu deniz zemininden ayrılsın diye derin ama
     biraz daha aydınlık bir su rengi + üstten hafif ışık */
  background: radial-gradient(circle at 35% 25%, #1B4E68 0%, var(--deep) 70%);
  overflow: hidden;
  position: relative;
}
.avatar .seal-wrap {
  position: absolute;
  left: -78px;
  top: 0;
  width: 122px;
  animation: seal-bob 6s ease-in-out infinite;
}
.avatar .seal { width: 122px; }

/* markdown içerikleri */
.bubble p { margin: 0 0 .8em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h4 { font-family: var(--display); font-weight: 700; font-size: 1.05em; margin: 1.1em 0 .4em; letter-spacing: -.01em; }
.bubble ul, .bubble ol { margin: .3em 0 .9em; padding-left: 1.4em; }
.bubble li { margin: .25em 0; }
.bubble a { color: var(--teal); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.bubble strong { font-weight: 700; }
.table-wrap { overflow-x: auto; margin: .6em 0 1em; }
.bubble table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.bubble th, .bubble td { padding: 7px 10px; text-align: left; vertical-align: top; }
.bubble th { background: var(--shallow-2); font-weight: 700; }
.bubble tr:nth-child(even) td { background: rgba(226, 237, 238, .5); }

/* yazıyor göstergesi */
.typing-wrap { padding: 4px 0 6px; }
.typing { display: inline-flex; gap: 5px; align-items: center; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal);
  opacity: .35;
  animation: typing 1.3s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: .18s; }
.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes typing {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* kaynaklar */
.sources {
  margin-top: 16px;
  padding: 12px 14px 8px;
  background: var(--shallow-2);
  border-radius: 10px;
  font-size: 14px;
}
.sources-label {
  display: block;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}
.source-note {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0;
  min-width: 0;
}
.source-note .n {
  flex: 0 0 auto;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--foam);
  color: var(--teal);
  font-size: 11.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
}
.source-note img {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--foam);
}
.source-note a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: rgba(15, 110, 117, .45);
  text-underline-offset: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.source-note a:hover { color: var(--teal); text-decoration-color: var(--teal); }
.source-note .kind {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: 12.5px;
}
.source-note .kind::before { content: "· "; }

/* ---------- yazma alanı ---------- */

.composer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  padding: 26px clamp(12px, 4vw, 24px) 12px;
  background: linear-gradient(180deg, rgba(238, 245, 245, 0) 0%, var(--shallow) 26%);
  pointer-events: none;
}
.composer-inner {
  pointer-events: auto;
  max-width: 752px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--foam);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 8px 8px 16px;
  transition: border-color .2s var(--ease-out);
}
.composer-inner:focus-within { border-color: var(--teal); }
#input {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  padding: 8px 0;
  max-height: 140px;
  outline: none;
}
#input::placeholder { color: #7D93A0; }
#send {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 11px;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  transition: background .2s var(--ease-out), transform .2s var(--ease-out);
}
#send:hover { background: var(--teal-dark); }
#send:active { transform: translateY(1px); }
#send:disabled { background: #A9C0C4; cursor: default; }
.hint {
  pointer-events: auto;
  max-width: 752px;
  margin: 8px auto 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- küçük ekranlar ---------- */

@media (max-width: 560px) {
  :root { --composer-h: 160px; }
  .topbar { padding: 14px 16px; font-size: 13px; }
  .hero { padding-top: 84px; padding-bottom: 96px; }
  .lede { font-size: 15.5px; }
  .chip { font-size: 14px; padding: 8px 12px; }
  .message.user .bubble { max-width: 88%; }
  .avatar { width: 40px; height: 40px; }
  .avatar .seal-wrap { left: -68px; top: 0; width: 106px; }
  .avatar .seal { width: 106px; }
  .message { gap: 10px; }
  .hint { font-size: 12px; }
}

/* ---------- hareket azaltma ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .is-thinking .seal { transform: none; }
  .is-thinking .seal-bubbles circle { opacity: .6; }
  .typing span { opacity: .8; }
}
