/* Public edition page — direction 1b "Briefing" */
:root {
  --bg: #f4f4f2; --surface: #ffffff; --border: #e6e6e3; --divider: #eeeeeb; --chip-border: #dcdcd8;
  --text: #17181a; --body: #3c3d42; --muted: #6f7075; --disabled: #b3b3ae;
  --accent: #2f6db3; --accent-tint: #e8f0fa; --audio-bg: #eef3fa; --audio-border: #9db8dc;
  --portadas: #2f6db3; --chismes: #c2582f; --chismes-tint: #fbe9e0; --columnas: #5c8a3a; --cartones: #8a63b8;
  --shadow: 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.public { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "DM Sans", system-ui, sans-serif; font-optical-sizing: auto; -webkit-font-smoothing: antialiased; }
.public a { color: inherit; text-decoration: none; }
.public a:hover { opacity: .8; }
.public h1, .public h2, .public h3, .public p, .public ul, .public figure { margin: 0; }

.wordmark { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.logo { display: block; width: auto; }
.kicker { font-size: 12.5px; color: var(--muted); }

/* Mobile header. --hp goes 0 (expanded) -> 1 (compact); compact_header.js animates it with d3. */
.m-sticky { --hp: 0; }
.m-header { background: var(--surface); border-bottom: 1px solid var(--border);
  padding: calc(14px - 6px * var(--hp)) 16px calc(16px - 8px * var(--hp)); }
.m-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: calc(14px - 12px * var(--hp)); }
.m-header .logo { height: calc(24px - 5px * var(--hp)); }
.m-header .kicker { max-height: calc(18px * (1 - var(--hp))); opacity: calc(1 - var(--hp) * 1.6); overflow: hidden; }
.m-header .m-title { font-size: calc(24px - 9px * var(--hp)); margin-top: calc(2px * (1 - var(--hp))) !important;
  color: color-mix(in srgb, var(--text) calc(100% - 30% * var(--hp)), var(--accent)); }
.m-nav { display: flex; gap: 8px; }
.m-header .circle { width: calc(32px - 6px * var(--hp)); height: calc(32px - 6px * var(--hp)); font-size: calc(16px - 2px * var(--hp)); }
.circle { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); display: grid; place-items: center; font-size: 16px; }
.circle.disabled, .pill.disabled { color: var(--disabled); }
.m-title { font-size: 24px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; margin-top: 2px !important; }

.audio { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--audio-bg); border: 1px dashed var(--audio-border); }
.audio-play { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; }
.audio-title { font-size: 14px; font-weight: 600; }
.audio-caption { font: 11px "JetBrains Mono", monospace; color: var(--muted); }

.m-sticky { position: sticky; top: 0; z-index: 10; box-shadow: 0 6px 18px rgba(0, 0, 0, calc(.07 * var(--hp))); }
.m-sticky.is-fixed { position: fixed; top: 0; left: 0; right: 0; }
.m-spacer { display: none; }
.m-sticky.is-fixed + .m-spacer { display: block; }
.tabs { background: var(--surface); padding: calc(10px - 4px * var(--hp)) 16px; border-bottom: 1px solid var(--border); }
.tabs-track { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--bg); padding: 4px; border-radius: 999px; }
.tabs-track a { text-align: center; padding: calc(7px - 2px * var(--hp, 0)) 0; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.tabs-track a.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.left { display: none; }

/* Search (UI only, not wired yet). Mobile: a circle button opens a top sheet via the popover API.
   Tablet/desktop: an inline field in the left column. */
.search-toggle { background: none; color: var(--text); padding: 0; cursor: pointer; font: inherit; }
.search-field { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; color: var(--muted); }
.search-field:focus-within { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-tint); }
.search-field input { flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--text);
  font: 16px "DM Sans", system-ui, sans-serif; /* 16px stops iOS zooming on focus */ -webkit-appearance: none; appearance: none; }
.search-field input::placeholder { color: var(--muted); }
.search-field input::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-icon { flex: none; }
.search-form { display: flex; align-items: center; gap: 12px; }
.search-form .search-field { flex: 1; }
.m-search { position: fixed; inset: 0 0 auto 0; margin: 0; width: 100%; max-width: none; border: 0; border-bottom: 1px solid var(--border);
  padding: max(12px, env(safe-area-inset-top)) 16px 12px; background: var(--surface); color: var(--text); box-shadow: 0 10px 30px rgba(0,0,0,.12); }
.m-search::backdrop { background: rgba(23, 24, 26, .28); }
.search-cancel { flex: none; border: 0; background: none; padding: 8px 0; color: var(--accent); font: 500 15px "DM Sans", system-ui, sans-serif; cursor: pointer; }
.d-search { display: none; }

/* Layout: Portadas, Chismes, Columnas, Cartones */
.layout { display: flex; flex-direction: column; gap: 24px; padding: 20px 16px 8px; }
.main { display: contents; }
section { scroll-margin-top: var(--sticky-h, 72px); }

.label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 12px !important; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.dot-portadas { background: var(--portadas); } .dot-chismes { background: var(--chismes); }
.dot-columnas { background: var(--columnas); } .dot-cartones { background: var(--cartones); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }

/* Stories */
.story { padding: 16px 18px; display: flex; flex-direction: column; }
.story.lead { padding: 20px 18px; margin-bottom: 12px; }
.story-grid { display: grid; gap: 12px; }
.tag { align-self: flex-start; font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-tint); padding: 3px 9px; border-radius: 999px; margin-bottom: 12px; }
.story.lead h2 { font-size: 22px; line-height: 1.2; font-weight: 600; letter-spacing: -.02em; margin-bottom: 8px; }
.story h3 { font-size: 17px; line-height: 1.25; font-weight: 600; margin-bottom: 6px; }
.story .summary { font-size: 14px; line-height: 1.5; color: var(--body); }
.story.lead .summary { font-size: 15px; }
.story-sources { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 16px; -webkit-font-smoothing: auto; -moz-osx-font-smoothing: auto; padding-top: 14px; border-top: 1px solid var(--divider); font-size: 13px; line-height: 1.7; color: var(--muted); }
.story:not(.lead) .story-sources { margin-top: auto; padding-top: 12px; font-size: 12.5px; }
.story:not(.lead) .summary { margin-bottom: 16px; }
.story-sources strong { color: var(--text); font-weight: 600; }
.story-sources .src { color: var(--accent); font-weight: 600; text-decoration: underline; text-decoration-color: #9db8dc; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
.story-sources .src:hover, .story-sources .src:focus-visible { text-decoration-color: var(--accent); }
.story-sources__hint { font-size: 11px; color: var(--disabled); white-space: nowrap; }
@media (max-width: 374px) { .story-sources__hint { display: none; } }
.pdf-link, .source a { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--accent) !important; white-space: nowrap; }
.source { margin-left: auto; font-size: 12px; color: var(--muted); }
.lead .pdf-link { font-size: 13px; }

/* Chismes */
.gossip-list { display: flex; flex-direction: column; gap: 12px; }
.gossip { padding: 16px 18px; }
.gossip header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--chismes-tint); color: var(--chismes); font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.gossip h3 { font-size: 14px; font-weight: 600; line-height: 1.3; }
.gossip .outlet { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.gossip ul { list-style: none; padding: 0; }
.gossip li { font-size: 14.5px; line-height: 1.5; color: var(--body); padding-left: 14px; text-indent: -14px; }
.gossip li + li { margin-top: 8px; }
.gossip .story-sources { font-size: 12.5px; padding-top: 12px; }

/* Columnas */
.columns { padding: 4px 18px; }
.column { display: grid; grid-template-columns: 26px 1fr; column-gap: 12px; padding: 16px 0; }
.column + .column { border-top: 1px solid var(--divider); }
.rank { width: 26px; height: 26px; border-radius: 50%; background: var(--divider); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.byline { font-size: 12.5px; color: var(--muted); } .byline b { color: var(--text); font-weight: 600; }
.column h3 { font-size: 15.5px; font-weight: 600; line-height: 1.3; margin: 2px 0 4px; }
.col-summary { font-size: 13.5px; color: var(--body); }
.column .story-sources { margin-top: 12px; padding-top: 10px; font-size: 12.5px; }

/* Cartones */
.cartoons { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scroll-snap-type: x mandatory; }
.cartoon { flex: none; width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 10px; scroll-snap-align: start; }
.cartoon img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--bg); }
.cartoon figcaption { font-size: 12.5px; margin-top: 8px; } .cartoon figcaption b { font-weight: 600; } .cartoon figcaption span { color: var(--muted); }
.lightbox { border: 0; padding: 0; border-radius: 16px; max-width: 94vw; max-height: 94vh; background: var(--surface); }
.lightbox::backdrop { background: rgba(0,0,0,.7); }
.lightbox img { display: block; max-width: 94vw; max-height: 90vh; }
#page-viewer { overflow: auto; }
#page-viewer img { max-height: none; width: min(94vw, 900px); max-width: none; }
.lightbox form { position: absolute; top: 8px; right: 8px; }
.lightbox button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); font-size: 18px; cursor: pointer; }

.footer { text-align: center; font-size: 11.5px; color: var(--muted); padding: 24px 16px 32px; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Tablet & desktop shared */
@media (min-width: 768px) {
  .m-header { display: none; }
  .left { display: block; }
  .m-search { display: none; }
  .d-search { display: flex; width: 100%; margin-top: 16px; }
  .d-search .search-field { height: 38px; background: var(--surface); }
  .d-search input { font-size: 14px; }
  .d-title { font-size: 30px; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; margin-top: 4px !important; }
  .pills { display: flex; gap: 6px; margin-top: 16px; }
  .pill { height: 34px; padding: 0 12px; display: inline-flex; align-items: center; border: 1px solid var(--chip-border); border-radius: 999px; font-size: 13px; }
  .left .audio { margin-top: 24px; }
  .section-list { margin-top: 28px; display: flex; flex-direction: column; gap: 2px; }
  .section-list a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; font-size: 14px; color: var(--body); }
  .section-list a.active { background: var(--surface); color: var(--text); font-weight: 600; }
  .section-list .n { margin-left: auto; color: var(--muted); font-weight: 400; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 32px 24px; }
  .left { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 32px; }
  .left .section-list { display: none; }
  .main { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
  .story-grid { grid-template-columns: 1fr 1fr; }
  .card { border-radius: 20px; }
  .story { padding: 18px 20px; }
  .story.lead { padding: 26px 28px; }
  .story.lead h2 { font-size: 30px; line-height: 1.15; max-width: 560px; margin-bottom: 14px; }
  .story.lead .summary { font-size: 16px; max-width: 560px; line-height: 1.6; }
  .columns { padding: 8px 28px; }
  .column { grid-template-columns: 28px 1fr; column-gap: 14px; padding: 20px 0; }
  .rank { width: 28px; height: 28px; }
  .column h3 { font-size: 16px; }
  .col-summary { font-size: 14px; max-width: 540px; }
  .cartoons { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 0; overflow: visible; }
  .cartoon { width: auto; border-radius: 16px; padding: 8px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .left .audio { margin-top: 0; }
}
@media (min-width: 1024px) {
  .layout { grid-template-columns: 240px minmax(0, 1fr); gap: 48px; padding: 36px 40px; max-width: 1200px; margin: 0 auto; }
  .left { grid-column: auto; display: block; position: sticky; top: 36px; align-self: start; }
  .left .wordmark { display: inline-flex; margin-bottom: 28px; }
  .left .section-list { display: flex; }
  .tabs { display: none; }
  section { scroll-margin-top: 24px; }
}
#page-viewer iframe { display: block; width: min(94vw, 900px); height: 88vh; border: 0; background: #fff; }
#page-viewer iframe[hidden], #page-viewer img[hidden], #page-viewer .viewer-open[hidden] { display: none; }
#page-viewer .viewer-open { position: absolute; top: 12px; left: 12px; font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: rgba(255,255,255,.9); color: #111; text-decoration: none; }
