/* Layout: a digital newsstand. A dark bar on top, a shelf of today's front pages,
   then the day's top stories and one sliding rail per topic. Nav sits at the thumb on phones. */
:root {
  --page: #ffffff;
  --shelf: #f2f1ee;      /* the kiosk counter the covers stand on */
  --card: #ffffff;
  --ink: #141414;
  --muted: #5f5f5f;
  --rule: #e4e2dd;
  --bar: #121212;        /* top bar */
  --bar-ink: #f4f2ee;
  --bar-muted: #a9a6a0;
  --accent: #e2482b;     /* laterite, the Red Island's soil */
  --leaf: #1f6b4a;
  --chip: #efeee9;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.10);

  --f-head: "Newsreader", "Iowan Old Style", Georgia, serif;
  --f-ui: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;

  --s-xs: 0.75rem;
  --s-sm: 0.875rem;
  --s-md: 1rem;
  --s-lg: 1.2rem;
  --s-xl: 1.6rem;
  --s-2xl: 2.2rem;
  --radius: 10px;
  --nav-h: 3.5rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0f0f0f; --shelf: #1a1a19; --card: #1c1c1b; --ink: #eeece8; --muted: #a3a09a; --rule: #2c2b29;
    --bar: #000000; --accent: #f06a4d; --leaf: #6cc79a; --chip: #262624; --on-accent: #0f0f0f;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.5); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --page: #0f0f0f; --shelf: #1a1a19; --card: #1c1c1b; --ink: #eeece8; --muted: #a3a09a; --rule: #2c2b29;
  --bar: #000000; --accent: #f06a4d; --leaf: #6cc79a; --chip: #262624; --on-accent: #0f0f0f;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.5); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 400 var(--s-md)/1.5 var(--f-ui);
  padding-bottom: calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap, .bar-in { max-width: 1240px; margin-inline: auto; padding-inline: 16px; }
@media (min-width: 760px) { .wrap, .bar-in { padding-inline: 28px; } }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 5; background: var(--bar); color: var(--bar-ink); padding-top: env(safe-area-inset-top, 0px); }
.bar-in:first-child { display: flex; align-items: center; gap: 0.75rem; min-height: 3.5rem; }
.brand {
  flex: 1; min-width: 0; text-decoration: none;
  font: 700 1.6rem/1 var(--f-head); letter-spacing: -0.02em;
}
.brand::after { content: "."; color: var(--accent); }
.tools { display: flex; gap: 0.4rem; align-items: center; }
.icon-btn {
  border: 1px solid #3a3a3a; background: transparent; color: var(--bar-ink); border-radius: 999px;
  min-height: 2.25rem; padding: 0 0.75rem; display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--s-sm); cursor: pointer; font-weight: 700;
}
.icon-btn[aria-pressed="true"] { background: var(--bar-ink); color: var(--bar); border-color: var(--bar-ink); }
.icon-btn svg { width: 1rem; height: 1rem; }

/* Topic tabs: text with an underline, scrolling sideways */
.topics { display: flex; gap: 1.25rem; overflow-x: auto; scrollbar-width: none; border-top: 1px solid #262626; }
.topics::-webkit-scrollbar { display: none; }
.topic {
  flex: none; border: 0; background: none; color: var(--bar-muted); cursor: pointer; white-space: nowrap;
  padding: 0.7rem 0 0.6rem; font-size: var(--s-sm); font-weight: 700; border-bottom: 3px solid transparent;
}
.topic:hover { color: var(--bar-ink); }
.topic[aria-pressed="true"] { color: var(--bar-ink); border-bottom-color: var(--accent); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; padding-block: 1.1rem 0.25rem; }
.dateline { flex: 1 1 100%; margin: 0; font-size: var(--s-sm); color: var(--muted); }
.dateline::first-letter { text-transform: uppercase; }
@media (min-width: 900px) { .dateline { flex: 1 1 auto; } }
.seg { display: inline-flex; background: var(--chip); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: none; padding: 0.3rem 0.8rem; font-size: var(--s-sm); cursor: pointer; border-radius: 999px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--page); font-weight: 700; }
.search { flex: 1 1 12rem; min-width: 0; max-width: 22rem; }
.search input {
  width: 100%; border: 0; border-radius: 999px; background: var(--chip);
  padding: 0.45rem 1rem; font-size: var(--s-sm);
}
.status-line { font-size: var(--s-xs); color: var(--muted); margin: 0; padding-block: 0.25rem 0.5rem; }
.status-line.warn { color: var(--accent); font-weight: 700; }

/* Sections */
.sec { padding-block: 1.25rem 0.5rem; }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.sec-title { margin: 0; min-width: 0; font: 700 var(--s-xl)/1.1 var(--f-ui); letter-spacing: -0.01em; overflow-wrap: anywhere; }
@media (max-width: 420px) { .sec-title { font-size: 1.35rem; } }
.see-all {
  border: 0; background: none; cursor: pointer; font-size: var(--s-sm); font-weight: 700; color: var(--muted);
  display: inline-flex; align-items: center; gap: 0.1rem; white-space: nowrap; padding: 0.25rem 0; flex: none;
}
.see-all:hover { color: var(--ink); }
.see-all svg { width: 1rem; height: 1rem; }

/* Sideways scrollers bleed to the screen edge */
.shelf, .rail {
  display: grid; grid-auto-flow: column; gap: 1rem; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding-inline: 16px; scrollbar-width: thin;
  margin-inline: -16px; padding-inline: 16px;
}
@media (min-width: 760px) { .shelf, .rail { margin-inline: -28px; padding-inline: 28px; scroll-padding-inline: 28px; } }
.shelf > *, .rail > * { scroll-snap-align: start; }

/* The kiosk shelf: generated front pages */
.shelf {
  grid-auto-columns: 9.5rem; padding-block: 1.25rem 1rem; background: var(--shelf);
  border-radius: 0;
}
@media (min-width: 760px) { .shelf { grid-auto-columns: 11.5rem; } }
.cover { text-decoration: none; display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.cover-page {
  aspect-ratio: 3 / 4; background: #fbfaf6; color: #161616; border-radius: 3px; overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; margin-bottom: 0.5rem;
  transition: transform .15s ease, box-shadow .15s ease;
}
.cover:hover .cover-page { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(0,0,0,.1), 0 14px 30px rgba(0,0,0,.16); }
.cover-mast {
  background: var(--c); color: #fff; padding: 0.45rem 0.5rem 0.35rem;
  display: flex; flex-direction: column; gap: 0.1rem;
}
.cover-name {
  font: 700 0.95rem/1.05 var(--f-head); letter-spacing: -0.01em; text-transform: uppercase;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-date { font-size: 0.6rem; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; }
.cover-pic { aspect-ratio: 4 / 3; background: var(--c); flex: none; overflow: hidden; }
.cover-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-pic .ph { font-size: 0.8rem; }
.cover-lead {
  margin: 0; padding: 0.45rem 0.5rem 0.2rem; font: 700 0.85rem/1.15 var(--f-head);
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
  border-bottom: 1px solid #ddd9cf;
}
.cover-page.nopic .cover-lead { font-size: 1.05rem; -webkit-line-clamp: 6; padding-top: 0.6rem; }
.cover-more { list-style: none; margin: 0; padding: 0.25rem 0.5rem; overflow: hidden; flex: 1; }
.cover-more li {
  font: 500 0.66rem/1.25 var(--f-head); color: #444; padding-block: 0.2rem; border-bottom: 1px solid #ebe8df;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cover-cap { font-weight: 700; font-size: var(--s-sm); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cover-sub { font-size: var(--s-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Picture placeholder: the paper's ink with its name */
.ph {
  width: 100%; height: 100%; display: flex; align-items: flex-end; padding: 0.6rem 0.75rem;
  background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 55%, #000));
  font: 700 var(--s-lg)/1.05 var(--f-head); color: #fff; text-transform: uppercase; letter-spacing: -0.01em;
}

/* Source badge */
.badge { display: inline-flex; align-items: center; gap: 0.4rem; font-size: var(--s-xs); font-weight: 700; letter-spacing: 0.02em; min-width: 0; }
.badge i {
  font-style: normal; flex: none; width: 1.25rem; height: 1.25rem; border-radius: 4px; background: var(--c); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font: 700 0.75rem/1 var(--f-head);
}

/* À la une: one big story, four beside it */
.hero { display: grid; gap: 1rem; }
@media (min-width: 900px) { .hero { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); } }
.hero-main { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--c); color: #fff; min-height: 18rem; }
.hero-link { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-height: inherit; text-decoration: none; }
.hero-pic { position: absolute; inset: 0; }
.hero-pic img, .hero-pic .ph { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-pic::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.88) 0%, rgba(0,0,0,.55) 45%, rgba(0,0,0,0) 75%); }
@media (min-width: 900px) { .hero-main { min-height: 26rem; } }
.hero-text { position: relative; padding: 1.25rem 3.5rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; }
.hero-main .badge i { background: #fff; color: var(--c); }
.hero-title { margin: 0; font: 700 var(--s-xl)/1.12 var(--f-head); letter-spacing: -0.01em; text-wrap: balance; }
@media (min-width: 900px) { .hero-title { font-size: var(--s-2xl); } }
.hero-link:hover .hero-title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.hero-sum { margin: 0; font-size: var(--s-sm); opacity: 0.9; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; max-width: 60ch; }
.hero-text time { font-size: var(--s-xs); opacity: 0.8; }
.hero-main.nopic { min-height: 0; }
.hero-main.nopic .hero-link { justify-content: center; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 60%, #000)); }
.hero-main.nopic .hero-text { padding-block: 2rem 1.75rem; }
@media (min-width: 900px) { .hero-main.nopic .hero-text { padding: 2.5rem 4rem 2.5rem 2.5rem; } .hero-main.nopic .hero-title { font-size: 2.6rem; } }
.hero-side { list-style: none; margin: 0; padding: 0; display: grid; align-content: start; }
.hero-side li { border-bottom: 1px solid var(--rule); }
.hero-side li:first-child { border-top: 1px solid var(--rule); }
@media (min-width: 900px) { .hero-side li:first-child { border-top: 0; } }
.hero-side a { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.8rem 0; text-decoration: none; }
.hs-title { font: 600 var(--s-lg)/1.2 var(--f-head); }
.hero-side a:hover .hs-title { text-decoration: underline; text-underline-offset: 3px; }
.hero-side time { font-size: var(--s-xs); color: var(--muted); }

/* Magazine cards, in rails and in grids */
.rail { grid-auto-columns: min(78vw, 17rem); padding-bottom: 0.75rem; }
.grid { display: grid; gap: 1.5rem 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); padding-top: 0.75rem; }
.card { display: flex; flex-direction: column; min-width: 0; }
.card-link { display: flex; flex-direction: column; gap: 0.6rem; text-decoration: none; flex: 1; }
.card-pic { aspect-ratio: 16 / 10; border-radius: var(--radius); overflow: hidden; background: var(--c); }
.card-pic img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.card-link:hover .card-pic img { transform: scale(1.03); }
.card-body { display: flex; flex-direction: column; gap: 0.4rem; }
.card-title { margin: 0; font: 700 var(--s-lg)/1.22 var(--f-head); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card-link:hover .card-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.card-sum { margin: 0; color: var(--muted); font-size: var(--s-sm); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card.textonly { border-top: 4px solid var(--c); padding-top: 0.75rem; }
.card.textonly .card-sum { -webkit-line-clamp: 4; }
.card-foot { display: flex; justify-content: space-between; align-items: center; font-size: var(--s-xs); color: var(--muted); margin-top: 0.25rem; }
.topic-tag { color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.lang {
  font-size: 0.62rem; letter-spacing: 0.08em; font-weight: 700; border-radius: 3px; padding: 0.02rem 0.28rem;
  border: 1px solid currentColor; margin-left: 0.15rem;
}
.lang.mg { color: var(--leaf); }
.lang.fr { color: var(--muted); }
.save {
  border: 0; background: none; cursor: pointer; color: var(--muted); flex: none;
  min-width: 2.5rem; min-height: 2.5rem; margin-right: -0.6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px;
}
.save:hover { color: var(--ink); }
.save[aria-pressed="true"] { color: var(--accent); }
.save svg { width: 1.15rem; height: 1.15rem; }
.save.on-dark { position: absolute; top: 0.6rem; right: 0.6rem; margin: 0; color: #fff; background: rgba(0,0,0,.35); }
.save.on-dark[aria-pressed="true"] { color: #fff; background: var(--accent); }

.more { display: flex; justify-content: center; padding-block: 1.5rem; }
.btn { border: 0; background: var(--ink); color: var(--page); border-radius: 999px; padding: 0.65rem 1.5rem; cursor: pointer; font-weight: 700; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 3rem 1rem; background: var(--shelf); border-radius: var(--radius); }

/* An open issue: the paper's masthead across the top */
.back {
  border: 0; background: none; cursor: pointer; font-weight: 700; font-size: var(--s-sm); color: var(--muted);
  display: inline-flex; align-items: center; gap: 0.2rem; padding: 1rem 0 0.5rem; margin-left: -0.3rem;
}
.back svg { width: 1.1rem; height: 1.1rem; }
.back:hover { color: var(--ink); }
.issue-head { background: var(--c); color: #fff; border-radius: var(--radius); padding: 1.5rem 1.25rem 1.1rem; margin-bottom: 0.75rem; }
.issue-name { margin: 0; font: 700 clamp(1.9rem, 6vw, 3.4rem)/1 var(--f-head); text-transform: uppercase; letter-spacing: -0.02em; }
.issue-sub { margin: 0.6rem 0 0; font-size: var(--s-sm); opacity: 0.9; padding-top: 0.6rem; border-top: 1px solid rgba(255,255,255,.35); }
.issue-sub::first-letter { text-transform: uppercase; }

/* Saved and sources panels */
.panel-title { font: 700 var(--s-xl)/1.2 var(--f-ui); margin: 1.5rem 0 0.25rem; }
.panel-lede { color: var(--muted); margin: 0 0 1rem; max-width: 65ch; font-size: var(--s-sm); }
.src-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.src-row { background: var(--shelf); border-radius: var(--radius); display: flex; align-items: center; gap: 0.8rem; padding: 0.75rem 1rem; }
.src-mono {
  flex: none; width: 2.6rem; height: 3.4rem; border-radius: 3px; background: var(--c); color: #fff; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; font: 700 1.3rem/1 var(--f-head);
}
.src-info { flex: 1; min-width: 0; }
.src-name { font-weight: 700; }
.src-sub { font-size: var(--s-xs); color: var(--muted); display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.src-state { display: inline-flex; align-items: center; gap: 0.35rem; }
.dot { flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; display: inline-block; background: var(--leaf); }
.dot.bad { background: var(--accent); }
.switch { position: relative; width: 2.6rem; height: 1.5rem; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--rule); transition: background 0.15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 0.2rem; left: 0.2rem; width: 1.1rem; height: 1.1rem; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { transform: translateX(1.1rem); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.about { font-size: var(--s-xs); color: var(--muted); max-width: 65ch; padding-block: 2rem 0; }

/* Data saver: no pictures anywhere */
.no-images .card-pic, .no-images .cover-pic, .no-images .hero-pic { display: none; }

/* Tabs: bottom bar on phones, inline in the top bar on wider screens */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; background: var(--bar); border-top: 1px solid #262626;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  flex: 1; height: var(--nav-h); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
  font-size: var(--s-xs); color: var(--bar-muted);
}
.tab svg { width: 1.3rem; height: 1.3rem; }
.tab[aria-current="page"] { color: var(--bar-ink); font-weight: 700; }
.tab[aria-current="page"] svg { color: var(--accent); }
@media (min-width: 760px) {
  body { padding-bottom: 2rem; }
  .tabs { position: static; border: 0; background: none; padding: 0; gap: 0.25rem; }
  .tab { flex-direction: row; gap: 0.4rem; height: 2.25rem; padding: 0 0.85rem; font-size: var(--s-sm); border-radius: 999px; flex: none; }
  .tab:hover { color: var(--bar-ink); }
  .tab[aria-current="page"] { background: #2a2a2a; }
}
@media (max-width: 420px) { .icon-btn .lbl { display: none; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
