/* ==========================================================================
   JETPACK COMPOSE CHEATSHEET · ESTILOS
   1. Variables (tema claro y oscuro)   2. Base   3. Cabecera
   4. Menú lateral   5. Contenido   6. Tablas y código   7. Buscador
   8. Responsive   9. Impresión
   ========================================================================== */

/* 1. VARIABLES ------------------------------------------------------------ */
:root {
  --bg: #f6f8f5;
  --surface: #ffffff;
  --surface-2: #eef2ec;
  --border: #dde4da;
  --text: #17201b;
  --muted: #56645b;
  --accent: #1f9d5a;          /* verde Android un poco más oscuro para leer bien sobre claro */
  --accent-soft: #e2f5ea;
  --blue: #2f6fdb;
  --purple: #6a2bdc;
  --warn-bg: #fff6e0;
  --warn-border: #f0c75e;
  --code-bg: #1b1f23;
  --code-text: #e6e6e6;
  --mark: #fff1a8;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .05);

  --radius: 12px;
  --header-h: 60px;
  --sidebar-w: 270px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1411;
    --surface: #151d18;
    --surface-2: #1c2620;
    --border: #2a362f;
    --text: #e8efe9;
    --muted: #98a89d;
    --accent: #3ddc84;
    --accent-soft: #173826;
    --blue: #7aa7ff;
    --purple: #b28bff;
    --warn-bg: #2e2715;
    --warn-border: #8a6d1f;
    --code-bg: #0b0f0d;
    --mark: #5c5216;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1411;
  --surface: #151d18;
  --surface-2: #1c2620;
  --border: #2a362f;
  --text: #e8efe9;
  --muted: #98a89d;
  --accent: #3ddc84;
  --accent-soft: #173826;
  --blue: #7aa7ff;
  --purple: #b28bff;
  --warn-bg: #2e2715;
  --warn-border: #8a6d1f;
  --code-bg: #0b0f0d;
  --mark: #5c5216;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
}

/* 2. BASE ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code { font-family: var(--mono); font-size: .88em; }
:not(pre) > code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .08em .38em;
  overflow-wrap: anywhere;
}
.skip {
  position: absolute; left: -9999px; top: 8px;
  background: var(--accent); color: #062b16; padding: 8px 14px; border-radius: 8px; z-index: 100;
}
.skip:focus { left: 8px; }

/* 3. CABECERA ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; white-space: nowrap; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #4285f4, #3ddc84 55%, #7b2ff7);
  color: #fff; font-family: var(--mono); font-size: 15px; font-weight: 700;
}
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); line-height: 1; }
.search {
  flex: 1; max-width: 520px; margin-left: auto;
  position: relative;
}
.search input {
  width: 100%; height: 40px;
  padding: 0 72px 0 38px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 15px;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; background: var(--surface);
}
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.menu-btn { display: none; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun { display: block; }
  :root:not([data-theme]) .icon-moon { display: none; }
}

/* 4. MENÚ LATERAL --------------------------------------------------------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 20px 14px 40px;
  border-right: 1px solid var(--border);
}
.sidebar h2 {
  margin: 18px 10px 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.sidebar h2:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a {
  display: block; padding: 6px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 14.5px;
}
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar .new {
  font-size: 10px; font-weight: 800; letter-spacing: .06em;
  color: var(--purple); margin-left: 6px; vertical-align: 1px;
}
.overlay { display: none; }

/* 5. CONTENIDO ------------------------------------------------------------ */
.content { padding: 36px clamp(16px, 4vw, 56px) 80px; max-width: 980px; }
.hero { margin-bottom: 40px; }
.hero .eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.hero h1 { margin: 6px 0 10px; font-size: clamp(30px, 5vw, 46px); line-height: 1.1; letter-spacing: -.02em; }
.hero p { margin: 0; color: var(--muted); max-width: 64ch; font-size: 17px; }
.hero .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.chip:hover { border-color: var(--accent); }

.section { margin-top: 56px; }
.section > h2 {
  display: flex; align-items: center; gap: 12px;
  font-size: 26px; letter-spacing: -.01em; margin: 0 0 6px;
}
.section > h2 .num {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 8px; padding: 3px 8px;
}
.section > .lead { color: var(--muted); margin: 0 0 18px; max-width: 70ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-top: 16px;
}
.card > h3 { margin: 0 0 8px; font-size: 18.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card > h3 code { font-size: .95em; background: none; border: 0; padding: 0; color: var(--accent); }
.card > p { margin: 0 0 12px; }
.card > h4 { margin: 18px 0 4px; font-size: 15px; }
.card > p:last-child { margin-bottom: 0; }
.tag {
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--muted);
}
.tag.nuevo { background: color-mix(in srgb, var(--purple) 15%, transparent); color: var(--purple); }

.tip, .warn {
  margin: 14px 0 0; padding: 10px 14px; border-radius: 10px; font-size: 14.5px;
  border-left: 4px solid var(--accent); background: var(--accent-soft);
}
.warn { border-left-color: var(--warn-border); background: var(--warn-bg); }
.tip strong, .warn strong { margin-right: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-top: 16px; }

/* Diagrama de alineaciones del Box */
.align-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  max-width: 460px; margin-top: 8px;
  padding: 8px; border: 2px dashed var(--border); border-radius: 12px;
}
.align-grid span {
  font-family: var(--mono); font-size: 12.5px; text-align: center;
  padding: 12px 4px; border-radius: 8px; background: var(--surface-2);
}
.align-grid span:nth-child(5) { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* 6. TABLAS Y CÓDIGO ------------------------------------------------------ */
.table-wrap { overflow-x: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
td:first-child code { white-space: nowrap; }

.code {
  position: relative; margin-top: 10px;
  background: var(--code-bg); border-radius: 10px; overflow: hidden;
  border: 1px solid #2a2f35;
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px 6px 14px; background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  font-family: var(--mono); font-size: 12px; color: #9aa4ae;
}
.copy {
  font: 600 12px var(--font); color: #cfd6dc; cursor: pointer;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 6px; padding: 3px 10px;
}
.copy:hover { background: rgba(255, 255, 255, .14); }
.copy.ok { color: #3ddc84; border-color: #3ddc84; }
pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
pre code { color: var(--code-text); font-size: 13.5px; line-height: 1.6; tab-size: 4; }
.k  { color: #c792ea; }   /* palabras clave */
.s  { color: #c3e88d; }   /* cadenas */
.c  { color: #6b7d75; font-style: italic; }  /* comentarios */
.n  { color: #f78c6c; }   /* números */
.a  { color: #ffcb6b; }   /* anotaciones */
.f  { color: #82aaff; }   /* llamadas a función */
.t  { color: #89ddff; }   /* tipos (Mayúscula inicial) */

/* 7. BUSCADOR ------------------------------------------------------------- */
.search-info { margin: -20px 0 24px; color: var(--muted); font-size: 14.5px; display: none; }
.searching .search-info { display: block; }
.searching .hero { display: none; }
.hidden { display: none !important; }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }
.empty {
  display: none; text-align: center; padding: 50px 20px; color: var(--muted);
  border: 2px dashed var(--border); border-radius: var(--radius);
}

.footer {
  margin-top: 70px; padding-top: 22px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 14px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
}

/* 8. RESPONSIVE ----------------------------------------------------------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: grid; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: min(84vw, 300px); height: 100vh;
    background: var(--surface);
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .menu-open .sidebar { transform: none; box-shadow: 4px 0 30px rgba(0, 0, 0, .25); }
  .menu-open .overlay { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .4); }
  .search kbd { display: none; }
  .search input { padding-right: 12px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .brand-text { display: none; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .card { padding: 16px; }
  /* Tablas apiladas: cada fila se convierte en un bloque con el código arriba */
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  .table-wrap thead { display: none; }
  .table-wrap tr { padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { padding: 0; border: 0; }
  .table-wrap td:first-child { white-space: normal; margin-bottom: 4px; }
  .table-wrap td:first-child code { white-space: normal; }
  .table-wrap td + td { color: var(--muted); }
  .table-wrap td:nth-child(3) { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidebar { transition: none; }
}

/* 9. IMPRESIÓN ------------------------------------------------------------ */
@media print {
  .topbar, .sidebar, .copy, .footer { display: none !important; }
  .layout { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
  .code { border: 1px solid #999; }
}
