﻿/* =====================================================================
   Alkafeel+ — shared shell (style v2): header + search + tab bar + footer.
   Loaded by EVERY page. Classes are prefixed `ak-`.
   Header with nav links from 768px up (tablet + desktop); below 768px the
   header keeps only logo + search + account and a bottom tab bar appears.
   Motion: transform / opacity only. Tokens only (no raw colors).
   ===================================================================== */

.ak-header, .ak-footer, .ak-tabbar, .ak-sres {
  font-family: var(--font); font-weight: var(--fw-regular); line-height: var(--lh-base); color: var(--c-text-body);
}
.ak-header a, .ak-footer a, .ak-tabbar a { text-decoration: none; }
.ak-header ul, .ak-footer ul, .ak-tabbar ul { margin: 0; padding: 0; list-style: none; }
.ak-wrap { width: 100%; padding-inline: var(--gutter); }

/* ---------- Logo (one swappable component — see app.js LOGO) ---------- */
.ak-logo { display: inline-flex; align-items: center; min-height: 40px; color: var(--c-text); flex: none; }
.ak-logo img { height: 36px; width: auto; }
.ak-logo-word { font-size: 24px; font-weight: var(--fw-bold); line-height: 1; color: var(--c-text); }
.ak-logo-word b { color: var(--c-primary); font-weight: var(--fw-bold); margin-inline-start: 1px; }

/* ---------- Header (alkafeel.tv: transparent gradient → solid #171D22 when scrolled) ---------- */
.ak-header {
  position: fixed; inset-inline: 0; top: 0; z-index: var(--z-header);
  height: var(--header-h);
  background: linear-gradient(var(--c-header-top), var(--c-bg-a0));
  view-transition-name: site-header;
  transition: transform 220ms var(--ease);
}
.ak-header.is-hidden { transform: translateY(-100%); }   /* smart header (app.js): hidden while scrolling down */
@media (prefers-reduced-motion: reduce) { .ak-header { transition: none; } }
.ak-header::before {               /* solid layer fades in on scroll (opacity only) */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--c-header-a92); box-shadow: var(--sh-header);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  opacity: 0; transition: opacity var(--dur-2) var(--ease-out);
}
.ak-header.is-scrolled::before, .ak-header.is-solid::before, .ak-header.is-searching::before { opacity: 1; }
/* one row at every width. Grid: start = logo + language · center = main menu · end = search + account.
   Logo, language, nav and account never shrink or hide; only the search field gives way
   (it grows into the FREE space of the end column and shrinks when there is less). */
.ak-bar { position: relative; height: 100%; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: var(--sp-6); }
.ak-start { grid-column: 1; justify-self: start; display: flex; align-items: center; gap: var(--sp-3); }
.ak-logo { flex: none; height: 44px; }        /* same box height as the language button → exact same vertical center */

.ak-nav { display: none; grid-column: 2; }
.ak-nav li { flex: none; }
.ak-nav a { white-space: nowrap; }
.ak-actions { grid-column: 3; justify-self: end; max-width: 100%; min-width: 0; flex-wrap: nowrap; justify-content: flex-end; }
@media (max-width: 767px) {                 /* phones: no nav in the header; search may grow up to the logo */
  .ak-bar { grid-template-columns: auto minmax(0, 1fr); column-gap: var(--sp-3); }
  .ak-actions { grid-column: 2; }
}

/* ---------- Language menu (globe next to the logo) ---------- */
.ak-lang { position: relative; flex: none; }
/* language: current language name as text + chevron (44px high, same pill style as the icon buttons) */
.ak-lbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding-inline: var(--sp-4) var(--sp-3);
  border-radius: var(--r-pill); background: var(--c-white-a10); border: 1px solid var(--c-white-a16); color: var(--c-text);
  font: var(--fw-semi) var(--fs-14)/1 var(--font); white-space: nowrap; cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out);
}
.ak-lbtn svg { width: 16px; height: 16px; flex: none; color: var(--c-text-2); transition: transform var(--dur-2) var(--ease); }
.ak-lbtn[aria-expanded="true"] .ak-lchev { transform: rotate(180deg); }
.ak-lbtn .ak-lglobe { display: none; }
@media (max-width: 767px) {             /* phones: the language is a round globe button, same as search / account */
  .ak-lbtn { width: 44px; padding: 0; justify-content: center; border-radius: var(--r-round); }
  .ak-lbtn .ak-ltxt, .ak-lbtn .ak-lchev { display: none; }
  .ak-lbtn .ak-lglobe { display: block; width: 22px; height: 22px; stroke-width: 2.2; color: var(--c-text); }
  /* search open: language + account fade away under the field, which grows over them (app.js room() sets --so) */
  .ak-lang, .ak-ibtn-account { transition: opacity var(--dur-1) var(--ease-out), visibility 0s linear var(--dur-1), transform var(--dur-1) var(--ease-out); }
  .ak-header.is-searching .ak-lang, .ak-header.is-searching .ak-ibtn-account { opacity: 0; visibility: hidden; }
  .ak-search { transition: width var(--dur-3) var(--ease), margin-inline-end var(--dur-3) var(--ease); }
  .ak-header.is-searching .ak-search { margin-inline-end: calc(-1 * var(--so, 0px)); }
}
.ak-lbtn:hover { border-color: var(--c-primary); }
.ak-lbtn:active { transform: scale(.97); }
.ak-lbtn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.ak-lmenu {
  position: absolute; z-index: 4; top: calc(100% + var(--sp-2)); inset-inline-end: 0; min-width: 190px; margin: 0; padding: var(--sp-1);
  list-style: none; border-radius: var(--r-md); background: var(--c-surface-2); border: 1px solid var(--c-line-2); box-shadow: var(--sh-pop);
  opacity: 0; transform: translateY(-6px); transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease);
}
.ak-lmenu.is-open { opacity: 1; transform: none; }
.ak-lmenu button {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: 44px; padding: 0 var(--sp-3);
  border: 0; border-radius: var(--r-md); background: transparent; cursor: pointer;
  font: var(--fw-semi) var(--fs-15)/1.2 var(--font); color: var(--c-text-2); text-align: start;
}
.ak-lmenu button:hover, .ak-lmenu button:focus-visible { background: var(--c-white-a10); color: var(--c-text); outline: none; }
.ak-lmenu button:focus-visible { box-shadow: inset 0 0 0 2px var(--c-focus); }
.ak-lmenu svg { width: 18px; height: 18px; flex: none; color: var(--c-primary); }
.ak-lmenu [aria-checked="false"] svg { opacity: 0; }
.ak-lmenu [aria-checked="true"] { color: var(--c-text); }
.ak-actions > :not(.ak-search) { flex: none; }
.ak-nav ul { display: flex; align-items: center; gap: clamp(6px, 3vw - 9px, 40px); }   /* ~32px at 1366, ~34 at 1440, 40 at 1920 */
.ak-nav a {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding-inline: var(--sp-1);
  font-size: var(--fs-14); font-weight: var(--fw-bold); color: var(--c-text-nav); line-height: 1;
  transition: opacity var(--dur-2) var(--ease-out);
}
.ak-nav a:hover, .ak-nav a[aria-current="page"] { color: var(--c-primary); }
.ak-dot { width: 8px; height: 8px; border-radius: var(--r-round); background: var(--c-live); flex: none; animation: ak-pulse 2s ease-in-out infinite; }
@keyframes ak-pulse { 50% { opacity: .35; } }

.ak-actions { margin-inline-start: auto; display: flex; align-items: center; gap: var(--sp-3); }
/* round icon buttons (icons only, labels in aria-label): 44×44 target, near-white 22px icon on a subtle
   round background; hover = green fill with dark icon (4.9:1); focus-visible = green ring */
.ak-ibtn {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; padding: 0; border-radius: var(--r-round); cursor: pointer;
  background: var(--c-white-a10); border: 1px solid var(--c-white-a16); color: var(--c-text);
  transition: transform var(--dur-1) var(--ease-out);
}
.ak-ibtn svg { width: 22px; height: 22px; flex: none; stroke-width: 2.2; }
.ak-ibtn::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--c-primary); opacity: 0; transition: opacity var(--dur-2) var(--ease-out); }
.ak-ibtn:hover::before, .ak-ibtn[aria-expanded="true"]::before { opacity: 1; }
.ak-ibtn:hover { color: var(--c-on-primary); border-color: var(--c-primary); }
.ak-ibtn:active { transform: scale(.94); }
.ak-ibtn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.ak-actions { gap: var(--sp-2); }

/* ---------- Search: the icon grows into a field inside the header row ----------
   .ak-search is a flex item: closed = the 44px icon; open = up to 420px, shrinking to the free space.
   The pill background fades in (opacity); width animates the free space only — nothing else moves. */
.ak-search {
  position: relative; flex: 0 1 auto; min-width: 44px; width: 44px; height: 44px;
  transition: width var(--dur-3) var(--ease);
}
.ak-header.is-searching .ak-search { width: var(--sw, 420px); }
.ak-sfield {
  position: relative; isolation: isolate; display: flex; align-items: center; width: 100%; height: 100%;
  overflow: hidden; border-radius: var(--r-pill);
}
.ak-sfield::before {                     /* the field pill */
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: var(--c-bg); border: 1px solid var(--c-line); box-shadow: var(--sh-inset);
  opacity: 0; transition: opacity var(--dur-2) var(--ease-out);
}
.ak-header.is-searching .ak-sfield::before { opacity: 1; }
.ak-header.is-searching .ak-search .ak-ibtn-search { background: transparent; border-color: transparent; color: var(--c-primary); }
.ak-header.is-searching .ak-search .ak-ibtn-search::before { opacity: 0; }
.ak-sinput {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; padding: 0;
  font: var(--fw-semi) var(--fs-14)/1 var(--font); color: var(--c-text);
  opacity: 0; visibility: hidden; transition: opacity var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2);
}
.ak-sinput::placeholder { color: var(--c-text-dim); opacity: 1; }
.ak-sinput::-webkit-search-cancel-button { display: none; }
.ak-sclose {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; margin-inline-end: 2px;
  border: 0; border-radius: var(--r-round); background: transparent; color: var(--c-text-body); cursor: pointer;
  opacity: 0; visibility: hidden; transition: opacity var(--dur-2) var(--ease-out), visibility 0s linear var(--dur-2);
}
.ak-sclose svg { width: 18px; height: 18px; }
.ak-sclose:hover { color: var(--c-text); background: var(--c-white-a10); }
.ak-sclose:focus-visible { outline: 2px solid var(--c-focus); outline-offset: -2px; }
.ak-header.is-searching .ak-sinput, .ak-header.is-searching .ak-sclose { opacity: 1; visibility: visible; transition-delay: 80ms, 0s; }

/* results */
.ak-sres {
  position: absolute; top: calc(100% + var(--sp-2)); inset-inline-end: 0; z-index: 3;
  width: max(100%, min(380px, calc(100vw - 2 * var(--gutter))));
  max-height: min(420px, 70vh); overflow-y: auto; padding: var(--sp-2);
  border-radius: var(--r-lg); background: var(--c-surface-2); border: 1px solid var(--c-line-2); box-shadow: var(--sh-pop);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity var(--dur-1) var(--ease-out), transform var(--dur-2) var(--ease);
}
.ak-sres.is-open { opacity: 1; transform: none; pointer-events: auto; }
@media (max-width: 767px) {             /* phones: results span the header width (anchored to the bar) */
  .ak-search { position: static; }
  .ak-sres { inset-inline: var(--gutter); width: auto; }
}
.ak-sres a {
  display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: var(--sp-3);
  padding: var(--sp-2); border-radius: var(--r-md); color: var(--c-text);
}
.ak-sres a:hover, .ak-sres a:focus-visible, .ak-sres a[aria-selected="true"] { background: var(--c-white-a06); outline: none; }
.ak-sres img, .ak-sres picture { width: 72px; height: 41px; object-fit: cover; border-radius: var(--r-xs); background: var(--c-surface); }
.ak-sres strong { display: block; font-size: var(--fs-14); font-weight: var(--fw-semi); line-height: var(--lh-title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ak-sres small { display: block; font-size: var(--fs-12); color: var(--c-text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ak-sth { display: grid; place-items: center; width: 72px; height: 41px; border-radius: var(--r-xs); background: var(--c-surface); color: var(--c-primary); }
.ak-sres .ak-sempty { padding: var(--sp-3); font-size: var(--fs-14); color: var(--c-text-body); text-align: center; }

@media (min-width: 768px) {
  .ak-nav { display: block; }
}
/* tablet: six menu items + controls must fit on one row → the menu takes the space between the
   two side groups (centered there) and the text is a little smaller */
@media (min-width: 768px) and (max-width: 1199px) {
  .ak-bar { grid-template-columns: auto minmax(0, 1fr) auto; column-gap: var(--sp-4); }
  .ak-nav { justify-self: center; }
  .ak-nav ul { gap: clamp(6px, 2.4vw - 12px, 20px); }
  .ak-nav a { font-size: var(--fs-13); padding-inline: 2px; }
  .ak-nav .ak-dot { width: 6px; height: 6px; }
  html[lang="ckb"] .ak-nav a { font-size: var(--fs-12); padding-inline: 1px; }   /* the longest labels (Kurdish) */
}

/* ---------- Bottom tab bar (phones only, < 768px): الرئيسية · البرامج · البث المباشر · الأطفال ---------- */
.ak-tabbar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: var(--z-tabbar);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, minmax(44px, auto));   /* auto tracks stretch evenly; a long label gets the room it needs */
  background: var(--c-header-a92); border-top: 1px solid var(--c-line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  view-transition-name: tabbar;              /* stays put while pages change */
}
.ak-tabbar a, .ak-tabbar .ak-tab-acc {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-family: var(--font); font-size: var(--fs-11); font-weight: var(--fw-semi); color: var(--c-text-body);
  transition: opacity var(--dur-2) var(--ease-out);
}
.ak-tab-ic { position: relative; display: grid; place-items: center; width: 52px; height: 28px; }
.ak-tab-ic::before {                          /* active pill: scales in (transform / opacity) */
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: var(--r-pill);
  background: var(--c-primary-a20); opacity: 0; transform: scaleX(.5);
  transition: opacity var(--dur-2) var(--ease-out), transform var(--dur-3) var(--ease);
}
.ak-tabbar svg { width: 22px; height: 22px; transition: transform var(--dur-3) var(--ease); }
.ak-tabbar [aria-current="page"] { color: var(--c-primary); }
.ak-tabbar [aria-current="page"] .ak-tab-ic::before { opacity: 1; transform: none; view-transition-name: tab-pill; }
.ak-tabbar a:active svg { transform: scale(.9); }
.ak-tabbar .ak-dot { position: absolute; top: 3px; inset-inline-start: calc(50% + 9px); }
::view-transition-group(tab-pill) { animation-duration: var(--dur-3); animation-timing-function: var(--ease); }
body.has-aktabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
body.has-aktabbar .toast-region { bottom: calc(var(--tabbar-h) + var(--sp-3) + env(safe-area-inset-bottom)); }
/* a language whose six menu labels do not fit next to the controls (e.g. Kurdish on narrow tablets)
   gets the phone layout: compact header + bottom tab bar (app.js fitNav adds .is-compact / .nav-compact) */
.ak-header.is-compact .ak-nav { display: none; }
.ak-header.is-compact .ak-bar { grid-template-columns: auto minmax(0, 1fr); column-gap: var(--sp-3); }
.ak-header.is-compact .ak-actions { grid-column: 2; }
@media (min-width: 768px) {
  body:not(.nav-compact) .ak-tabbar { display: none; }
  body.has-aktabbar:not(.nav-compact) { padding-bottom: 0; }
  body.has-aktabbar:not(.nav-compact) .toast-region { bottom: var(--sp-6); }
}

/* ---------- Footer: ONE row of three columns — brand (start) · about / privacy / contact / FAQ (center) ·
   follow us + social icons (end) — then a thin divider and one small centered © line.
   Phones (< 768px): the three blocks stack, centered. Logical properties → English mirrors itself. ---------- */
.ak-footer { margin-top: var(--sec-gap); background: var(--c-footer); }
.ak-ftop { padding-block: var(--sp-6) var(--sp-3); }
.ak-frow { display: grid; gap: var(--sp-5); justify-items: center; text-align: center; }
.ak-fbrand { display: grid; gap: var(--sp-1); justify-items: center; }
.ak-fbrand .ak-logo { min-height: 40px; height: 40px; }
.ak-fabout { margin: 0; font-size: var(--fs-13); line-height: var(--lh-base); color: var(--c-text-body); }
.ak-flinks ul { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; }
.ak-flinks li { display: inline-flex; align-items: center; }
.ak-flinks button, .ak-fbottom button {
  display: inline-flex; align-items: center; min-height: 44px; padding-inline: var(--sp-2); border: 0; background: none; cursor: pointer;
  font: var(--fw-bold) var(--fs-14)/1.2 var(--font); color: var(--c-text-foot); white-space: nowrap; transition: opacity var(--dur-2) var(--ease-out);
}
.ak-flinks button:hover { color: var(--c-primary); }
.ak-fsep { color: var(--c-text-dim); padding-inline: 2px; }
.ak-social { display: grid; gap: var(--sp-2); justify-items: center; }
.ak-fh { margin: 0; font-size: var(--fs-13); font-weight: var(--fw-bold); color: var(--c-text); line-height: 1.2; }
.ak-social ul { display: flex; gap: var(--sp-4); }
.ak-social a {
  position: relative; isolation: isolate; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: var(--r-round); background: var(--c-bg); box-shadow: var(--sh-inset); color: var(--c-text-2);
}
.ak-social a::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--c-primary); opacity: 0; transition: opacity var(--dur-2) var(--ease-out); }
.ak-social a:hover::before { opacity: 1; }
.ak-social a:hover { color: var(--c-on-primary); }
.ak-social svg { width: 17px; height: 17px; }
.ak-fbottom { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--c-line); text-align: center; }
.ak-fbottom p { margin: 0; font-size: var(--fs-12); color: var(--c-text-body); }
.ak-footer a:focus-visible, .ak-footer button:focus-visible, .ak-nav a:focus-visible, .ak-logo:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 3px; border-radius: var(--r-xs); }
@media (min-width: 768px) {
  .ak-frow { grid-template-columns: auto 1fr auto; grid-template-areas: "brand links social"; align-items: center; column-gap: var(--sp-6); text-align: start; }
  .ak-fbrand { grid-area: brand; justify-self: start; justify-items: start; }
  .ak-fabout { white-space: nowrap; }   /* the long line stays on ONE line */
  .ak-flinks { grid-area: links; justify-self: center; }
  .ak-flinks ul { flex-wrap: nowrap; }
  .ak-social { grid-area: social; justify-self: end; justify-items: end; }
}
/* tablets: not enough room for three columns → brand + social on one line, the links centered under them */
@media (min-width: 768px) and (max-width: 1399px) {
  .ak-frow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand social" "links links"; row-gap: var(--sp-3); }
}
/* wide screens: equal side columns so the links sit in the exact center of the screen */
@media (min-width: 1400px) {
  .ak-frow { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .ak-ftop { padding-block: var(--sp-6) var(--sp-3); }
  .ak-flinks ul { column-gap: var(--sp-3); }
  .ak-flinks .ak-fsep { display: none; }      /* the links may wrap on phones: no dot at the start of a line */
}

/* sections rise + fade in once as they enter the screen (see app.js inView) */
.will-in { opacity: 0; transform: translateY(var(--rise)); }
.will-in.is-in { opacity: 1; transform: none; transition: opacity var(--dur-3) var(--ease), transform var(--dur-4) var(--ease); }

@media (prefers-reduced-motion: reduce) {
  .ak-dot { animation: none; }
  .will-in { opacity: 1; transform: none; }
}

/* ---------- PHONES (< 768px): readable tab labels, ≥ 44px footer targets and search close. Desktop unchanged. ---------- */
@media (max-width: 767px) {
  .ak-tabbar a, .ak-tabbar .ak-tab-acc { font-size: var(--fs-12); }
  .ak-social a { width: 44px; height: 44px; }
  .ak-fbrand .ak-logo { min-height: 44px; height: 44px; }
  .ak-sclose { width: 44px; height: 44px; }
  .ak-flinks button { min-width: 44px; justify-content: center; }
  /* search results: the subtitle (which tells apart works with the same title) may use two lines */
  .ak-sres small { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
}

/* account tab (phones): a button styled like the other tabs; highlighted while the sign-in sheet is open */
.ak-tab-acc { border: 0; background: none; padding: 0; cursor: pointer; min-width: 0; }
.ak-tab-acc.is-open { color: var(--c-primary); }
.ak-tab-acc.is-open .ak-tab-ic::before { opacity: 1; transform: none; }
.ak-tabbar a > span:last-child, .ak-tab-acc > span:last-child { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-inline: 2px; }
/* phones (and the compact header): the account icon leaves the header — it is the last tab instead */
@media (max-width: 767px) { .ak-header .ak-ibtn-account { display: none; } }
.ak-header.is-compact .ak-ibtn-account { display: none; }
@media (max-width: 400px) { .ak-tab-ic { width: 48px; } }
/* five tabs on narrow phones: the longest labels (English, Kurdish) get a slightly smaller font so every label stays on one line */
@media (max-width: 400px) { html[lang="en"] .ak-tabbar a, html[lang="en"] .ak-tabbar .ak-tab-acc, html[lang="ckb"] .ak-tabbar a, html[lang="ckb"] .ak-tabbar .ak-tab-acc { font-size: 11px; } }
