/* RetroFM shared styles: page chrome (body, header, footer, store button).
   Page-specific CSS stays in each template's page_styles block.

   Breakpoints (CSS variables cannot be used in @media, so this is the single reference):
     600px   phones        max-width: 600px
     768px   tablets       max-width: 768px / min-width: 769px
     1024px  desktop       min-width: 1024px / max-width: 1023px
   Use only these three. Test at 360px, 768px and 1280px. */

/* Fonts (self-hosted, SIL OFL 1.1; see the LICENSE file in each folder under static/fonts/).
   Each family is split into a Bengali and a Latin subset, so a page only
   downloads the subsets its text actually uses. */
@font-face {
  font-family: 'Noto Sans Bengali';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/noto-sans-bengali/noto-sans-bengali-bengali-wght.woff2') format('woff2');
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1;
}

@font-face {
  font-family: 'Noto Sans Bengali';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/noto-sans-bengali/noto-sans-bengali-latin-wght.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Tiro Bangla';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/tiro-bangla/tiro-bangla-bengali-400.woff2') format('woff2');
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1;
}

@font-face {
  font-family: 'Tiro Bangla';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/tiro-bangla/tiro-bangla-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Design tokens. Change a value here and every page follows. */
:root {
  /* Colours */
  --color-bg: #000;
  --color-surface: #111;            /* header, footer, content panels */
  --color-surface-card: #1c1c1c;
  --color-surface-raised: #333;     /* cards, secondary buttons */
  --color-surface-hover: #555;
  --color-text: #fff;
  --color-text-muted: #ccc;
  --color-text-subtle: #aaa;
  --color-border: #ddd;
  --color-accent: #d93a2b;          /* primary actions: button fills, active states */
  --color-accent-text: #ff6b5e;     /* accent-coloured text on dark surfaces (6.8:1 on #111) */
  --color-accent-hover: #b82e21;
  --color-success: #0f9d58;
  --color-success-hover: #0c7a45;
  --color-facebook: #1877f2;
  --color-instagram: #e4405f;
  --color-youtube: #ff0000;
  --color-whatsapp: #25d366;

  /* Translucent overlays */
  --tint: rgba(255, 255, 255, 0.1);
  --scrim: rgba(0, 0, 0, 0.5);
  --scrim-strong: rgba(0, 0, 0, 0.7);
  --shadow-card: 0 4px 8px rgba(0, 0, 0, 0.2);
  --gradient-hero: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.65) 55%, rgba(0, 0, 0, 0) 100%);

  /* Radius */
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-card: 10px;
  --radius-pill: 16px;
  --radius-round: 50%;

  /* Spacing scale */
  --space-1: 5px;
  --space-2: 10px;
  --space-3: 15px;
  --space-4: 20px;
  --space-5: 40px;
  --gutter: 16px;           /* side padding of page content */
  /* Typography */
  --font-body: 'Noto Sans Bengali', 'Nirmala UI', 'Vrinda', Arial, sans-serif;
  --font-heading: 'Tiro Bangla', 'Noto Sans Bengali', 'Nirmala UI', Georgia, serif;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 20px;
  --text-xl: 28px;
  --text-2xl: 40px;
  --leading-body: 1.6;      /* Bengali conjuncts and vowel signs need more room than Latin */
  --leading-heading: 1.4;
}


body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  margin: 0;
  padding: 0;
}

/* Opt in with body_class to keep the footer at the bottom of short pages */
body.sticky-footer {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.sticky-footer .page {
  flex: 1;
}

/* Page content sits in side gutters; header, footer and banners run edge to edge */
.page {
  padding-inline: var(--gutter);
}

/* Opt out of the gutters for banners that should reach the screen edges */
.page .full-bleed {
  width: auto;
  max-width: none;
  margin-inline: calc(var(--gutter) * -1);
  border-radius: 0;
}

/* Inline SVG icons (see icon() and static/icons.svg): sized by font-size, coloured by the text colour */
.icon {
  flex: none;
  width: 1.25em;
  height: 1em;
  fill: currentColor;
  vertical-align: -0.125em;
  overflow: visible;
}

/* Form controls do not inherit the page font by default */
button,
input,
select,
textarea {
  font-family: inherit;
}

/* Headings use Tiro Bangla, which ships only a regular weight: keep it at 400 and
   stop browsers from synthesising a (distorted) bold. */
h1,
h2 {
  font-family: var(--font-heading);
  font-weight: 400;
  font-synthesis: none;
  line-height: var(--leading-heading);
}

h1 {
  font-size: var(--text-xl);
}

h2 {
  font-size: var(--text-lg);
}
a {
  text-decoration: none;
  color: var(--color-text);
}

/* Bootstrap (loaded on some pages) turns hovered links blue; keep them ours.
   Components set their own hover look with a more specific rule. */
a:hover {
  color: var(--color-text);
}

/* Keyboard focus: one visible ring for every interactive element, in the brand accent.
   Mouse clicks do not trigger :focus-visible, so pointer users never see it. */
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--color-accent-text);
  outline-offset: 2px;
  box-shadow: none;
}

/* Header */
header {
  background-color: var(--color-surface);
  padding: var(--space-4) var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header .logo {
  display: flex;
  align-items: center;
}

header .logo a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

header .logo img {
  height: 40px;
  margin-right: var(--space-2);
  border-radius: var(--radius-card);
}

/* Google Play install button (header and footer) */
.store-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #202124 0%, #0d0d0d 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  color: var(--color-text);
  line-height: 1;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.store-button:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.45);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.store-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px var(--scrim);
}

.store-button .store-button__icon {
  width: 22px;
  height: 24px;
  flex-shrink: 0;
}

.store-button .store-button__text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.store-button .store-button__text small {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.store-button .store-button__text strong {
  font-size: 15px;
  font-weight: 600;
}

/* Grid of story cards (category and profile pages) */
.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-2) 0;
}

@media (max-width: 600px) {
  .story-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .story-grid .story-card {
    padding: var(--space-2);
  }
}

/* Page transition: story links fade out before navigating (see js/site.js) */
.fullscreen-zoom-fade {
  animation: zoomFade 0.5s forwards;
}

@keyframes zoomFade {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* Story card: one component for the home rows, category grid and 404 */
.story-card {
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: var(--space-3);
  background-color: var(--color-surface-raised);
  border: 1px solid transparent;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.story-card:hover,
.story-card:focus-visible {
  transform: translateY(-4px);
  border-color: var(--color-surface-hover);
}

/* Covers are almost all square, so a 1:1 crop keeps the printed titles intact */
.story-card .cover {
  display: block;
  width: 100%;
  height: auto; /* otherwise the width/height attributes (set to avoid layout shift) fix the height at 400px */
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-card);
  background-color: var(--color-surface);
}

.story-card .card-title {
  margin: var(--space-2) 0 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  /* Two lines at most; the author sits right under the title, and any slack goes above the pinned stats */
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.story-card .card-author {
  margin: var(--space-1) 0 0;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-card .card-info {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: auto; /* pins the stats to the bottom so cards of different title length match */
  padding-top: var(--space-2);
}

.story-card .card-info p {
  margin: 0;
  display: flex;
  align-items: center;
  background-color: var(--tint);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.story-card .card-info .icon {
  width: 1em;
  margin-right: var(--space-1);
}

@media (prefers-reduced-motion: reduce) {
  .story-card {
    transition: none;
  }

  .story-card:hover,
  .story-card:focus-visible {
    transform: none;
  }
}

/* Buttons: one primary action per screen, outlined secondary, text-only tertiary */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px var(--space-4);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s;
}
/* One primary action per screen */
.btn-primary {
  padding: 14px 28px;
  background-color: var(--color-accent);
  font-size: var(--text-lg);
  font-weight: 600;
}
.btn-primary:hover {
  background-color: var(--color-accent-hover);
}
/* Secondary: outlined, so it never competes with the primary fill */
.btn-secondary {
  border-color: var(--color-success);
}
.btn-secondary:hover {
  background-color: var(--color-success);
}
/* Tertiary: text only */
.btn-ghost {
  color: var(--color-text-muted);
}
.btn-ghost:hover {
  color: var(--color-text);
  text-decoration: underline;
}

/* Round icon-only button (carousel and row arrows). 44px is the minimum comfortable tap target. */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-round);
  background-color: var(--scrim);
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.3s;
}

.icon-btn:hover:not(:disabled) {
  background-color: var(--color-surface-hover);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Header search + category chips */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

header {
  gap: var(--space-4);
}

.site-search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin: 0 auto;
}

.site-search[hidden] {
  display: none;
}

.site-search input[type="search"] {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-3);
  background-color: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-surface-hover);
  border-radius: 22px;
  font-size: var(--text-base);
}

.site-search input[type="search"]::placeholder {
  color: var(--color-text-subtle);
}

.site-search input[type="search"]:focus {
  outline: 2px solid var(--color-accent-text);
  outline-offset: 1px;
}

.site-search-results {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(60vh, 420px);
  margin: 0;
  padding: var(--space-1);
  overflow-y: auto;
  list-style: none;
  background-color: var(--color-surface);
  border: 1px solid var(--color-surface-hover);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.site-search-results[hidden] {
  display: none;
}

.site-search-results li {
  border-radius: var(--radius-sm);
}

.site-search-results li a {
  display: block;
  padding: var(--space-2) var(--space-3);
  color: var(--color-text);
}

.site-search-results li[aria-selected="true"],
.site-search-results li:hover {
  background-color: var(--tint);
}

.site-search-results .result-meta {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

.site-search-results .no-results {
  padding: var(--space-2) var(--space-3);
  color: var(--color-text-subtle);
}

.category-nav {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--gutter) 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-nav::-webkit-scrollbar {
  display: none;
}

.category-nav a,
.chip-list a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--space-3);
  background-color: var(--color-surface);
  border: 1px solid var(--color-surface-raised);
  border-radius: 22px;
  font-size: var(--text-sm);
  white-space: nowrap;
}

.category-nav a:hover,
.chip-list a:hover {
  background-color: var(--color-surface-raised);
}

/* The same chips, wrapped onto several lines (404 page) */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A search box that sits in the page body instead of the header */
.site-search.site-search--page {
  max-width: 480px;
  margin: var(--space-4) auto;
}

.category-nav a[aria-current="page"] {
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    padding: var(--space-3) var(--gutter);
  }

  .site-search {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }
}

/* Breadcrumbs */
.breadcrumbs { padding: 0 var(--gutter); font-size: 14px; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; column-gap: 6px; }
.breadcrumbs li { display: flex; align-items: center; min-height: 44px; }
.breadcrumbs li + li::before { content: "\203A"; margin-right: 6px; color: var(--color-text-subtle); }
.breadcrumbs a { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; color: var(--color-text-muted); }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs [aria-current] { color: var(--color-text); }

/* Footer: brand blurb, link groups, app + social, then the copyright bar */
footer {
  background-color: var(--color-surface);
  padding: var(--space-5) var(--gutter) var(--space-4);
  margin-top: var(--space-5);
}

footer .footer-inner {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1.2fr;
  gap: var(--space-5) var(--space-4);
  max-width: 1200px;
  margin: 0 auto;
}

footer .footer-heading {
  margin: 0 0 var(--space-2);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

footer .footer-heading--brand {
  font-size: var(--text-lg);
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-text);
}

footer .footer-heading--follow {
  margin-top: var(--space-4);
}

footer .footer-brand p {
  margin: 0;
  max-width: 36ch;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

footer .footer-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

footer .footer-list a {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  font-size: var(--text-sm);
}

footer .footer-list a:hover,
footer .footer-bottom a:hover {
  text-decoration: underline;
}

footer .social-media-links {
  display: flex;
  margin-left: -8px; /* the icon is 28px inside a 44px target: line it up with the column edge */
}

footer .social-media-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

footer .social-media-links .social-facebook { color: var(--color-facebook); }
footer .social-media-links .social-instagram { color: var(--color-instagram); }
footer .social-media-links .social-youtube { color: var(--color-youtube); }
footer .social-media-links .social-whatsapp { color: var(--color-whatsapp); }

footer .social-media-links .icon {
  width: 28px;
  height: 28px;
}

footer .footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
  max-width: 1200px;
  margin: var(--space-4) auto 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-surface-raised);
}

footer .footer-bottom p {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
}

footer .footer-bottom a {
  color: var(--color-text-muted);
}

@media (max-width: 1023px) {
  footer .footer-inner {
    grid-template-columns: repeat(3, 1fr);
  }

  footer .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  footer {
    padding-top: var(--space-4);
  }

  footer .footer-inner {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  footer .footer-app {
    grid-column: 1 / -1;
  }

  footer .footer-bottom {
    flex-direction: column;
  }
}

/* Reduced motion: no animation or smooth scrolling anywhere. Individual components
   also have their own rules above. */
@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;
  }

  .store-button {
    transition: none;
  }

  .store-button:hover,
  .store-button:active {
    transform: none;
  }
}
