/* ==========================================================================
   FormFlow — Temel bileşen kütüphanesi (Bölüm 3.5)
   Buton · Input · Kart · Chip · Modal · Bildirim · Boş durum · İskelet
   ========================================================================== */

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

/*
  hidden özniteliği her zaman kazanır.
  .btn gibi display:inline-flex tanımlayan sınıflar tarayıcının
  [hidden] { display:none } kuralını ezdiği için gereklidir.
*/
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--t-body-size);
  line-height: 1.6;
  color: var(--ink-700);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Zemin dokusu: tek radyal mor ışıma — yalnız sayfa zemininde */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(1200px 600px at 15% -10%, rgba(91, 75, 255, .08), transparent);
}
body > * { position: relative; z-index: 1; }

h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); color: var(--ink-900); font-weight: 700; }
h1 { font-size: var(--t-h1-size); line-height: 1.2; }
h2 { font-size: var(--t-h2-size); line-height: 1.3; font-weight: 700; }
h3 { font-size: var(--t-h3-size); line-height: 1.4; font-weight: 600; }
p  { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

small { font-size: var(--t-small-size); }
code, kbd, .mono { font-family: var(--font-mono); font-size: .92em; }

img, svg, video { max-width: 100%; height: auto; }

/* Uzun kelimeler ve bağlantılar dar ekranda kabı yarmaz */
body { overflow-wrap: break-word; }

hr { border: none; border-top: 1px solid var(--line-soft); margin: var(--s-5) 0; }

::selection { background: var(--brand-100); color: var(--ink-900); }

/* Klavye odağı her etkileşimli öğede görünür */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--r-sm);
}

/* Ekran okuyucu metni */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Honeypot — görsel olarak gizli, ekran okuyucudan da uzak */
.ff-hp { position: absolute; left: -9999px; top: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* ---------------------------------------------------------------- Tipografi */

.t-display { font-family: var(--font-display); font-size: var(--t-display-size); line-height: 1.15; font-weight: 700; color: var(--ink-900); }
.t-h2      { font-size: var(--t-h2-size); font-weight: 700; }
.t-body    { font-size: var(--t-body-size); }
.t-small   { font-size: var(--t-small-size); color: var(--ink-500); }
.t-label   { font-size: var(--t-label-size); font-weight: 600; letter-spacing: .01em; color: var(--ink-700); }
.t-caption {
  font-size: var(--t-caption-size); font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-500);
}
.t-mono    { font-family: var(--font-mono); }
.t-muted   { color: var(--ink-500); }
.t-ok      { color: var(--ok-500); }
.t-warn    { color: var(--warn-500); }
.t-err     { color: var(--err-500); }

/* -------------------------------------------------------------------- Buton */

.btn {
  --btn-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--btn-height);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: var(--t-body-size);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--ink-300); border-color: transparent; color: #fff;
  box-shadow: none; cursor: not-allowed; transform: none;
}

.btn--primary { background: var(--brand-500); color: #fff; box-shadow: var(--shadow-sm); }
.btn--primary:hover:not(:disabled) { background: var(--brand-600); transform: translateY(-1px); }

.btn--secondary { background: var(--bg-surface); border-color: var(--line-strong); color: var(--ink-700); }
.btn--secondary:hover:not(:disabled) { border-color: var(--brand-400); color: var(--brand-600); }

.btn--quiet { background: transparent; color: var(--ink-500); }
.btn--quiet:hover:not(:disabled) { background: var(--bg-sunken); color: var(--ink-700); }

.btn--danger { background: var(--err-500); color: #fff; box-shadow: var(--shadow-sm); }
.btn--danger:hover:not(:disabled) { background: #C82F44; transform: translateY(-1px); }

.btn--sm { --btn-height: 36px; padding: 0 14px; font-size: var(--t-small-size); }
.btn--lg { --btn-height: 52px; padding: 0 28px; font-size: 16px; }
.btn--block { width: 100%; white-space: normal; }
.btn--icon { padding: 0; width: var(--btn-height); }

.btn svg { width: 18px; height: 18px; flex: none; }

/* -------------------------------------------------------------------- Input */

.field { margin-bottom: var(--s-5); }
.field:last-child { margin-bottom: 0; }

.field__label {
  display: block;
  margin-bottom: var(--s-2);
  font-size: var(--t-label-size);
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink-700);
}
.field__label .req { color: var(--err-500); margin-left: 2px; }

.field__help { margin-top: var(--s-2); font-size: var(--t-small-size); color: var(--ink-500); }

.field__error {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: var(--s-2);
  font-size: var(--t-small-size);
  color: var(--err-500);
}
.field__error svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

.input, .select, .textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-size: var(--t-body-size);
  line-height: 1.5;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
  -webkit-appearance: none;
  appearance: none;
}
.textarea { padding: 12px 14px; min-height: 110px; resize: vertical; line-height: 1.6; }

.input::placeholder, .textarea::placeholder { color: var(--ink-300); }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-focus);
}

.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select[aria-invalid="true"],
.field--error .input, .field--error .textarea, .field--error .select {
  border-color: var(--err-500);
}

.input:disabled, .textarea:disabled, .select:disabled {
  background: var(--bg-sunken); color: var(--ink-500); cursor: not-allowed;
}

.select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7192' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.input-group { display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; min-width: 0; }
.input-group .input { flex: 1; }

.input--mono { font-family: var(--font-mono); }

/* Onay kutusu ve radyo */
.choice {
  display: flex; align-items: flex-start; gap: var(--s-3);
  min-height: 44px;
  padding: 10px var(--s-4);
  border: 1.5px solid var(--line-soft);
  border-radius: var(--r-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.choice:hover { border-color: var(--brand-400); }
.choice input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand-500); cursor: pointer; }
.choice__text { flex: 1; color: var(--ink-700); }
.choice:has(input:checked) { border-color: var(--brand-500); background: var(--brand-050); }
.choice:has(input:checked) .choice__text { color: var(--ink-900); font-weight: 500; }
.choice:has(input:focus-visible) { box-shadow: var(--shadow-focus); }

.choice-list { display: grid; gap: var(--s-2); }
.choice-list--inline { grid-auto-flow: column; grid-auto-columns: max-content; }
.choice-list--grid { grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }

/* Anahtar (switch) */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__track {
  position: relative; width: 44px; height: 26px; flex: none;
  background: var(--line-strong); border-radius: var(--r-full);
  transition: background var(--dur-base) var(--ease-out);
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-xs);
  transition: transform var(--dur-base) var(--ease-spring);
}
.switch input:checked + .switch__track { background: var(--brand-500); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--shadow-focus); }
.switch__label { font-size: var(--t-body-size); color: var(--ink-700); }

/* --------------------------------------------------------------------- Kart */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--s-5);
}
.card--flush { padding: 0; overflow: hidden; }
.card--clickable { transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
.card--clickable:hover { box-shadow: var(--shadow-md); }

.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  margin-bottom: var(--s-4);
}
.card__title { font-size: var(--t-h3-size); font-weight: 600; color: var(--ink-900); font-family: var(--font-display); }

/* --------------------------------------------------------------------- Chip */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-full);
  font-size: var(--t-caption-size);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--bg-sunken);
  color: var(--ink-500);
  white-space: nowrap;
}
.chip--brand { background: var(--brand-100); color: var(--brand-600); }
.chip--ok    { background: var(--ok-100);    color: var(--ok-500); }
.chip--warn  { background: var(--warn-100);  color: var(--warn-500); }
.chip--err   { background: var(--err-100);   color: var(--err-500); }
.chip--info  { background: var(--info-100);  color: var(--info-500); }

.chip__close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-right: -4px;
  border: none; background: none; padding: 0; cursor: pointer;
  color: inherit; opacity: .7; border-radius: 50%;
}
.chip__close:hover { opacity: 1; background: rgba(0,0,0,.06); }

/* -------------------------------------------------------------------- Modal */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg-overlay);
  display: flex; align-items: center; justify-content: center;
  padding: var(--s-4);
  animation: fade-in var(--dur-base) var(--ease-out);
}
.modal {
  width: 100%; max-width: 560px;
  max-height: calc(100vh - var(--s-7));
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur-base) var(--ease-out);
  overflow: hidden;
}
.modal--wide { max-width: 760px; }
.modal__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--line-soft);
}
.modal__title { font-family: var(--font-display); font-size: var(--t-h2-size); font-weight: 700; color: var(--ink-900); }
.modal__body { padding: var(--s-5); overflow-y: auto; flex: 1; }
.modal__footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--line-soft);
  background: var(--bg-canvas);
}
.modal__close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex: none;
  border: none; background: none; border-radius: var(--r-sm);
  color: var(--ink-500); cursor: pointer;
}
.modal__close:hover { background: var(--bg-sunken); color: var(--ink-900); }

/* ---------------------------------------------------------------- Bildirim */

.toast-stack {
  position: fixed; z-index: 200; right: var(--s-5); bottom: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-2);
  max-width: min(420px, calc(100vw - var(--s-6)));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-4);
  background: var(--bg-surface);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--brand-500);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  animation: toast-in var(--dur-base) var(--ease-out);
}
.toast--success { border-left-color: var(--ok-500); }
.toast--error   { border-left-color: var(--err-500); }
.toast--warning { border-left-color: var(--warn-500); }
.toast__body { flex: 1; font-size: var(--t-small-size); color: var(--ink-700); }
.toast__action {
  border: none; background: none; padding: 0; cursor: pointer;
  font-weight: 600; font-size: var(--t-small-size); color: var(--brand-600);
}
.toast.is-leaving { animation: toast-out var(--dur-base) var(--ease-out) forwards; }

/* Sayfa üstü uyarı şeridi */
.banner {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  font-size: var(--t-small-size);
  margin-bottom: var(--s-4);
}
.banner--info { background: var(--info-100); color: #0F5F91; }
.banner--warn { background: var(--warn-100); color: #8A5A00; }
.banner--err  { background: var(--err-100);  color: #97182C; }
.banner--ok   { background: var(--ok-100);   color: #06673F; }
.banner svg { width: 18px; height: 18px; flex: none; }

/* ------------------------------------------------------------- Boş durum */

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: var(--s-8) var(--s-5);
  color: var(--ink-500);
}
.empty__art {
  width: 96px; height: 96px; margin-bottom: var(--s-5);
  border-radius: var(--r-xl);
  background: linear-gradient(140deg, var(--brand-050), var(--brand-100));
  display: grid; place-items: center;
  color: var(--brand-500);
}
.empty__art svg { width: 40px; height: 40px; }
.empty__title { font-family: var(--font-display); font-size: var(--t-h2-size); color: var(--ink-900); margin-bottom: var(--s-2); }
.empty__text { max-width: 46ch; margin-bottom: var(--s-5); }

/* ---------------------------------------------------------------- İskelet */

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, #F5F6FC 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--r-sm);
}
.skeleton--text { height: 12px; margin-bottom: var(--s-2); }
.skeleton--title { height: 20px; width: 40%; margin-bottom: var(--s-4); }
.skeleton--row { height: 44px; margin-bottom: var(--s-2); border-radius: var(--r-md); }

/* ------------------------------------------------------------- Animasyonlar */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-3px); } 30%, 70% { transform: translateX(3px); } 50% { transform: none; } }
@keyframes pulse-ring { 0% { box-shadow: 0 0 0 0 rgba(91,75,255,.35); } 70% { box-shadow: 0 0 0 8px rgba(91,75,255,0); } 100% { box-shadow: 0 0 0 0 rgba(91,75,255,0); } }
@keyframes draw-check { to { stroke-dashoffset: 0; } }

/* Sayfa yükleniş sıralaması — en fazla 6 kart */
.stagger > * { animation: rise var(--dur-base) var(--ease-out) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(6) { animation-delay: 200ms; }
.stagger > *:nth-child(n+7) { animation: none; }

/* ---------------------------------------------------------- Hata sayfası */

.ff-error-page { display: grid; place-items: center; min-height: 100vh; }
.ff-error { text-align: center; padding: var(--s-6); max-width: 460px; }
.ff-error__code { font-family: var(--font-mono); font-size: 56px; font-weight: 500; color: var(--brand-400); margin: 0 0 var(--s-2); }
.ff-error__title { font-family: var(--font-display); font-size: var(--t-h1-size); color: var(--ink-900); margin-bottom: var(--s-3); }
.ff-error__text { color: var(--ink-500); margin-bottom: var(--s-5); }

/* ------------------------------------------------------- Yardımcı sınıflar */

.stack   { display: flex; flex-direction: column; gap: var(--s-4); min-width: 0; }
.stack--sm { gap: var(--s-2); }
/* Satırlar varsayılan olarak sarar: dar ekranda yatay taşmayı önler. */
.row     { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; min-width: 0; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.row--nowrap { flex-wrap: nowrap; }
.grow    { flex: 1; min-width: 0; }
.hidden  { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap  { white-space: nowrap; }
.center  { text-align: center; }
.right   { text-align: right; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); }

/* --------------------------------------------------- Hareket tercihi */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
