/* ==========================================================================
   OnNewsPortal — La Vie Health
   Offline reading library. Works fully offline via file:// — no external
   requests, self-hosted DM Sans loaded separately from assets/fonts/fonts.css.
   ========================================================================== */

/* ---------- Design tokens (La Vie template) ---------- */
:root {
  --onp-ink: #1E3337;        /* dark teal — headings, dark surfaces */
  --onp-gold: #CEB27C;       /* accents, hover, borders, rules (decorative) */
  --onp-gold-deep: #8a7346;  /* gold for TEXT on light surfaces (4.5:1+ on white) */
  --onp-beige: #EBE7E1;      /* warm beige bands / tints */
  --onp-paper: #FAF8F7;      /* off-white page background */
  --onp-secondary: #54595F;  /* secondary text */
  --onp-muted: #7A7A7A;      /* muted text */

  --onp-font: 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --onp-radius: 15px;
  --onp-shadow: 0 1px 2px rgba(30, 51, 55, 0.05), 0 6px 18px rgba(30, 51, 55, 0.06);
  --onp-shadow-hover: 0 2px 4px rgba(30, 51, 55, 0.06), 0 14px 34px rgba(30, 51, 55, 0.12);
  --onp-border: rgba(30, 51, 55, 0.09);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--onp-font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--onp-ink);
  background: var(--onp-paper);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

[hidden] {
  display: none !important;
}

img {
  max-width: 100%;
}

code {
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 0.9em;
  background: var(--onp-beige);
  border: 1px solid rgba(30, 51, 55, 0.08);
  border-radius: 6px;
  padding: 0.15em 0.45em;
  color: var(--onp-ink);
  white-space: nowrap;
}

/* Shared centered shell */
.onp-shell {
  width: min(1160px, 100% - 3rem);
  margin-inline: auto;
}

/* Accessible keyboard focus */
:focus-visible {
  outline: 2px solid var(--onp-gold);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Header ---------- */
.onp-header {
  background: var(--onp-paper);
  border-bottom: 1px solid var(--onp-beige);
}

.onp-header-inner {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 1.1rem 0;
}

.onp-logo {
  height: 44px;
  width: auto;
  flex: none;
}

.onp-header-rule {
  width: 1px;
  height: 38px;
  background: var(--onp-beige);
  flex: none;
}

.onp-wordmark {
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--onp-ink);
  line-height: 1.2;
}

.onp-wordmark-accent {
  color: var(--onp-gold-deep);
}

.onp-tagline {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--onp-muted);
  margin-top: 0.1rem;
}

/* ---------- Hero ---------- */
.onp-hero {
  background: linear-gradient(180deg, var(--onp-paper) 0%, var(--onp-beige) 130%);
  border-bottom: 1px solid var(--onp-beige);
  padding: 4.25rem 0 3.75rem;
}

.onp-hero-title {
  margin: 0;
  font-size: clamp(1.9rem, 1.35rem + 2.4vw, 2.9rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--onp-ink);
  max-width: 22ch;
}

.onp-hero-rule {
  width: 64px;
  height: 3px;
  border-radius: 2px;
  background: var(--onp-gold);
  margin: 1.15rem 0 1.15rem;
}

.onp-hero-sub {
  margin: 0;
  max-width: 58ch;
  font-size: 1.05rem;
  color: var(--onp-secondary);
}

/* ---------- Main / toolbar ---------- */
.onp-main {
  flex: 1;
  padding: 2.25rem 0 4rem;
}

.onp-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.onp-search-wrap {
  position: relative;
  flex: 1 1 260px;
  max-width: 440px;
  display: block;
  color: var(--onp-muted);
}

.onp-search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  pointer-events: none;
}

.onp-search {
  width: 100%;
  font: inherit;
  font-size: 0.95rem;
  color: var(--onp-ink);
  background: #FFFFFF;
  border: 1px solid var(--onp-border);
  border-radius: 999px;
  padding: 0.62rem 1.1rem 0.62rem 2.6rem;
  box-shadow: 0 1px 2px rgba(30, 51, 55, 0.04);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.onp-search::placeholder {
  color: var(--onp-muted);
}

.onp-search:focus {
  outline: none;
  border-color: var(--onp-gold);
  box-shadow: 0 0 0 3px rgba(206, 178, 124, 0.25);
}

.onp-count {
  flex: none;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--onp-secondary);
  background: var(--onp-beige);
  border: 1px solid rgba(30, 51, 55, 0.06);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  white-space: nowrap;
}

/* ---------- Cards grid ---------- */
.onp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

/* ---------- Card ---------- */
.onp-card {
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border: 1px solid var(--onp-border);
  border-radius: var(--onp-radius);
  box-shadow: var(--onp-shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.onp-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--onp-shadow-hover);
  border-color: var(--onp-gold);
}

.onp-card:focus-visible {
  outline: 2px solid var(--onp-gold);
  outline-offset: 3px;
  border-radius: var(--onp-radius);
}

/* 16:9 thumbnail area */
.onp-thumb {
  aspect-ratio: 16 / 9;
  background: var(--onp-ink);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onp-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 260ms ease;
}

.onp-card:hover .onp-thumb img {
  transform: scale(1.03);
}

/* Fallback avatar — big DM Sans initial, gold on dark teal */
.onp-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--onp-gold);
  background: var(--onp-ink);
  user-select: none;
}

/* Card body */
.onp-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1.05rem 1.15rem 1.05rem;
  flex: 1;
}

.onp-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.35;
  color: var(--onp-ink);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.onp-desc {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--onp-muted);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* Meta row */
.onp-meta {
  margin-top: auto;
  padding-top: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
}

.onp-domain {
  font-variant-caps: all-small-caps;
  letter-spacing: 0.09em;
  font-weight: 600;
  color: var(--onp-gold-deep);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.onp-date {
  color: var(--onp-muted);
  white-space: nowrap;
}

.onp-badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--onp-gold-deep);
  background: rgba(206, 178, 124, 0.14);
  border: 1px solid var(--onp-gold);
  border-radius: 999px;
  padding: 0.16rem 0.6rem;
  white-space: nowrap;
}

/* ---------- Empty state ---------- */
.onp-empty {
  margin: 2.5rem auto 0;
  max-width: 520px;
  text-align: center;
  background: var(--onp-beige);
  border: 1px solid rgba(30, 51, 55, 0.07);
  border-radius: var(--onp-radius);
  padding: 3rem 2rem 2.75rem;
}

.onp-empty-icon {
  width: 46px;
  height: 46px;
  color: var(--onp-gold);
}

.onp-empty-title {
  margin: 1rem 0 0.4rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--onp-ink);
}

.onp-empty-hint {
  margin: 0;
  font-size: 0.92rem;
  color: var(--onp-secondary);
}

/* ---------- No-results state (search) ---------- */
.onp-noresults {
  margin-top: 2rem;
  text-align: center;
}

.onp-noresults-text {
  margin: 0;
  font-size: 0.95rem;
  color: var(--onp-muted);
}

/* ---------- Footer ---------- */
.onp-footer {
  border-top: 1px solid var(--onp-beige);
  padding: 1.1rem 0;
  font-size: 0.8rem;
  color: var(--onp-muted);
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 480px) {
  .onp-shell {
    width: calc(100% - 2rem);
  }

  .onp-hero {
    padding: 3rem 0 2.6rem;
  }

  .onp-header-rule {
    display: none;
  }

  .onp-logo {
    height: 38px;
  }

  .onp-count {
    margin-left: auto;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .onp-card,
  .onp-thumb img,
  .onp-search {
    transition: none;
  }

  .onp-card:hover {
    transform: none;
  }

  .onp-card:hover .onp-thumb img {
    transform: none;
  }
}
