/* ════════════════════════════════════════════════════════════
   TERAN ILDIZ — css/layout.css   (v33 · 3/7)
   BBC News skeleti: qora masthead · bo'lim lentasi · yon menyu ·
   mobil pastki nav · sahifa kallagi · kontent + yon panel · kolofon
   ════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────
   1) MASTHEAD (#nav) — barcha mavzularda qora (BBC imzosi)
───────────────────────────────────────────── */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 120;
  height: calc(var(--nav-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 10px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-bdr);
}

/* Masthead tugmalari */
.nb {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  color: var(--chrome-ink);
  border-radius: var(--r-sm);
  font-size: 16px;
  transition: background var(--dur) var(--ease);
}
.nb:hover { background: var(--chrome-hover); }
.nb:active { transform: scale(.94); }
.lang-btn { width: auto; padding: 0 12px; font-size: .8rem; font-weight: 600; }
.lang-btn i { font-size: 15px; }
.lang-btn span { color: var(--chrome-txt); }

/* ── LOGO: asl logo belgisi + so'z belgisi ── */
/* (BUGFIX) .logo torgina mobil ekranlarda min-width:0 orqali siqilishga
   ruxsat berilgan, lekin matnida overflow:hidden yo'q edi — natijada
   "TERAN ILDIZ" matni o'z qutisidan tashqariga toshib, yoniga qo'shni
   qidiruv ikonkasini (#searchToggleBtn) ustidan bosib, uni ko'rinmas
   qilib qo'yardi. Endi matn kesib, "…" bilan yakunlanadi — hech qachon
   qo'shni tugmalarni yopmaydi. */
.logo { display: inline-flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; margin-right: auto; }
.logo-mono {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--brand);
  border-radius: 8px;
  overflow: hidden;
}
.logo-block {
  font-family: var(--ff-brand);
  font-weight: 700; font-size: 15px; letter-spacing: .02em;
  color: #fff; line-height: 1; transform: translateY(.5px);
}
.logo-mono img { display: block; width: 100%; height: 100%; object-fit: cover; }
.logo-mono .logo-block { display: none; }  /* rasm ishlamasa, JS onerror orqali qayta ko'rsatiladi */
.logo-tx { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.logo-nm {
  font-family: var(--ff-brand);
  font-size: 1.02rem; font-weight: 700; letter-spacing: .06em;
  color: var(--chrome-ink); line-height: 1.15; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.logo-sb {
  font-size: .6rem; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); line-height: 1.3; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

/* ── Qidiruv (desktop, masthead ichida) ── */
.srch {
  position: relative;
  flex: 0 1 340px; min-width: 0;
  display: none; align-items: center;
  height: 40px;
  background: var(--chrome-bg-2);
  border: 1px solid var(--chrome-bdr);
  border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease);
}
.srch:focus-within { border-color: var(--chrome-txt); }
.srch-ic { position: absolute; left: 12px; font-size: 13px; color: var(--chrome-txt); pointer-events: none; }
.srch input {
  width: 100%; height: 100%;
  padding: 0 36px 0 36px;
  background: none; border: 0; outline: none;
  color: var(--chrome-ink); font-size: .9rem;
}
.srch input::placeholder { color: var(--chrome-txt); }
.srch input::-webkit-search-cancel-button { display: none; }
.srch-x {
  position: absolute; right: 6px;
  width: 28px; height: 28px; display: none; place-items: center;
  color: var(--chrome-txt); border-radius: var(--r-sm); font-size: 13px;
}
.srch-x:hover { background: var(--chrome-hover); color: var(--chrome-ink); }

.nav-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }

@media (min-width: 900px) {
  .srch { display: flex; }
  .search-btn { display: none; }
}
@media (max-width: 420px) {
  .logo-sb { display: none; }
  .lang-btn span { display: none; }
  .lang-btn { width: 40px; padding: 0; }
}

/* ── Mobil qidiruv paneli ── */
.srch-mob {
  position: fixed; z-index: 118;
  top: calc(var(--nav-h) + env(safe-area-inset-top));
  left: 0; right: 0;
  padding: 10px 14px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-bdr);
  animation: srchDrop .22s var(--ease-out);
}
@keyframes srchDrop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.srch-mob input {
  width: 100%; height: 42px;
  padding: 0 14px;
  background: var(--chrome-bg-2);
  border: 1px solid var(--chrome-bdr); border-radius: var(--r-sm);
  color: var(--chrome-ink); font-size: .95rem; outline: none;
}
.srch-mob input:focus { border-color: var(--chrome-txt); }
body.mob-srch-open #catbar { transform: translateY(62px); }

/* ─────────────────────────────────────────────
   2) BO'LIM LENTASI (#catbar) — BBC section ribbon:
      matnli tablar, faolida 3px qizil ostki chiziq
───────────────────────────────────────────── */
#catbar {
  position: fixed; z-index: 115;
  top: calc(var(--nav-h) + env(safe-area-inset-top));
  left: 0; right: 0;
  height: var(--cat-h);
  display: flex; align-items: stretch;
  padding: 0 max(8px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  transition: transform var(--dur) var(--ease);
}
#catbar::-webkit-scrollbar { display: none; }

.nc {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 13px;
  font-size: .86rem; font-weight: 500; white-space: nowrap;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  transition: color var(--dur) var(--ease);
}
.nc i {
  width: 20px; height: 20px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 10px; color: #fff;
  background: linear-gradient(135deg, var(--cc), var(--cd));
  border-radius: 4px;
}
.nc:hover { color: var(--ink); }
.nc.on {
  color: var(--ink); font-weight: 700;
  border-bottom-color: var(--brand);
}

/* ─────────────────────────────────────────────
   3) YON MENYU (#side) — BBC gamburger menyusi
───────────────────────────────────────────── */
#side { position: fixed; inset: 0; z-index: 200; }
#side[hidden] { display: none; }
.side-ov {
  position: absolute; inset: 0;
  background: rgba(8,10,12,.6);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.side-panel {
  position: absolute; top: 0; left: 0; bottom: 0;
  width: min(320px, 86vw);
  display: flex; flex-direction: column;
  background: var(--surf);
  border-right: 1px solid var(--rule);
  overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  animation: sideIn .26s var(--ease-out);
}
@keyframes sideIn { from { transform: translateX(-40px); opacity: 0; } to { transform: none; opacity: 1; } }

.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  background: var(--chrome-bg);
  border-bottom: 1px solid var(--chrome-bdr);
}
.side-head .logo-nm { font-size: .95rem; }

.side-group {
  padding: 18px 18px 8px;
  font-size: .68rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim);
  display: flex; align-items: center; gap: 10px;
}
.side-group::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.side-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  font-size: .92rem; font-weight: 500;
  color: var(--txt);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.side-item i {
  width: 26px; height: 26px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 12px; color: #fff;
  background: linear-gradient(135deg, var(--cc), var(--cd));
  border-radius: 5px;
}
.side-item::after {
  content: "\f054"; font-family: "Font Awesome 6 Free"; font-weight: 900;
  margin-left: auto; font-size: 10px; color: var(--dim);
}
.side-item:hover { background: var(--surf-1); color: var(--ink); }
.side-item.on {
  color: var(--ink); font-weight: 700;
  box-shadow: inset 3px 0 0 var(--brand);
  background: var(--surf-1);
}

/* ─────────────────────────────────────────────
   4) MOBIL PASTKI NAV (#tabbar) — yangi, ilova uslubi
───────────────────────────────────────────── */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 110;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding: 0 6px env(safe-area-inset-bottom);
  display: none;
  background: var(--chrome-bg);
  border-top: 1px solid var(--chrome-bdr);
}
#tabbar .tb {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--chrome-txt);
  font-size: .62rem; font-weight: 600; letter-spacing: .02em;
  border-top: 2px solid transparent;
  transition: color var(--dur) var(--ease);
}
#tabbar .tb i { font-size: 17px; }
#tabbar .tb:active { transform: scale(.94); }
#tabbar .tb.on { color: #fff; border-top-color: var(--brand); }
@media (max-width: 768px) {
  #tabbar { display: flex; }
  body { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); }
}

/* ─────────────────────────────────────────────
   5) ASOSIY SAHIFA SKELETI
───────────────────────────────────────────── */
.main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(var(--top) + env(safe-area-inset-top) + 14px)
           max(16px, env(safe-area-inset-right))
           56px
           max(16px, env(safe-area-inset-left));
}

/* Sana chizig'i — BBC front sanasi: hijriy oltin, melodiy kul */
.ti-dateline {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px;
  padding-bottom: 10px; margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  font-size: .78rem;
}
.tdl-hijri { font-family: var(--ff-serif); font-style: italic; font-size: .88rem; color: var(--gold-hi); }
.tdl-greg  { color: var(--muted); font-weight: 500; }
.tdl-sep   { flex: 1; }
.tdl-brand {
  font-size: .64rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim);
}

/* Sahifa kallagi — bo'lim nomi + qalin qoida (gazeta) */
.phd {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
  padding-bottom: 12px; margin-bottom: 20px;
  border-bottom: 4px double var(--rule-strong);
}
.phd-l { min-width: 0; }
.pkicker {
  display: block;
  font-size: .68rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase;
  color: var(--brand-hi);
  margin-bottom: 4px;
}
.pttl {
  font-size: clamp(1.5rem, 4.2vw, 2.3rem);
  font-weight: 700; letter-spacing: -.02em; line-height: 1.08;
}
.pcnt {
  flex: 0 0 auto;
  font-size: .74rem; font-weight: 700;
  color: var(--muted);
  padding: 5px 11px;
  border: 1px solid var(--rule); border-radius: var(--r-pill);
  font-variant-numeric: tabular-nums;
}
.pcnt::after { content: " ta"; font-weight: 500; color: var(--dim); }

/* Kontent + yon panel — BBC ikki ustunli tuzilma */
.ti-portal {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
@media (min-width: 1024px) {
  .ti-portal { grid-template-columns: minmax(0, 1fr) 316px; }
}
.ti-rail { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* Kartalar to'ri */
#grid.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  align-items: stretch;
}
@media (max-width: 719px) {
  #grid.grid { grid-template-columns: 1fr; gap: 0; border-top: 1px solid var(--rule); }
}

/* ─────────────────────────────────────────────
   6) KOLOFON (.ti-foot) — BBC pastki qismi
───────────────────────────────────────────── */
.ti-foot {
  margin-top: 56px;
  border-top: 4px solid var(--rule-strong);
  padding-top: 26px;
  display: grid; gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.tf-col { min-width: 0; }
.tf-brand { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 8px; }
.tf-nm {
  font-family: var(--ff-brand);
  font-size: 1.05rem; font-weight: 700; letter-spacing: .06em; color: var(--ink);
  display: flex; align-items: center; gap: 9px;
}
.tf-nm::before {
  content: "TI";
  display: grid; place-items: center;
  width: 26px; height: 26px;
  background: var(--brand); color: #fff;
  font-size: 11px; letter-spacing: .02em; border-radius: 2px;
}
.tf-quote { font-family: var(--ff-serif); font-style: italic; color: var(--muted); font-size: .9rem; max-width: 460px; }
.tf-tag {
  font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); margin-bottom: 10px;
  padding-top: 8px; border-top: 2px solid var(--brand);
  display: inline-block;
}
.tf-col h5 {
  font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink); margin-bottom: 10px;
  padding-top: 8px; border-top: 2px solid var(--brand);
  display: inline-block;
}
.tf-col a {
  display: block;
  padding: 7px 0;
  font-size: .85rem; color: var(--muted);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: color var(--dur) var(--ease);
}
.tf-col a:hover { color: var(--brand-hi); }
.ti-foot-base {
  grid-column: 1 / -1;
  margin-top: 4px; padding: 16px 0 6px;
  border-top: 1px solid var(--rule);
  font-size: .74rem; color: var(--dim);
  display: flex; flex-wrap: wrap; gap: 6px 18px;
}

/* ─────────────────────────────────────────────
   7) MAVZU MENYUSI
───────────────────────────────────────────── */
.theme-menu-ov { position: fixed; inset: 0; z-index: 210; }
.theme-menu {
  position: fixed; z-index: 211;
  top: calc(var(--nav-h) + env(safe-area-inset-top) + 6px);
  right: max(12px, env(safe-area-inset-right));
  width: 236px; max-height: min(70vh, 480px); overflow-y: auto;
  background: var(--surf);
  border: 1px solid var(--rule-strong); border-radius: var(--r);
  box-shadow: var(--sh-lg);
  padding: 6px;
  animation: srchDrop .18s var(--ease-out);
}
.theme-opt {
  width: 100%;
  display: flex; align-items: center; gap: 11px;
  padding: 10px 11px;
  font-size: .86rem; font-weight: 500; text-align: left;
  color: var(--txt);
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
.theme-opt i {
  width: 26px; height: 26px; flex: 0 0 auto;
  display: grid; place-items: center;
  font-size: 12px;
  color: var(--ink);
  background: var(--surf-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
}
.theme-opt:hover { background: var(--surf-1); color: var(--ink); }
.theme-opt.on { color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); background: var(--surf-1); }
.theme-opt.on i { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ─────────────────────────────────────────────
   8) PWA BANNER
───────────────────────────────────────────── */
#pwaBanner {
  position: fixed; z-index: 130;
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  max-width: 460px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--chrome-bg);
  border: 1px solid var(--chrome-bdr);
  border-top: 3px solid var(--brand);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  animation: pwaUp .35s var(--ease-out);
}
@keyframes pwaUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@media (max-width: 768px) { #pwaBanner { bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom)); } }
#pwaBanner[hidden] { display: none; }
.pwa-ic { flex: 0 0 auto; }
.pwa-tx { flex: 1; min-width: 0; }
.pwa-tx h4 { font-size: .9rem; color: #fff; }
.pwa-tx p { font-size: .74rem; color: var(--chrome-txt); }
.pwa-actions { display: flex; gap: 8px; }
.pwa-btn {
  padding: 8px 13px;
  font-size: .78rem; font-weight: 700;
  border-radius: var(--r-sm);
  transition: opacity var(--dur) var(--ease);
}
.pwa-btn.ghost { color: var(--chrome-txt); border: 1px solid var(--chrome-bdr); }
.pwa-btn.primary { background: var(--brand); color: #fff; }
.pwa-btn:hover { opacity: .88; }

/* ─────────────────────────────────────────────
   9) TOAST — qora plashka, qizil chekka
───────────────────────────────────────────── */
#toast {
  position: fixed; z-index: 300;
  left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  max-width: min(440px, calc(100vw - 32px));
  padding: 12px 18px;
  background: var(--chrome-bg); color: #fff;
  border: 1px solid var(--chrome-bdr);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-lg);
  font-size: .88rem; font-weight: 500; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 768px) { #toast { bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); } }
