/* Network News BD App, base styles (mobile first). */

@font-face {
  font-family: "NNBD Bengali";
  src: url("../fonts/solaimanlipi.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+200C-200D, U+20B9, U+25CC;
}
@font-face {
  font-family: "NNBD Bengali";
  src: url("../fonts/solaimanlipi-bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+200C-200D, U+20B9, U+25CC;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "NNBD Bengali", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Bengali", "Kalpurush", "SolaimanLipi", sans-serif;
  font-size: calc(1rem * var(--fs-scale));
  line-height: 1.7;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); }
h1, h2, h3, h4 { line-height: 1.4; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
.muted { color: var(--text-muted); }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.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;
}
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent-bg); color: var(--on-accent); padding: 10px 14px; border-radius: 8px;
}
.skip-link:focus { top: 8px; }

.ic { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 18px; height: 18px; }
.ic-xl { width: 56px; height: 56px; color: var(--text-muted); }

/* ---------- Layout shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-logo { border-radius: 8px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; color: var(--accent); letter-spacing: .01em; white-space: nowrap; }
.brand-tag { font-size: .72rem; color: var(--text-muted); white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 2px; }

.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--text);
  border-radius: 50%; cursor: pointer; text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.badge {
  position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--accent-bg); color: var(--on-accent);
  font-size: .7rem; line-height: 18px; text-align: center; font-weight: 700;
}

.view { flex: 1; padding: 12px 12px calc(92px + env(safe-area-inset-bottom)); width: 100%; max-width: 960px; margin: 0 auto; outline: none; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 56px; padding: 6px 2px; text-decoration: none; color: var(--text-muted);
  font-size: .75rem; line-height: 1.2;
}
.nav-item[aria-current="page"] { color: var(--accent); font-weight: 700; }
.nav-item[aria-current="page"] .ic { stroke-width: 2.4; }

.offline-banner {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  background: #3b3b3b; color: #fff; padding: 8px 12px; font-size: .85rem;
  padding-top: calc(8px + env(safe-area-inset-top));
}
.offline-banner .ic { width: 18px; height: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px; border-radius: 999px; font: inherit; font-weight: 700; font-size: .95rem;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent-bg); }
.btn-danger { color: var(--accent); border-color: var(--accent); }
.btn-sm { min-height: 36px; padding: 4px 14px; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- Typography helpers ---------- */
.page-title { font-size: 1.45rem; margin: 6px 0 12px; }
.section { margin: 22px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-title {
  font-size: 1.1rem; margin: 0; padding-left: 10px; border-left: 4px solid var(--accent-bg);
}
.section-link { font-size: .85rem; font-weight: 700; text-decoration: none; }
.cat-label {
  display: inline-block; font-size: .78rem; font-weight: 700; color: var(--accent);
  text-decoration: none; letter-spacing: .01em;
}
.meta { font-size: .8rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }

/* ---------- Images ---------- */
.thumb { position: relative; display: block; background: var(--surface-2); overflow: hidden; aspect-ratio: 16 / 9; border-radius: 10px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-weight: 700; font-size: .9rem; }
.thumb-empty .ic { width: 32px; height: 32px; opacity: .6; }

/* ---------- Cards ---------- */
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover .card-title { text-decoration: underline; text-decoration-color: var(--accent); }
.card-title { font-weight: 700; line-height: 1.45; margin: 4px 0; color: var(--text); }

.featured { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.featured .thumb { border-radius: 0; }
.featured-body { padding: 12px 14px 14px; }
.featured .card-title { font-size: 1.35rem; }
.featured .excerpt { color: var(--text-muted); font-size: .92rem; margin: 6px 0 8px; }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.row-card { display: grid; grid-template-columns: 1fr 112px; gap: 12px; padding: 12px 0; align-items: start; }
.row-card .thumb { aspect-ratio: 4 / 3; border-radius: 8px; }
.row-card .card-title { font-size: 1rem; }
.row-card.no-img { grid-template-columns: 1fr; }

.tiles { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.tile { flex: 0 0 72%; max-width: 300px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tile .thumb { border-radius: 0; }
.tile-body { padding: 8px 12px 12px; }
.tile .card-title { font-size: .95rem; }

.ranked { counter-reset: rank; }
.ranked .list-item { counter-increment: rank; }
.ranked .row-card { grid-template-columns: 34px 1fr; }
.ranked .rank-num { font-weight: 700; font-size: 1.5rem; color: var(--accent); line-height: 1.2; text-align: center; }
.ranked .rank-num::before { content: counter(rank, bengali); }

/* ---------- Breaking strip ---------- */
.strip { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.strip-label { background: var(--accent-bg); color: var(--on-accent); font-weight: 700; font-size: .85rem; padding: 8px 12px; display: flex; align-items: center; white-space: nowrap; }
.strip-list { display: flex; gap: 0; overflow-x: auto; list-style: none; margin: 0; padding: 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.strip-list::-webkit-scrollbar { display: none; }
.strip-list a { display: block; white-space: nowrap; padding: 8px 14px; text-decoration: none; color: var(--text); font-size: .9rem; border-right: 1px solid var(--border); max-width: 80vw; overflow: hidden; text-overflow: ellipsis; }
.strip-list a:hover { background: var(--surface-2); }

/* ---------- Category chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; min-height: 38px; padding: 4px 14px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; font-size: .9rem; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"], .chip[aria-current="true"] { background: var(--accent-bg); border-color: var(--accent-bg); color: var(--on-accent); font-weight: 700; }
.chip-wrap { flex-wrap: wrap; overflow: visible; }

/* ---------- Article ---------- */
.article { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.article-head { padding: 14px 14px 0; }
.article-title { font-size: 1.55rem; line-height: 1.4; margin: 6px 0 10px; }
.article-figure { margin: 12px 0 0; }
.article-figure .thumb { border-radius: 0; }
.article-figure figcaption { font-size: .8rem; color: var(--text-muted); padding: 6px 14px 0; }
.article-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.article-body { padding: 14px; font-size: 1.06em; line-height: 1.95; overflow-wrap: anywhere; text-align: justify; }
.article-body figcaption, .article-body table, .article-body pre { text-align: left; }
.byline { display: inline-flex; align-items: center; gap: 8px; }
.byline-img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--surface-2, #eee); }
.byline-name { font-weight: 700; color: var(--text); }
.article-body img { border-radius: 6px; margin: 8px 0; }
.article-body figure { margin: 14px 0; }
.article-body figcaption { font-size: .8rem; color: var(--text-muted); }
.article-body blockquote { margin: 14px 0; padding: 4px 14px; border-left: 4px solid var(--accent-bg); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.article-body h2, .article-body h3, .article-body h4 { margin-top: 1.4em; }
.article-body a { text-decoration: underline; }
.article-body .table-wrap { overflow-x: auto; margin: 12px 0; }
.article-body table { border-collapse: collapse; width: 100%; font-size: .9em; }
.article-body th, .article-body td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; }
.article-body pre { overflow-x: auto; background: var(--surface-2); padding: 10px; border-radius: 8px; }
.embed-note { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; margin: 12px 0; }
.attribution { padding: 0 14px 16px; font-size: .85rem; color: var(--text-muted); }
.share-menu { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 12px; }

/* ---------- Lists, states ---------- */
.state { text-align: center; padding: 36px 16px; color: var(--text-muted); }
.state .ic { width: 48px; height: 48px; margin-bottom: 8px; opacity: .8; }
.state h2 { font-size: 1.1rem; color: var(--text); margin-bottom: 6px; }
.load-more { display: flex; justify-content: center; padding: 14px 0 4px; }
.end-note { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 14px 0; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent-bg); animation: spin .8s linear infinite; margin: 0 auto 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.boot { text-align: center; padding: 60px 16px; color: var(--text-muted); }

.skeleton { background: linear-gradient(90deg, var(--skeleton-a), var(--skeleton-b), var(--skeleton-a)); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-row { display: grid; grid-template-columns: 1fr 112px; gap: 12px; padding: 12px 0; }
.sk-lines { display: flex; flex-direction: column; gap: 8px; }
.sk-line { height: 14px; }
.sk-line.w60 { width: 60%; }
.sk-thumb { aspect-ratio: 4 / 3; }
.sk-hero { aspect-ratio: 16 / 9; border-radius: 14px; }

/* ---------- Forms ---------- */
.search-form { display: flex; gap: 8px; margin-bottom: 10px; }
.input {
  flex: 1; min-width: 0; min-height: 46px; padding: 8px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px;
}
.input:focus-visible { border-color: var(--focus); }
.select { min-height: 40px; padding: 4px 10px; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px; max-width: 100%; }
.field-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.history { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }

/* ---------- Settings ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 4px 14px; margin-bottom: 14px; }
.panel-title { font-size: .85rem; font-weight: 700; color: var(--text-muted); margin: 18px 4px 6px; text-transform: none; }
.setting { padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting-label { font-weight: 700; margin-bottom: 6px; display: block; }
.setting-help { font-size: .85rem; color: var(--text-muted); margin: 4px 0 0; }
.menu-link { display: flex; align-items: center; gap: 12px; padding: 14px 0; text-decoration: none; color: var(--text); border-bottom: 1px solid var(--border); min-height: 52px; }
.menu-link:last-child { border-bottom: 0; }
.menu-link .grow { flex: 1; }
.menu-link small { display: block; color: var(--text-muted); font-size: .8rem; }
.segmented { display: inline-flex; border: 1.5px solid var(--border); border-radius: 999px; overflow: hidden; background: var(--surface); }
.segmented button { min-height: 40px; padding: 4px 16px; border: 0; background: transparent; color: var(--text); font: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.segmented button[aria-pressed="true"] { background: var(--accent-bg); color: var(--on-accent); font-weight: 700; }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper .btn { min-width: 44px; padding: 4px 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 2; }
.switch .track { position: absolute; inset: 0; background: var(--border); border-radius: 15px; transition: background .15s; }
.switch .thumb-dot { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.switch input:checked ~ .track { background: var(--accent-bg); }
.switch input:checked ~ .thumb-dot { transform: translateX(22px); }
.switch input:focus-visible ~ .track { outline: 3px solid var(--focus); outline-offset: 2px; }
.preview-text { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; margin-top: 8px; }

.notice { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--border); font-size: .9rem; margin-bottom: 12px; }
.notice.info { background: var(--surface-2); }

.inbox-item { padding: 12px 0; border-bottom: 1px solid var(--border); display: block; text-decoration: none; color: var(--text); }
.inbox-item:last-child { border-bottom: 0; }
.inbox-item.unread .card-title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-bg); margin-right: 8px; }

/* ---------- Install banner, toast, dialog ---------- */
.install-banner {
  position: fixed; left: 8px; right: 8px; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 45;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow), 0 8px 24px rgba(0,0,0,.18);
}
.install-banner img { border-radius: 8px; }
.install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; font-size: .85rem; }
.install-text span { color: var(--text-muted); font-size: .78rem; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 70;
  max-width: min(92vw, 460px); display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: #1f2024; color: #fff; border-radius: 12px; font-size: .9rem; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast button { background: transparent; border: 0; color: #FFB4B6; font: inherit; font-weight: 700; cursor: pointer; min-height: 36px; }

.dialog-scrim { position: fixed; inset: 0; z-index: 80; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: var(--surface); color: var(--text); border-radius: 16px; padding: 20px; width: min(100%, 420px); box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.dialog h2 { font-size: 1.1rem; margin-bottom: 8px; }
.dialog .btn-row { justify-content: flex-end; margin-top: 14px; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 28px; padding: 18px 4px; border-top: 1px solid var(--border); font-size: .85rem; color: var(--text-muted); text-align: center; }
.site-footer a { color: inherit; }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-bottom: 6px; }

/* ---------- Offline page ---------- */
.offline-page { max-width: 440px; margin: 0 auto; padding: 56px 20px; text-align: center; }
.offline-page img { border-radius: 16px; margin-bottom: 8px; }
.offline-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

@media (prefers-reduced-motion: reduce) {
  .skeleton, .spinner { animation: none; }
  .switch .track, .switch .thumb-dot { transition: none; }
}

/* Bengali counter style for ranked list */
@counter-style bengali {
  system: numeric;
  symbols: "০" "১" "২" "৩" "৪" "৫" "৬" "৭" "৮" "৯";
}
