/* ══════════════════════════════════════════════════════════════════════
   library.css — Learning Library hub (/library/) and item pages.
   Shared foundations (tokens, reset, nav, progress, footer, shared buttons)
   live in /site.css. This file only defines library-specific surfaces.
   ══════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════ HUB HERO ═══════════════════════ */
.hero {
  position: relative;
  background: linear-gradient(160deg, var(--azulejo-dark), var(--azulejo) 55%, var(--azulejo-light));
  color: var(--white);
  padding: 156px 32px 64px;
  overflow: hidden;
  isolation: isolate;
}
.hero::after {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background:
    repeating-linear-gradient(90deg, transparent 0 118px, rgba(255,255,255,0.05) 118px 120px),
    repeating-linear-gradient(0deg, transparent 0 118px, rgba(255,255,255,0.05) 118px 120px);
  pointer-events: none;
}
.hero-inner { max-width: 1060px; margin: 0 auto; position: relative; z-index: 1; }
.kicker {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.22em;
  color: var(--dourado-light);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 5.5vw, 56px);
  line-height: 1.08;
  margin: 12px 0 14px;
  letter-spacing: -0.015em;
}
.hero-standfirst {
  max-width: 560px; margin: 0;
  color: #E8EEF8;
  font-size: clamp(15px, 1.6vw, 17px);
  line-height: 1.6;
}

/* ═══════════════════════ FILTER CARD ═══════════════════════ */
.shell { max-width: 1060px; margin: 0 auto; padding: 0 24px; }
.filters {
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-tile);
  padding: 22px 24px;
  margin-top: -30px;
  position: relative; z-index: 2;
}
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filter-row:last-child { margin-bottom: 0; }
.filter-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--cortica);
  width: 52px; flex-shrink: 0;
}

.pill {
  border: 1.5px solid var(--border);
  background: var(--marfim);
  color: var(--noite);
  font-family: var(--font-body);
  font-size: 13px; font-weight: 600;
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms var(--ease-bounce), border-color 180ms ease;
}
.pill:hover { transform: translate(-1px, -1px); border-color: var(--azulejo); }
.pill:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 2px; }
.pill.on { background: var(--azulejo); border-color: var(--azulejo); color: var(--white); }
.pill.lv-a1.on { background: var(--verde); border-color: var(--verde); }
.pill.lv-a2.on { background: var(--azulejo); border-color: var(--azulejo); }
.pill.lv-b1.on { background: var(--terracotta); border-color: var(--terracotta); }
.pill.lv-b2.on { background: var(--dourado); border-color: var(--dourado); color: var(--noite); }

.search {
  flex: 1; min-width: 180px;
  display: flex; align-items: center; gap: 8px;
  border: 1.5px solid var(--border);
  background: var(--marfim);
  border-radius: 999px;
  padding: 7px 15px;
}
.search svg { flex-shrink: 0; opacity: 0.5; }
.search input {
  border: 0; background: none; outline: none;
  font-family: var(--font-body); font-size: 13.5px;
  width: 100%; color: var(--noite);
}

/* Topic dropdown, styled to sit beside the pills */
.topic-select { position: relative; display: inline-flex; }
.topic-select::after {
  content: ""; position: absolute; right: 15px; top: 50%;
  width: 7px; height: 7px; margin-top: -5px;
  border-right: 2px solid var(--cortica); border-bottom: 2px solid var(--cortica);
  transform: rotate(45deg); pointer-events: none;
}
.topic-select select {
  appearance: none; -webkit-appearance: none;
  border: 1.5px solid var(--border); background: var(--marfim);
  border-radius: 999px; padding: 7px 36px 7px 16px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  color: var(--noite); cursor: pointer; min-width: 190px;
  transition: border-color 0.18s var(--ease-bounce), transform 0.18s var(--ease-bounce);
}
.topic-select select:hover { border-color: var(--azulejo); transform: translate(-1px, -1px); }
.topic-select select:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 2px; }

.count { font-size: 12.5px; color: var(--cortica); margin: 20px 2px 12px; }

/* ═══════════════════════ CARD GRID ═══════════════════════ */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
  padding-bottom: 32px;
}
.card {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 20px 20px 18px;
  position: relative;
  display: flex; flex-direction: column; gap: 9px;
  text-decoration: none; color: var(--noite);
  transition: transform 180ms var(--ease-bounce), box-shadow 180ms var(--ease-bounce);
}
.card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-tile); }
.card.hide { display: none; }

.card-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; color: var(--white); padding: 3px 9px; border-radius: 3px; }
.badge.lv-a1 { background: var(--verde); }
.badge.lv-a2 { background: var(--azulejo); }
.badge.lv-b1 { background: var(--terracotta); }
.badge.lv-b2 { background: var(--dourado); color: var(--noite); }
.type { font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em; color: var(--cortica); font-weight: 700; }
.mins { margin-left: auto; font-size: 11.5px; color: var(--cortica); }

.card h3 { font-family: var(--font-display); font-size: 21px; margin: 0; line-height: 1.2; }
.card .en { font-size: 13px; color: var(--cortica); font-style: italic; margin-top: -5px; }
.card p { font-size: 13.5px; margin: 0; color: #3A3A4E; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.chip { font-size: 11px; background: var(--calcada); border: 1px solid var(--border); color: var(--cortica); padding: 2px 9px; border-radius: 999px; }

/* Game card, dark variant */
.card.game {
  background: linear-gradient(150deg, #141426, var(--noite) 70%, #232345);
  border-color: var(--noite);
  color: var(--marfim);
}
.card.game h3 { color: var(--dourado-light); }
.card.game p { color: #C9C9DC; }
.card.game .en { color: #8E8EA8; }
.card.game .type { color: var(--dourado); }
.card.game .chip { background: #26263E; border-color: #33334E; color: #A8A8C0; }
.card.game:hover { box-shadow: 4px 4px 0 0 var(--dourado); }

.empty { display: none; text-align: center; padding: 56px 20px; color: var(--cortica); font-size: 15px; }
.empty.show { display: block; }

@media (max-width: 640px) {
  .hero { padding: 132px 20px 52px; }
  .shell { padding: 0 16px; }
  .filters { padding: 18px 16px; margin-top: -22px; }
  .filter-label { width: 100%; margin-bottom: 2px; }
  .grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════ ITEM HERO ═══════════════════════ */
.item-hero {
  background: linear-gradient(160deg, var(--azulejo-dark), var(--azulejo));
  color: var(--white);
  padding: 156px 32px 44px;
}
.crumb { font-size: 12.5px; color: #B9CCE8; margin-bottom: 16px; }
.crumb a { color: #B9CCE8; border-bottom: 1px solid transparent; transition: color 200ms, border-color 200ms; }
.crumb a:hover { color: var(--white); border-color: rgba(255,255,255,0.4); }
.crumb .sep { opacity: 0.5; margin: 0 4px; }
.crumb .current { color: var(--white); font-weight: 600; }
.item-hero h1 { font-family: var(--font-display); font-size: clamp(30px, 4.5vw, 46px); margin: 8px 0 4px; line-height: 1.12; }
.item-hero .sub { font-style: italic; color: #D6E2F5; font-size: 17px; margin: 0; }
.meta-row {
  display: flex; gap: 10px; margin-top: 18px;
  flex-wrap: wrap; align-items: center;
  font-size: 12.5px;
}
.meta-row .badge { font-size: 11px; }
.meta-row span:not(.badge) { color: #B9CCE8; }

/* ═══════════════════════ ARTICLE BODY (.paper) ═══════════════════════ */
.paper { max-width: 760px; margin: 0 auto; padding: 44px 24px 80px; }

.section-h {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 42px 0 6px;
  position: relative;
  padding-top: 16px;
}
.section-h::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: 56px; height: 3px; background: var(--dourado);
}
.section-sub { font-size: 13px; color: var(--cortica); margin: 0 0 18px; }

.intro-txt {
  font-size: 16.5px; color: #3A3A4E;
  border-left: 3px solid var(--dourado);
  padding-left: 16px;
  margin-bottom: 16px;
}

/* Reveal-all control */
.reveal-all {
  border: 1.5px solid var(--azulejo);
  background: var(--white); color: var(--azulejo);
  font-family: var(--font-body); font-weight: 700; font-size: 12.5px;
  padding: 7px 16px; border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms var(--ease-bounce), background 180ms ease, color 180ms ease;
  margin-bottom: 16px;
}
.reveal-all:hover { background: var(--azulejo); color: var(--white); transform: translate(-1px, -1px); }
.reveal-all:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 2px; }

/* Dialogue lines */
.line { margin-bottom: 14px; }
.line .who { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 3px; }
.line.a .who { color: var(--terracotta); }
.line.b .who { color: var(--azulejo); margin-left: 11%; }
.bubble { background: var(--white); border: 1px solid var(--border); padding: 12px 16px; max-width: 88%; position: relative; }
.line.a .bubble { border-left: 3px solid var(--terracotta); }
.line.b .bubble { border-left: 3px solid var(--azulejo); margin-left: 11%; }
.pt { font-size: 16px; }

.en-toggle {
  display: block; border: 0; background: none; padding: 0; margin-top: 7px;
  cursor: pointer; font-family: var(--font-body); text-align: left; width: 100%;
}
.en-toggle:focus-visible { outline: 2px solid var(--azulejo); outline-offset: 2px; }
.en-toggle .hint { font-size: 11px; color: var(--azulejo); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.en-toggle .en { display: none; font-size: 14px; color: var(--cortica); font-style: italic; margin-top: 2px; }
.en-toggle.open .hint { display: none; }
.en-toggle.open .en { display: block; }

/* Texto paragraphs, reuse the reveal mechanism without the speaker bubble */
.para {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--azulejo);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.para .pt { font-size: 16px; }

/* Vocabulary / expressions grid */
.vocab {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px; background: var(--border);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-tile);
  margin-bottom: 16px;
}
.vocab dt, .vocab dd { background: var(--white); padding: 10px 14px; font-size: 14.5px; margin: 0; }
.vocab .t { font-weight: 700; color: var(--azulejo-dark); }
.vocab .vgroup {
  grid-column: 1 / -1; background: var(--calcada);
  font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
  color: var(--cortica);
  margin: 0; padding: 10px 14px;
}

/* "What you'll learn" — the English summary under the intro */
.learn {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--verde);
  padding: 16px 20px 16px 18px;
  margin: 24px 0 8px;
}
.learn-h {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--verde); margin: 0 0 8px;
}
.learn ul { margin: 0; padding-left: 20px; }
.learn li { font-size: 14.5px; margin-bottom: 4px; color: #3A3A4E; }
.learn li:last-child { margin-bottom: 0; }

/* Questions */
.qgroup {
  font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--cortica); margin: 22px 0 10px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.qgroup:first-child { margin-top: 0; }
.qnote { font-size: 13.5px; color: var(--cortica); margin: 0 0 12px; font-style: italic; }
.q { background: var(--white); border: 1px solid var(--border); padding: 16px 18px; margin-bottom: 12px; }
.q .qq { font-size: 15.5px; font-weight: 600; margin-bottom: 8px; }
.q .num { color: var(--dourado); font-family: var(--font-display); font-weight: 700; margin-right: 8px; }
.show-a {
  border: 1.5px solid var(--verde); background: var(--white); color: var(--verde);
  font-weight: 700; font-size: 12px; font-family: var(--font-body);
  padding: 5px 13px; border-radius: 999px; cursor: pointer;
  transition: transform 180ms var(--ease-bounce), background 180ms ease, color 180ms ease;
}
.show-a:hover { background: var(--verde); color: var(--white); }
.show-a:focus-visible { outline: 2px solid var(--verde); outline-offset: 2px; }
.ans { display: none; margin-top: 9px; font-size: 14.5px; color: var(--verde); font-style: italic; }
.q.open .ans { display: block; }
.q.open .show-a { display: none; }

/* Culture callout */
.culture {
  background: var(--calcada);
  border: 1px solid var(--border);
  border-left: 4px solid var(--terracotta);
  padding: 18px 20px;
  font-size: 14.5px;
  margin-bottom: 16px;
}

/* End CTA */
.cta {
  margin-top: 48px;
  background: var(--azulejo-dark);
  color: var(--white);
  padding: 32px 30px;
  text-align: center;
  box-shadow: 6px 6px 0 0 var(--dourado);
}
.cta h3 { font-family: var(--font-display); font-size: 24px; margin: 0 0 8px; }
.cta p { margin: 0 0 18px; color: #C9D8EE; font-size: 14.5px; }
.cta .btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--terracotta); color: var(--white) !important;
  text-decoration: none; font-weight: 700;
  padding: 12px 26px; border-radius: 4px;
  border: 2px solid var(--noite);
  transition: transform 180ms var(--ease-bounce);
}
.cta .btn:hover { transform: translate(-2px, -2px); }

/* Related items */
.related { margin-top: 8px; }
.related-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border); }
.related-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--white); padding: 14px 18px;
  color: inherit; text-decoration: none;
  transition: background 200ms ease;
}
.related-card:hover { background: var(--calcada); }
.related-title { font-family: var(--font-display); font-size: 16px; flex: 1; }
.related-mins { font-size: 12px; color: var(--cortica); }

/* ═══════════════════════ RESPONSIVE ═══════════════════════ */
@media (max-width: 560px) {
  .vocab { grid-template-columns: 1fr; }
  .vocab .t { padding-bottom: 2px; }
}

@media (max-width: 640px) {
  .item-hero { padding: 132px 20px 36px; }
  .paper { padding: 36px 16px 64px; }
  .bubble, .para { max-width: 100%; }
  .line.b .bubble, .line.b .who { margin-left: 0; }
  .topic-select, .topic-select select { width: 100%; min-width: 0; }
  .learn { padding: 14px 16px; }
  .cta { padding: 26px 20px; box-shadow: 4px 4px 0 0 var(--dourado); }
  .cta .btn { width: 100%; justify-content: center; }

  /* The meta row wraps on mobile, so the dot separators would dangle */
  .meta-row { gap: 6px 12px; }
  .meta-row .dot { display: none; }

  /* Narrow viewport is effectively always touch, so size the controls for it */
  .pill, .topic-select select, .search { min-height: 44px; }
  .reveal-all, .show-a { min-height: 44px; padding-left: 20px; padding-right: 20px; }
  .en-toggle { min-height: 44px; display: flex; align-items: center; }
  .en-toggle.open { display: block; min-height: 0; padding-top: 2px; }
}

@media (max-width: 380px) {
  .related-card { flex-wrap: wrap; gap: 8px; }
  .related-title { flex: 1 1 100%; order: 3; }
}

/* Touch devices get full-size tap targets. Pointer devices keep the
   tighter visual rhythm, so this costs the desktop design nothing. */
@media (pointer: coarse) {
  .pill, .topic-select select { min-height: 44px; }
  .search { min-height: 44px; }
  .reveal-all, .show-a { min-height: 44px; padding-left: 20px; padding-right: 20px; }
  .en-toggle { min-height: 44px; display: flex; align-items: center; }
  .en-toggle.open { display: block; min-height: 0; padding-top: 2px; }
  .related-card { min-height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .pill, .card, .reveal-all, .show-a, .cta .btn {
    transition: none !important;
  }
}

/* ═══════════════════════ PRINT ═══════════════════════ */
/* A library item should print as a clean worksheet: every translation and
   model answer expanded, site chrome and interactive affordances gone. */
@media print {
  .nav, .footer, .wa-float, .progress, .filters, .cta, .related,
  .reveal-all, .en-toggle .hint, .show-a, .section-sub { display: none !important; }

  body { background: #fff !important; color: #000 !important; }

  .item-hero, .hero {
    background: none !important; color: #000 !important;
    padding: 0 0 12px !important; border-bottom: 2px solid #000;
  }
  .item-hero h1, .hero h1 { font-size: 26pt; }
  .item-hero .sub, .meta-row, .crumb { color: #333 !important; }
  .crumb { display: none; }

  .paper { max-width: 100%; padding: 0; }

  /* Expand every hidden answer and translation */
  .en-toggle .en { display: block !important; font-style: italic; color: #444 !important; }
  .ans { display: block !important; color: #000 !important; }

  .learn { border: 1px solid #000; border-left: 4px solid #000; }
  .bubble, .para, .q, .culture, .vocab dt, .vocab dd {
    background: #fff !important; box-shadow: none !important;
  }
  .vocab { box-shadow: none !important; border-color: #000; }
  .badge { border: 1px solid #000; color: #000 !important; background: none !important; }

  /* Keep a block and its translation on the same page */
  .line, .para, .q, .learn { break-inside: avoid; page-break-inside: avoid; }
  .section-h { break-after: avoid; page-break-after: avoid; }

  a[href]::after { content: ""; }
}
