/* Portafolio de Roberto López: un chat. Tema claro por defecto, oscuro por preferencia o por botón. */
:root {
  --wall: #efe8dd; --wall-dot: #e2d9cb;
  --bar: #0b6e4f; --bar-ink: #ffffff; --bar-muted: #cde8dd;
  --in: #ffffff; --out: #d8f3c8; --ink: #1d2329; --muted: #5a6670;
  --accent: #0b6e4f; --accent-soft: #e3f2ec; --line: #e4e0d8;
  --chip: #f1f4f2; --doc: #c4392d; --shadow: 0 1px 1.5px rgba(0,0,0,.13);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wall: #0c1517; --wall-dot: #13201f;
    --bar: #13262a; --bar-ink: #e8efed; --bar-muted: #93aaa4;
    --in: #1b2a2e; --out: #145240; --ink: #e8efed; --muted: #a2b3ae;
    --accent: #5ad6a8; --accent-soft: #173a31; --line: #2a3b3f;
    --chip: #233438; --doc: #e0594b; --shadow: 0 1px 1.5px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --wall: #0c1517; --wall-dot: #13201f;
  --bar: #13262a; --bar-ink: #e8efed; --bar-muted: #93aaa4;
  --in: #1b2a2e; --out: #145240; --ink: #e8efed; --muted: #a2b3ae;
  --accent: #5ad6a8; --accent-soft: #173a31; --line: #2a3b3f;
  --chip: #233438; --doc: #e0594b; --shadow: 0 1px 1.5px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; color: var(--ink);
  font: 16px/1.5 system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--wall);
  background-image: radial-gradient(var(--wall-dot) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--in); padding: .5rem 1rem; z-index: 20; }
.skip:focus { left: 8px; }

/* Barra superior, como la cabecera de un chat */
.bar {
  position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-ink);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.bar-in { max-width: 780px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; gap: .75rem; }
.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bar-ink); color: var(--bar); font-weight: 700; letter-spacing: .02em; text-decoration: none;
}
.who { flex: 1; min-width: 0; line-height: 1.25; }
.who strong { display: block; font-size: 1.02rem; }
.who span { display: block; font-size: .82rem; color: var(--bar-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-btn {
  flex: none; background: transparent; color: var(--bar-ink); border: 1px solid color-mix(in srgb, var(--bar-ink) 40%, transparent);
  border-radius: 999px; padding: .3rem .75rem; font: inherit; font-size: .85rem; cursor: pointer; text-decoration: none;
}
.bar-btn:hover { background: color-mix(in srgb, var(--bar-ink) 14%, transparent); }
/* Sin JS el botón no sirve, así que no se muestra. Muestra la luna en claro y el sol en oscuro. */
.theme-btn { width: 38px; height: 34px; padding: 0; display: none; place-items: center; }
.js .theme-btn { display: grid; }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }

/* Hilo */
.thread { max-width: 780px; margin: 0 auto; padding: 1rem 1rem 3rem; display: flex; flex-direction: column; gap: .45rem; }
.chip-day {
  align-self: center; background: var(--in); color: var(--muted); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .06em; padding: .25rem .7rem; border-radius: 8px; box-shadow: var(--shadow); margin: .4rem 0 .6rem;
}
.msg {
  position: relative; max-width: min(88%, 620px); padding: .5rem .75rem .55rem; border-radius: 10px;
  box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.msg.in { align-self: flex-start; background: var(--in); border-top-left-radius: 3px; }
.msg.out { align-self: flex-end; background: var(--out); border-top-right-radius: 3px; }
.msg.wide { max-width: 100%; width: 100%; }
.msg p { margin: .2rem 0; }
.msg h1 { font-size: 1.55rem; line-height: 1.2; margin: .15rem 0; }
.msg h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); margin: .1rem 0 .3rem; }
.msg h3 { font-size: 1rem; margin: 0; }
.ticks { float: right; margin: .35rem 0 -.2rem .6rem; color: #3b9bd6; font-size: .75rem; letter-spacing: -.25em; }
.group-start { margin-top: .9rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; margin: .4rem 0 .2rem; padding: 0; list-style: none; }
.stats li { background: var(--accent-soft); border-radius: 8px; padding: .45rem .6rem; font-size: .85rem; color: var(--muted); }
.stats b { display: block; font-size: 1.35rem; color: var(--ink); }

.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .45rem 0 .1rem; padding: 0; list-style: none; }
.tags li { background: var(--chip); border-radius: 999px; padding: .12rem .6rem; font-size: .82rem; }

/* Botones de respuesta rápida */
.quick { align-self: flex-start; display: flex; flex-wrap: wrap; gap: .4rem; max-width: min(88%, 620px); margin: .1rem 0 .3rem; }
.quick a {
  background: var(--in); color: var(--accent); text-decoration: none; font-weight: 600; font-size: .92rem;
  padding: .45rem .95rem; border-radius: 999px; box-shadow: var(--shadow);
}
.quick a:hover { background: var(--accent-soft); }

/* Mensaje de lista: años como filas desplegables */
.list { margin: .4rem -.75rem -.55rem; border-top: 1px solid var(--line); }
.list details { border-bottom: 1px solid var(--line); }
.list details:last-child { border-bottom: 0; }
.list summary {
  list-style: none; cursor: pointer; padding: .7rem .75rem; display: flex; align-items: baseline; gap: .7rem;
}
.list summary::-webkit-details-marker { display: none; }
.list summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.3rem; line-height: 1; transition: transform .15s; }
.list details[open] summary::after { transform: rotate(90deg); }
.list .yr { flex: none; font-weight: 700; color: var(--accent); min-width: 5.6rem; font-variant-numeric: tabular-nums; }
.list .body { padding: 0 .75rem .8rem; }
.list ul.pts { margin: 0; padding-left: 1.1rem; }
.list ul.pts li { margin: .25rem 0; }
.list .cl { font-size: .85rem; color: var(--muted); margin-top: .35rem; }

/* Carrusel de proyectos */
.carousel { position: relative; margin: .4rem -.25rem 0; }
.cards {
  display: flex; gap: .7rem; overflow-x: auto; scroll-snap-type: x mandatory; padding: .2rem .25rem .7rem;
  list-style: none; margin: 0; scrollbar-width: thin;
}
.card {
  flex: 0 0 min(78%, 270px); scroll-snap-align: start; background: var(--in); border: 1px solid var(--line);
  border-radius: 12px; display: flex; flex-direction: column; overflow: hidden;
}
.card .cover { height: 64px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, var(--out))); display: flex; align-items: flex-end; padding: .4rem .7rem; color: #fff; font-size: .8rem; font-weight: 600; }
.card .txt { padding: .6rem .75rem; flex: 1; }
.card .txt p { font-size: .9rem; color: var(--muted); margin: .3rem 0 0; }
.card .cta { border-top: 1px solid var(--line); text-align: center; padding: .55rem; font-weight: 600; text-decoration: none; display: block; }
.card .cta:hover { background: var(--accent-soft); }
.card .cta.none { color: var(--muted); font-weight: 400; font-size: .85rem; }
.car-nav { display: none; }
.js .car-nav { display: flex; justify-content: flex-end; gap: .4rem; margin-top: -.2rem; }
.car-nav button {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--in); color: var(--ink);
  cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.car-nav button:disabled { opacity: .35; cursor: default; }

/* Habilidades */
.skills { display: grid; gap: .55rem; margin-top: .3rem; }
.skills h3 { font-size: .85rem; color: var(--muted); font-weight: 600; }
.skills .tags { margin-top: .2rem; }

/* Documento PDF */
.doc {
  display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--ink);
  background: color-mix(in srgb, var(--ink) 6%, transparent); border-radius: 8px; padding: .6rem .7rem; margin: .35rem 0;
}
.doc:hover { background: color-mix(in srgb, var(--ink) 11%, transparent); }
.doc .ico { flex: none; width: 36px; height: 44px; border-radius: 4px; background: var(--doc); color: #fff; font-size: .68rem; font-weight: 700; display: grid; place-items: end center; padding-bottom: 5px; }
.doc .name { display: block; font-weight: 600; }
.doc .meta { display: block; font-size: .8rem; color: var(--muted); }
.doc .dl { margin-left: auto; color: var(--muted); font-size: 1.2rem; }

/* Botones CTA al pie del mensaje */
.ctas { margin: .5rem -.75rem -.55rem; border-top: 1px solid var(--line); }
.ctas a { display: flex; justify-content: center; align-items: center; gap: .45rem; padding: .6rem; font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--line); }
.ctas a:last-child { border-bottom: 0; }
.ctas a:hover { background: var(--accent-soft); }

/* Caso de estudio */
.case-meta { color: var(--muted); font-size: .9rem; margin: .1rem 0 .2rem; }
.msg ul.pts { margin: .2rem 0; padding-left: 1.15rem; }
.msg ul.pts li { margin: .3rem 0; }

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 0 1rem 2rem; }

/* Escribiendo… y aparición progresiva (solo con JS) */
.typing { align-self: flex-start; background: var(--in); border-radius: 10px; padding: .55rem .8rem; box-shadow: var(--shadow); display: flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.js .pending { display: none; }
.js .fade { opacity: 0; transform: translateY(8px); transition: opacity .35s ease, transform .35s ease; }
.js .fade.shown { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js .fade { opacity: 1; transform: none; transition: none; } .typing i { animation: none; } }

@media (max-width: 480px) {
  .msg { max-width: 94%; }
  .msg h1 { font-size: 1.35rem; }
  .list .yr { min-width: 4.9rem; }
  .bar-btn.lang { padding: .3rem .55rem; }
}

@media print {
  body { background: #fff; }
  .bar, .quick, .car-nav, .skip, .typing { display: none !important; }
  .js .fade, .js .pending { opacity: 1 !important; transform: none !important; display: block; }
  .msg { box-shadow: none; border: 1px solid #ddd; max-width: 100%; }
  .list details { display: block; } .list details > .body { display: block; }
  .cards { flex-wrap: wrap; overflow: visible; }
}
