/* Fiitarih Yayın Masası — temel stil ve ortak bileşenler.
   Görünüme özel stiller: views-main.css (Bugün/Taslak/Editör), views-data.css (Arşiv/Üretim/Yedek), archive-v2.css (Arşiv v2).
   Asıl hedef iPhone (iOS Safari + ana ekrana eklenmiş uygulama): güvenli alan boşlukları env(safe-area-inset-*),
   ≥ 44 px dokunma hedefleri, 16 px'ten küçük olmayan form yazısı (odakta yakınlaşmayı önler), ≤ 768 px'te alt sekme çubuğu. */

:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --surface-2: #f1eee8;
  --text: #1d1b19;
  --muted: #6b655e;
  --border: #dcd6cc;
  --accent: #b3121b;
  --accent-contrast: #ffffff;
  --accent-soft: #fbe9ea;
  --ok: #1d7a3e;
  --ok-soft: #e3f4e8;
  --warn: #8a5a00;
  --warn-soft: #fdf1d8;
  --danger: #a4161a;
  --danger-soft: #fde4e4;
  --info: #1f5fa8;
  --info-soft: #e4eefb;
  --focus: #1f5fa8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 4px 14px rgba(0, 0, 0, 0.05);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, Menlo, Consolas, "Courier New", monospace;
  /* Yerleşim: yan boşluk, alt sekme çubuğu yüksekliği (masaüstünde 0), üst çubuk renkleri, dokunma vurgusu */
  --gutter: 1.25rem;
  --tabbar-h: 0px;
  --topbar-bg: var(--surface);
  --topbar-fg: var(--text);
  --mark-bg: var(--accent);
  --mark-fg: var(--accent-contrast);
  --tap: rgba(179, 18, 27, 0.14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  /* Açık ekran klavyesinin yüksekliği (app.js ölçer; klavye kapalıyken 0) */
  --kb-inset: 0px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1f1d1a;
    --surface-2: #28251f;
    --text: #f1ede6;
    --muted: #a8a095;
    --border: #3a3630;
    --accent: #e0444c;
    --accent-contrast: #ffffff;
    --accent-soft: #3a1c1e;
    --ok: #5cc98a;
    --ok-soft: #173323;
    --warn: #f0b44c;
    --warn-soft: #3a2d12;
    --danger: #ff7a7f;
    --danger-soft: #3d1a1b;
    --info: #7fb2f0;
    --info-soft: #172a40;
    --focus: #7fb2f0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --tap: rgba(224, 68, 76, 0.22);
  }
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: var(--tap);
}
a { color: var(--info); }
a:hover { text-decoration-thickness: 2px; }
a, button, summary, label, select, [role="button"] { touch-action: manipulation; }
img, canvas, video { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
small, .small { font-size: 0.85rem; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 0.9em; }
code, .mono { overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: 0.5rem 1rem; z-index: 100; }
.skip-link:focus { left: max(1rem, var(--safe-left)); top: var(--safe-top); }

/* Üst çubuk (iPhone'da durum çubuğunun altına uzanır: black-translucent + viewport-fit=cover) */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: calc(0.6rem + var(--safe-top)) max(1.25rem, var(--safe-right)) 0.6rem max(1.25rem, var(--safe-left));
  background: var(--topbar-bg);
  color: var(--topbar-fg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.brand__mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--mark-bg); color: var(--mark-fg); font-size: 1.1rem; flex: none;
}
.brand__name small { font-weight: 500; color: var(--muted); margin-left: 0.25rem; }
.topbar__title { display: none; }
.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.nav a {
  padding: 0.45rem 0.85rem; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: var(--surface-2); }
.nav a.is-active { background: var(--accent); color: var(--accent-contrast); }

/* Alt sekme çubuğu: yalnız ≤ 768 px (aşağıdaki medya sorgusu) */
.tabbar { display: none; }

.main {
  max-width: 1280px; margin: 0 auto; outline: none;
  padding: 1.25rem max(var(--gutter), var(--safe-right)) calc(4rem + var(--tabbar-h) + var(--safe-bottom)) max(var(--gutter), var(--safe-left));
}
.view > header, .view-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

.global-warning {
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--border);
  padding: 0.6rem max(1.25rem, var(--safe-right)) 0.6rem max(1.25rem, var(--safe-left));
}
.global-warning__line { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.global-warning__line + .global-warning__line { margin-top: 0.35rem; }
/* Depo durumu (açılamadı / eski pencere) ve bekleyen güncelleme: kalıcı satırlar; "Yenile" düğmesi satırın içinde */
.global-warning__line--storage, .global-warning__line--stale { font-weight: 600; }
.global-warning__line .btn { margin-left: 0.35rem; vertical-align: baseline; }
.error-box { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0.5rem 0; overflow-wrap: anywhere; }
.error-box ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.info-box { background: var(--info-soft); color: var(--text); border-left: 4px solid var(--info); border-radius: var(--radius-sm); padding: 0.7rem 1rem; margin: 0.5rem 0; }
.warn-box { background: var(--warn-soft); color: var(--text); border-left: 4px solid var(--warn); border-radius: var(--radius-sm); padding: 0.7rem 1rem; margin: 0.5rem 0; }
.ok-box { background: var(--ok-soft); color: var(--text); border-left: 4px solid var(--ok); border-radius: var(--radius-sm); padding: 0.7rem 1rem; margin: 0.5rem 0; }

/* iPhone: "ana ekrana ekleyin" ipucu (Safari sekmesinde; kapatılabilir) */
.install-host { padding: 0.75rem max(var(--gutter), var(--safe-right)) 0 max(var(--gutter), var(--safe-left)); max-width: 1280px; margin: 0 auto; }
.install-hint {
  background: var(--surface); border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0.9rem 1rem;
}
.install-hint__title { font-size: 1.05rem; margin-bottom: 0.5rem; }
.install-hint__steps { list-style: none; margin: 0 0 0.6rem; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.install-hint__steps li { display: flex; align-items: flex-start; gap: 0.55rem; }
.install-hint__glyph {
  display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
}
.install-hint__note { margin: 0 0 0.45rem; font-size: 0.92rem; }
.install-hint__actions { display: flex; justify-content: flex-end; }

/* Yerleşim yardımcıları */
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.stack--tight { gap: 0.35rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grid { display: grid; gap: 1rem; }
.grid--3 { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); }
.spacer { flex: 1; }

/* Kart */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.1rem; min-width: 0;
}
.card__head { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.card__title { font-size: 1.1rem; font-weight: 700; margin: 0.2rem 0 0.4rem; }
.card__section { border-top: 1px dashed var(--border); padding-top: 0.6rem; margin-top: 0.6rem; }
.card__section > h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 0.35rem; }
.card__actions { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.8rem; }

/* Rozet */
.badge {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.12rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap; max-width: 100%;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.badge--muted { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.badge--accent { background: var(--accent); color: var(--accent-contrast); }

/* Çip (tek dokunuş seçenekleri) */
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer;
  padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem;
}
.chip:hover { border-color: var(--accent); }
.chip.is-selected { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* Düğme */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  min-height: 40px; padding: 0.45rem 1rem; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
}
.btn:hover:not(:disabled) { border-color: var(--text); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--primary:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--accent); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover:not(:disabled) { background: var(--surface-2); border-color: transparent; }
.btn--danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn--small { min-height: 32px; padding: 0.25rem 0.7rem; font-size: 0.88rem; }

/* Form */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.75rem; min-width: 0; }
.field__label { font-weight: 600; font-size: 0.92rem; }
.field__hint { color: var(--muted); font-size: 0.85rem; }
input[type="text"], input[type="url"], input[type="date"], input[type="search"], input[type="number"], select, textarea {
  font: inherit; font-size: max(16px, 1em); color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.65rem; width: 100%; max-width: 100%;
}
textarea { resize: vertical; min-height: 5rem; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 2px solid color-mix(in srgb, var(--focus) 35%, transparent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin: 0 0 0.75rem; min-width: 0; }
legend { font-weight: 700; padding: 0 0.3rem; }
.counter { font-size: 0.85rem; color: var(--muted); text-align: right; }
.counter.is-over { color: var(--danger); font-weight: 700; }

/* Tablo / liste */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-sm); overflow: hidden; }
.table th, .table td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-2); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }

/* Görsel yer tutucu (boş kutu hazır sayılmaz) */
.media-missing {
  border: 2px dashed var(--warn); background: var(--warn-soft); color: var(--text);
  border-radius: var(--radius-sm); padding: 0.9rem; text-align: left;
}
.media-missing strong { color: var(--warn); }
.preview-label { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.thumb { max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }

/* Diyalog */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.3rem; max-width: 560px; width: calc(100% - 2rem); background: var(--surface); color: var(--text); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog__title { margin-bottom: 0.75rem; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; flex-wrap: wrap; }
.dialog__details { background: var(--surface-2); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; font-size: 0.92rem; overflow-wrap: anywhere; }

/* Bildirim */
.toasts {
  position: fixed; z-index: 50; display: flex; flex-direction: column; gap: 0.5rem;
  bottom: max(1rem, var(--safe-bottom)); right: max(1rem, var(--safe-right));
  max-width: min(420px, calc(100% - 2rem));
}
.toast { background: var(--text); color: var(--bg); padding: 0.65rem 0.95rem; border-radius: var(--radius-sm); box-shadow: var(--shadow); overflow-wrap: anywhere; }
.toast--ok { background: var(--ok); color: #fff; }
.toast--error { background: var(--danger); color: #fff; }
.toast--warn { background: var(--warn); color: #fff; }
.toast--action { display: flex; align-items: center; gap: 0.75rem; }
.toast__msg { flex: 1; }
/* Kipli pencere (sayfa, form, seçici) içindeki bildirim alanı: pencere üst katmanda olduğundan #toasts görünmez */
.toasts--in-dialog { z-index: 10; pointer-events: none; }
.toasts--in-dialog .toast { pointer-events: auto; }
.toast .btn { color: inherit; background: transparent; border-color: currentColor; flex: none; }

/* Sekme */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 3px solid transparent; padding: 0.5rem 0.9rem; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* Dosya bırakma alanı */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.2rem; text-align: center; background: var(--surface); }
.dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); }

details > summary { cursor: pointer; font-weight: 600; }
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- Dokunmatik ekranlar: form yazısı en az 16 px (iOS odakta yakınlaştırmasın), ≥ 44 px dokunma hedefleri ---------- */
@media (pointer: coarse), (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]), select, textarea {
    font-size: max(16px, 1em) !important;
  }
  .btn, .btn--small { min-height: 44px; }
  .btn--small { padding: 0.4rem 0.85rem; }
  .chip { min-height: 44px; }
  .tabs button { min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 1.3rem; height: 1.3rem; }
  /* Kendi dolgusu olan özet satırları (ör. .prod-used, .ed-steps) da en az 44 px: min-height dolguya göre ezilmez */
  details > summary { padding-block: 0.55rem; min-height: 44px; }
}

/* ---------- Telefon (≤ 768 px): alt sekme çubuğu, sade üst çubuk, güvenli alanlar ---------- */
@media (max-width: 768px) {
  :root {
    --tabbar-h: 3.5rem;
    --topbar-bg: var(--accent);
    --topbar-fg: #ffffff;
    --mark-bg: #ffffff;
    --mark-fg: var(--accent);
  }
  body { overflow-x: clip; }
  .main { overflow-wrap: anywhere; }

  .topbar {
    gap: 0.65rem; flex-wrap: nowrap; border-bottom: none;
    padding-top: calc(0.45rem + var(--safe-top)); padding-bottom: 0.45rem;
    min-height: calc(3.25rem + var(--safe-top));
  }
  .brand__name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .brand__mark { width: 32px; height: 32px; }
  .topbar__title {
    display: block; min-width: 0; font-size: 1.15rem; font-weight: 700;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .nav { display: none; }

  .tabbar {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  }
  @supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    .tabbar {
      background: color-mix(in srgb, var(--surface) 90%, transparent);
      -webkit-backdrop-filter: saturate(1.5) blur(14px);
      backdrop-filter: saturate(1.5) blur(14px);
    }
  }
  .tabbar__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .tabbar__link {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
    min-height: var(--tabbar-h); padding: 0.3rem 0.1rem; color: var(--muted); text-decoration: none;
    font-size: 0.72rem; font-weight: 600; -webkit-tap-highlight-color: transparent;
  }
  .tabbar__link:active { background: var(--surface-2); }
  .tabbar__link.is-active { color: var(--accent); }
  .tabbar__icon { width: 24px; height: 24px; flex: none; }
  .tabbar__label { line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .global-warning { font-size: 0.92rem; }

  .toasts {
    top: calc(var(--safe-top) + 3.75rem); bottom: auto;
    left: max(0.75rem, var(--safe-left)); right: max(0.75rem, var(--safe-right)); max-width: none;
  }
  /* Tam ekran sayfada üst çubuk yok: bildirim güvenli alanın hemen altında */
  .toasts--in-dialog { top: calc(var(--safe-top) + 0.75rem); }

  .dialog {
    width: calc(100% - 1.5rem); padding: 1rem;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 1.5rem);
    overflow: auto; overscroll-behavior: contain;
  }
  .dialog__actions .btn { flex: 1 1 auto; }

  .card__actions .btn { flex: 1 1 auto; }
}

/* Koyu temada telefon üst çubuğu yüzey renginde (durum çubuğunun beyaz yazısı yine okunur) */
@media (max-width: 768px) and (prefers-color-scheme: dark) {
  :root {
    --topbar-bg: var(--surface);
    --topbar-fg: var(--text);
    --mark-bg: var(--accent);
    --mark-fg: var(--accent-contrast);
  }
  .topbar { border-bottom: 1px solid var(--border); }
}

/* Klavye açıkken (metin alanı odakta) alt çubuk gizlenir; yapışık kaydetme çubuğu klavyenin üstüne iner */
@media (max-width: 768px) and (pointer: coarse) {
  :root:has(:is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]), textarea, select):focus) {
    --tabbar-h: 0px;
  }
  body:has(:is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="button"]):not([type="submit"]), textarea, select):focus) .tabbar {
    display: none;
  }
}

@media (max-width: 640px) {
  :root { --gutter: 1rem; }
  .main { padding-top: 0.9rem; }
  .grid--2, .grid--3 { grid-template-columns: 1fr; }
  h1 { font-size: 1.45rem; }
}

@media (max-width: 480px) {
  .badge { white-space: normal; text-align: left; }
}

/* Hareketi azalt: animasyon ve yumuşak kaydırma kapalı */
@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;
  }
}
