/* Base blog styles — consumes tokens.css variables. Portado pixel-perfect de
 * claude-design/project/{TopBar,BlogScreen,ArticuloScreen,ThemeSwitch}.dc.html
 * (no del markup React actual), 006-blog-server-render T006. */

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
}

body {
  overflow-x: hidden;
  margin: 0;
  background: var(--bg);
  color: var(--t1);
  font-family: var(--font-body);
  transition:
    background 0.3s ease,
    color 0.3s ease;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-heading);
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
}

img {
  max-width: 100%;
  display: block;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.by-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--frame);
}

/* --- TopBar --------------------------------------------------------- */

.by-topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 40px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition:
    background 0.3s ease,
    border-color 0.3s ease;
}

.by-topbar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.by-topbar__title {
  font: 800 21px/1 var(--font-heading);
  color: var(--t1);
  letter-spacing: -0.02em;
}

/* --- Theme switch ----------------------------------------------------- */

.by-theme-switch {
  position: relative;
  width: 66px;
  height: 34px;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--border2);
  background: var(--surface3);
  cursor: pointer;
  padding: 0;
  transition:
    background 0.3s ease,
    border-color 0.3s ease;
}

.by-theme-switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.3, 0.5, 1);
}

:root[data-theme="dark"] .by-theme-switch__knob {
  transform: translateX(32px);
}

.by-theme-switch__moon {
  display: none;
}

:root[data-theme="dark"] .by-theme-switch__sun {
  display: none;
}

:root[data-theme="dark"] .by-theme-switch__moon {
  display: block;
}

/* --- Footer ------------------------------------------------------------ */

.by-footer {
  padding: 44px 56px 34px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.by-footer__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.by-footer__title {
  font: 800 16px/1 var(--font-heading);
  color: var(--t1);
  letter-spacing: -0.02em;
}

.by-footer__tagline {
  font: 500 13px/1 var(--font-body);
  color: var(--t4);
}

.by-footer__legal {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.by-footer__legal a {
  font: 600 13px/1 var(--font-body);
  color: var(--t3);
  text-decoration: none;
}

.by-footer__legal a:hover {
  color: var(--greenTx);
}

.by-main {
  flex: 1;
}

.by-section-padding {
  padding-left: 56px;
  padding-right: 56px;
}

@media (max-width: 640px) {
  .by-section-padding,
  .by-topbar,
  .by-footer {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* --- Article card / grid ------------------------------------------------ */

.by-article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 26px;
}

.by-article-grid--compact {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.by-article-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 44px -38px var(--shadowLg);
  transition:
    background 0.3s ease,
    border-color 0.3s ease;
}

.by-article-card__cover {
  position: relative;
  height: 190px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
}

.by-article-card--compact .by-article-card__cover {
  height: 150px;
}

.by-article-card__cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.by-article-card__body {
  padding: 24px 24px 26px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.by-article-card--compact .by-article-card__body {
  padding: 22px 22px 24px;
}

.by-article-card__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.by-article-card--compact .by-article-card__meta {
  margin-bottom: 12px;
}

.by-badge {
  display: inline-flex;
  align-items: center;
  font: 800 11px/1 var(--font-body);
  padding: 7px 11px;
  border-radius: 999px;
}

.by-article-card__reading-time {
  font: 600 12.5px/1 var(--font-body);
  color: var(--t4);
}

.by-article-card__title {
  margin: 0 0 10px;
  font: 700 20px/1.25 var(--font-heading);
  color: var(--t1);
  letter-spacing: -0.01em;
}

.by-article-card--compact .by-article-card__title {
  margin: 0;
  font-size: 18px;
}

.by-article-card__excerpt {
  margin: 0 0 20px;
  font: 400 14.5px/1.55 var(--font-body);
  color: var(--t3);
}

.by-article-card__footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.by-article-card__date {
  font: 500 12.5px/1 var(--font-body);
  color: var(--t4);
}

/* --- Category accent classes (badge + cover) --------------------------- */

.by-accent-optim .by-badge {
  background: var(--cat-optim-badgeBg);
  color: var(--cat-optim-badgeTx);
}
.by-accent-optim .by-article-card__cover {
  background-image: var(--cat-optim-cover);
}

.by-accent-tuto .by-badge {
  background: var(--cat-tuto-badgeBg);
  color: var(--cat-tuto-badgeTx);
}
.by-accent-tuto .by-article-card__cover {
  background-image: var(--cat-tuto-cover);
}

.by-accent-expli .by-badge {
  background: var(--cat-expli-badgeBg);
  color: var(--cat-expli-badgeTx);
}
.by-accent-expli .by-article-card__cover {
  background-image: var(--cat-expli-cover);
}

.by-accent-general .by-badge {
  background: var(--cat-general-badgeBg);
  color: var(--cat-general-badgeTx);
}
.by-accent-general .by-article-card__cover {
  background-image: var(--cat-general-cover);
}

/* --- Archived pill + collapsible note (hide_from_listing articles) ------ */

.by-archived-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 800 11px/1 var(--font-body);
  padding: 7px 11px 7px 9px;
  border-radius: 999px;
  background: var(--surface2);
  color: var(--t3);
  border: 1px solid var(--border3);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.by-archived-pill:hover,
.by-archived-pill:focus-visible {
  color: var(--t2);
}

.by-archived-pill:focus-visible {
  outline: 2px solid var(--greenTx);
  outline-offset: 2px;
}

.by-archived-pill__chevron {
  transition: transform 0.2s ease;
}

.by-archived-pill[aria-expanded="true"] .by-archived-pill__chevron {
  transform: rotate(180deg);
}

.by-archived-note {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
}

.by-archived-note.is-open {
  grid-template-rows: 1fr;
}

/* Direct grid child collapses via the row track; overflow hides its content
 * while the track is 0fr. The padded box lives one level deeper so its own
 * padding/border don't leak while collapsed. */
.by-archived-note__inner {
  overflow: hidden;
  min-height: 0;
}

.by-archived-note.is-open .by-archived-note__inner {
  margin-bottom: 20px;
}

.by-archived-note__inner p {
  margin: 0;
  padding: 12px 15px;
  background: var(--surface2);
  border: 1px solid var(--border3);
  border-radius: 12px;
  color: var(--t3);
  font: 400 13.5px/1.55 var(--font-body);
}

.by-archived-note__inner strong {
  color: var(--t1);
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .by-archived-pill,
  .by-archived-pill__chevron,
  .by-archived-note {
    transition: none;
  }
}

/* --- Empty state --------------------------------------------------------- */

.by-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 60px 20px;
  text-align: center;
}

.by-empty-state__title {
  margin: 0;
  font: 700 18px/1.4 var(--font-heading);
  color: var(--t1);
}

.by-empty-state__hint {
  margin: 0;
  font: 400 14.5px/1.5 var(--font-body);
  color: var(--t3);
}

/* --- Share controls ------------------------------------------------------ */

.by-share-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.by-share-btn {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--surface);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--t2);
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    color 0.18s ease;
}

.by-share-btn--copied {
  background: rgba(22, 163, 74, 0.1);
  border-color: #16a34a;
  color: #16a34a;
}

.by-share-btn svg {
  pointer-events: none;
}

/* Copy button icon swap: link by default, check once copied. */
.by-share-icon--check {
  display: none;
}

.by-share-btn--copied .by-share-icon--link {
  display: none;
}

.by-share-btn--copied .by-share-icon--check {
  display: block;
}

/* --- Reading progress bar ------------------------------------------------- */

.by-reading-progress {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 5px;
  background: var(--track);
}

.by-reading-progress__fill {
  height: 100%;
  background: linear-gradient(90deg, #12b981, #3dd07e);
  width: 0%;
  transition: width 0.08s linear;
}

/* --- Core "Resumen" block -------------------------------------------------- */

.by-core-block {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--surface2);
  border: 1px solid var(--border3);
  border-radius: 20px;
  padding: 24px 26px;
  margin-bottom: 40px;
}

.by-core-block__label {
  font: 800 12px/1 var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--greenTx);
  margin-bottom: 10px;
}

.by-core-block__text {
  margin: 0;
  font: 500 16.5px/1.6 var(--font-body);
  color: var(--t2);
}

/* --- Article body -------------------------------------------------------- */

.by-article-body {
  max-width: 760px;
  margin: 0 auto;
  font: 400 16.5px/1.75 var(--font-body);
  color: var(--t2);
}

.by-article-body h2,
.by-article-body h3 {
  color: var(--t1);
  margin-top: 2em;
}

.by-article-body img {
  border-radius: 16px;
}

.by-article-body a {
  color: var(--greenTx);
  text-decoration: underline;
}

/* Brand content blocks (div[data-block], sanitizer.py ALLOWED_CLASSES) —
 * numbered steps, stat cards and Core callouts embedded in article bodies
 * (claude-design/project/ArticuloScreen.dc.html "pasos"/"stats"/"aviso de
 * Core" sections). */

.by-article-body div[data-block="steps"] {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 28px 0;
}

.by-article-body div[data-block="steps"] div.step {
  display: flex;
  gap: 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 18px 22px;
  font: 500 14px/1.4 var(--font-body);
  color: var(--t3);
}

.by-article-body span.step-number {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--green);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 800 15px/1 var(--font-heading);
  margin-right: 2px;
}

.by-article-body span.step-gain {
  display: inline-block;
  white-space: nowrap;
  font: 800 11px/1 var(--font-body);
  color: var(--cat-optim-badgeTx);
  background: var(--cat-optim-badgeBg);
  padding: 4px 9px;
  border-radius: 999px;
  margin-right: 10px;
}

.by-article-body div[data-block="stat-grid"] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.by-article-body div[data-block="stat-card"] {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 24px;
  text-align: center;
  margin: 20px 0;
}

.by-article-body div[data-block="stat-grid"] div[data-block="stat-card"] {
  margin: 0;
}

.by-article-body span.stat-value {
  display: block;
  font: 800 38px/1 var(--font-heading);
  color: var(--green);
  margin-bottom: 8px;
}

.by-article-body span.stat-label {
  display: block;
  font: 500 14px/1.4 var(--font-body);
  color: var(--t3);
}

/* Speech-bubble callout: Core "talking" floats outside the bubble, bottom
 * left, with the bubble's near corner squared off to read as a tail
 * pointing at him (claude-design/project/Core.dc.html "wink" expression,
 * inlined as an SVG data URI — the sanitizer only allows a single <div>
 * here, so Core is a pseudo-element rather than a sibling markup node). */
.by-article-body div[data-block="core-callout"] {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--chipBorder);
  border-radius: 18px 18px 18px 4px;
  padding: 20px 24px;
  margin: 28px 0 28px 58px;
  font: 500 14px/1.4 var(--font-body);
  color: var(--t3);
}

.by-article-body div[data-block="core-callout"]::before {
  content: "";
  position: absolute;
  left: -58px;
  bottom: 0;
  width: 44px;
  height: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 58 58'%3E%3Crect x='26' y='2' width='6' height='8' rx='3' fill='%23FFC24B'/%3E%3Crect x='6' y='6' width='46' height='46' rx='15' fill='%2312B981'/%3E%3Crect x='15' y='14' width='28' height='24' rx='9' fill='%23fff'/%3E%3Ccircle cx='24' cy='26' r='3.4' fill='%2312B981'/%3E%3Cpath d='M32 26 h6' stroke='%2312B981' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
}

/* pros-cons: two side-by-side cards, "A favor" / "En contra" — headings
 * are generated from CSS so the block's markup stays minimal. */
.by-article-body div[data-block="pros-cons"] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.by-article-body div[data-block="pros-cons"] > div {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 20px 22px;
  font: 500 14px/1.5 var(--font-body);
  color: var(--t3);
}

.by-article-body div[data-block="pros-cons"] span.pc-title {
  display: block;
  font: 800 12px/1 var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.by-article-body div[data-block="pros-cons"] div.pros span.pc-title {
  color: var(--greenTx);
}

.by-article-body div[data-block="pros-cons"] div.cons span.pc-title {
  color: #d4736a;
}

.by-article-body div[data-block="pros-cons"] ul {
  margin: 0;
  padding-left: 18px;
}

.by-article-body div[data-block="pros-cons"] li {
  margin-bottom: 8px;
}

/* verdict: highlighted final recommendation — brand-green tinted card with
 * the text set in the heading face so it reads as the article's takeaway. */
.by-article-body div[data-block="verdict"] {
  background: var(--cat-optim-cover);
  border: 1px solid var(--chipBorder);
  border-radius: 18px;
  padding: 24px 26px;
  margin: 28px 0;
  font: 700 18px/1.45 var(--font-heading);
  color: var(--t1);
}

.by-article-body div[data-block="verdict"] span.verdict-label {
  display: block;
  font: 800 12px/1 var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--greenTx);
  margin-bottom: 10px;
}

/* versus: head-to-head comparison, optional .winner gets the green border
 * — the "VS" separator is generated so the markup stays two plain divs. */
.by-article-body div[data-block="versus"] {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  margin: 28px 0;
}

.by-article-body div[data-block="versus"] div.vs-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
}

.by-article-body div[data-block="versus"] div.vs-item.winner {
  border: 2px solid var(--green);
}

.by-article-body div[data-block="versus"]::before {
  content: "VS";
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  font: 800 15px/1 var(--font-heading);
  color: var(--t4);
}

.by-article-body div[data-block="versus"] div.vs-item:first-child {
  grid-column: 1;
  grid-row: 1;
}

.by-article-body div[data-block="versus"] div.vs-item:last-child {
  grid-column: 3;
  grid-row: 1;
}

.by-article-body span.vs-badge {
  display: inline-block;
  font: 800 10px/1 var(--font-body);
  color: var(--cat-optim-badgeTx);
  background: var(--cat-optim-badgeBg);
  padding: 4px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.by-article-body span.vs-name {
  display: block;
  font: 800 17px/1.2 var(--font-heading);
  color: var(--t1);
  margin-bottom: 6px;
}

.by-article-body span.vs-desc {
  display: block;
  font: 500 14px/1.4 var(--font-body);
  color: var(--t3);
}

/* warning: serious caution notice (data loss, irreversible actions) —
 * distinct from core-callout: objective, not in Core's voice. The ⚠ icon
 * is generated so the markup stays a single text div. */
.by-article-body div[data-block="warning"] {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-left: 4px solid var(--yellow);
  border-radius: 12px 18px 18px 12px;
  padding: 18px 22px;
  margin: 28px 0;
  font: 500 14px/1.4 var(--font-body);
  color: var(--t3);
}

.by-article-body div[data-block="warning"]::before {
  content: "⚠";
  font-size: 20px;
  line-height: 1.2;
  color: var(--yellow);
}

/* quote: pull-quote with a green accent bar and optional source line. */
.by-article-body div[data-block="quote"] {
  margin: 28px 0;
  padding: 8px 0 8px 28px;
  border-left: 4px solid var(--green);
}

.by-article-body span.quote-text {
  display: block;
  font: 600 20px/1.5 var(--font-heading);
  color: var(--t1);
}

.by-article-body span.quote-source {
  display: block;
  margin-top: 10px;
  font: 500 13px/1 var(--font-body);
  color: var(--t4);
}

/* specs: key-value tech sheet rows inside a single card. */
.by-article-body div[data-block="specs"] {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 8px 24px;
  margin: 28px 0;
}

.by-article-body div[data-block="specs"] div.spec-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font: 500 14px/1.4 var(--font-body);
}

.by-article-body div[data-block="specs"] div.spec-row:last-child {
  border-bottom: none;
}

.by-article-body span.spec-key {
  color: var(--t4);
}

.by-article-body span.spec-val {
  color: var(--t1);
  font-weight: 700;
  text-align: right;
}

/* Cover image: the stored file is already normalized to a fixed 1600x840
 * (1.91:1) by normalize_cover_image, so we render it at its native ratio via
 * aspect-ratio — no fixed pixel height that would re-crop it at wider column
 * widths. object-fit:cover only guards the rare case a legacy/un-normalized
 * cover isn't exactly 1.91:1. */
.by-article-cover {
  width: 100%;
  aspect-ratio: 1600 / 840;
  object-fit: cover;
  border-radius: 22px;
}

.by-article-body figure.article-image {
  margin: 28px 0;
  text-align: center;
}

/* Body images keep their natural size and aspect ratio (they're stored with
 * aspect ratio preserved, longer side <=1600px). Cap at the column width so
 * large images don't overflow, but never upscale small ones. Applies to both
 * figure-wrapped images and bare markdown ![]() images. */
.by-article-body figure.article-image img,
.by-article-body > p img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.by-article-body figcaption.article-image-caption {
  margin-top: 8px;
  font: 500 13px/1.5 var(--font-body);
  color: var(--t4);
  text-align: center;
}

/* Affiliate disclosure — constitution I, kept visible next to affiliate
 * links whenever body_html includes one (rendered from stored HTML). */
.by-affiliate-notice {
  display: inline-block;
  margin-top: 4px;
  font: 600 12px/1.4 var(--font-body);
  color: var(--t4);
}
