/* nelson-dev — terminal session. Tokens en DESIGN.md.
   Mobile-first: en móvil el terminal es fullscreen (como una app);
   la ventana flotante sobre escritorio es la mejora de desktop. */

:root {
  --desk: #05070c;
  --term: #0d1420;
  --term-raised: #151d2c;
  --border: #1e2939;
  --text: #c9d4e3;
  --dim: #7e8ba0;
  --green: #5cf08c;
  --cyan: #67e0f5;
  --yellow: #e8d576;
  --magenta: #e08fd0;
  --red: #f2555a;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--desk);
  color: var(--text);
  font-family: var(--mono);
  font-variant-ligatures: none;
  font-size: 15px;
  font-size-adjust: from-font;
  line-height: 1.7;
  min-height: 100svh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--cyan); color: var(--term); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: absolute; left: 1rem; top: -3rem;
  background: var(--green); color: var(--term);
  padding: 0.4rem 0.8rem; z-index: 10; transition: top 120ms ease-out;
}
.skip-link:focus { top: 1rem; }

a { color: var(--cyan); text-underline-offset: 0.25em; }
a:hover { background: var(--cyan); color: var(--term); text-decoration: none; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

/* ---------- Ventana: fullscreen en móvil ---------- */

.window {
  background: var(--term);
  min-height: 100svh;
}

.titlebar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  justify-content: space-between;
  background: var(--term-raised);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
}

.traffic { display: flex; gap: 0.5rem; flex-shrink: 0; }
.traffic i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.tl-red { background: var(--red); }
.tl-yellow { background: #f5bd4f; }
.tl-green { background: #33c748; }

.titlebar-title {
  display: none;
  flex: 1; text-align: center;
  color: var(--dim); font-size: 0.8125rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.lang-switch { display: flex; align-items: center; gap: 0.35rem; color: var(--dim); font-size: 0.8125rem; }
.lang-switch button {
  font: inherit; color: var(--dim);
  background: none; border: 1px solid transparent; border-radius: 4px;
  padding: 0.35rem 0.6rem; cursor: pointer;
}
.lang-switch button:hover { color: var(--text); border-color: var(--border); }
.lang-switch button[aria-pressed="true"] {
  color: var(--term); background: var(--green); font-weight: 600;
}

/* ---------- Sesión ---------- */

.session {
  padding: 1.5rem 1.1rem 1rem;
}

.block + .block { margin-top: 3rem; }
.block { scroll-margin-top: 4.5rem; }

.cmd {
  font-size: 1rem; font-weight: 400;
  word-break: break-word;
}
.prompt { color: var(--green); font-weight: 600; }
.cmd-text { color: var(--text); font-weight: 600; }

.caret {
  display: inline-block; width: 0.6em; height: 1.1em;
  background: var(--green); vertical-align: text-bottom; margin-left: 2px;
}
@media (prefers-reduced-motion: no-preference) {
  .caret { animation: blink 1.1s steps(1) infinite; }
  @keyframes blink { 50% { opacity: 0; } }
}

.output { margin-top: 0.9rem; }

.comment { color: var(--dim); }
.dim { color: var(--dim); }

/* ---------- Hero ---------- */

.banner {
  color: var(--green);
  font-size: clamp(0.36rem, 1.9vw, 1.02rem);
  line-height: 1.25;
  text-shadow: 0 0 18px rgba(92, 240, 140, 0.35);
  overflow-x: auto;
  margin-bottom: 1.1rem;
}

.hero h1 {
  font-size: 1.05rem; font-weight: 600; letter-spacing: 0.01em;
  margin-bottom: 0.2rem;
}

.role { color: var(--cyan); font-weight: 600; }

.pitch { max-width: 58ch; margin-top: 0.9rem; }

.hero .comment { margin-top: 0.9rem; }

.hero-nav { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; margin-top: 1.6rem; }
.hero-nav a { font-weight: 600; padding-block: 0.25rem; }

/* ---------- git log ---------- */

.gitlog {
  border-left: 1px solid var(--border);
  margin-left: 0.3rem;
}

.commit { padding: 0 0 0 0.9rem; position: relative; }
.commit + .commit { margin-top: 1.4rem; }
.commit[open] + .commit, .commit[open] { margin-top: 2rem; }
.commit[open]:first-child { margin-top: 0; }

.commit::before {
  content: "";
  position: absolute; left: -4px; top: 0.55em;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--yellow);
}

.commit summary { list-style: none; cursor: pointer; border-radius: 4px; padding-block: 0.3rem; }
.commit summary::-webkit-details-marker { display: none; }
.commit summary:hover { background: rgba(30, 41, 57, 0.45); }

.disc { color: var(--dim); font-weight: 400; margin-left: 0.6rem; white-space: nowrap; }
.disc::before { content: "[+]"; }
.commit[open] .disc::before { content: "[-]"; }

.show-body { margin-top: 0.6rem; }
.show-meta { color: var(--dim); font-size: 0.8125rem; }
.gitkey { display: inline-block; min-width: 4.2rem; }
.show-url { margin-top: 0.8rem; font-size: 0.8125rem; }
.show-url .gitkey { color: var(--dim); }

.exp-hint { margin-top: 0.6rem; margin-bottom: 1.2rem; font-size: 0.8125rem; }

.commit-line { font-size: 1rem; font-weight: 400; line-height: 1.6; }
.graph { color: var(--dim); }
.hash { color: var(--yellow); }
.refs { color: var(--yellow); }
.ref-head { color: var(--cyan); font-weight: 600; }
.ref-branch { color: var(--green); }
.ref-tag { color: var(--magenta); }
.commit-role { font-weight: 800; color: var(--text); }
.commit-org { color: var(--cyan); font-weight: 600; }

.commit ul { list-style: none; margin-top: 0.6rem; max-width: 68ch; }
.commit li { padding-left: 1.1rem; position: relative; }
.commit li + li { margin-top: 0.45rem; }
.commit li::before { content: "-"; position: absolute; left: 0; color: var(--green); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.8rem; }
.chips span {
  font-size: 0.75rem; line-height: 1;
  color: #9fb0c8;
  border: 1px solid var(--border);
  background: rgba(30, 41, 57, 0.35);
  border-radius: 4px;
  padding: 0.3rem 0.5rem;
}

/* ---------- tree ---------- */

.tree-root { color: var(--dim); }
.tree-list, .tree-list ul { list-style: none; }
.tree-list > li { margin-top: 0.7rem; padding-left: 1.25rem; position: relative; }
.tree-list > li::before { content: "├──"; position: absolute; left: 0; margin-left: -0.5rem; color: var(--border); letter-spacing: -0.04em; }
.tree-list > li:last-child::before { content: "└──"; }
.tree-list .dir { color: var(--cyan); font-weight: 600; }
.tree-list ul { padding-left: 1.5rem; }
.tree-list ul li { position: relative; }
.tree-list ul li::before { content: "│"; position: absolute; left: -1.1rem; color: var(--border); }
.tree-count { margin-top: 1rem; }

/* ---------- markdown crudo (cat about.md) ---------- */

.md-h { font-weight: 800; margin-bottom: 0.8rem; }
.md-tok { color: var(--dim); font-weight: 400; }
.md-list { list-style: none; margin-top: 0.9rem; }
.md-list li { padding-left: 1.1rem; position: relative; }
.md-list li + li { margin-top: 0.55rem; }
.md-list li::before { content: "-"; position: absolute; left: 0; color: var(--green); }
.md-list strong { color: var(--cyan); font-weight: 600; }

/* ---------- contacto / exit ---------- */

.linkedin-link {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.8rem 1.2rem;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  font-weight: 600;
  text-decoration: none;
}
.linkedin-link:hover, .linkedin-link:focus-visible { background: var(--cyan); color: var(--term); }

.exit {
  padding: 0 1.1rem 2rem;
  margin-top: 2rem;
}
.exit .process-done { color: var(--dim); margin-top: 0.3rem; }
.exit .colophon { color: var(--dim); font-size: 0.8125rem; margin-top: 1.2rem; }

.prose p + p { margin-top: 0.8rem; }
.prose { max-width: 68ch; }

/* ---------- Motion: tipeo del hero ---------- */

/* Sin JS todo queda visible; con JS el hero se orquesta desde main.js */
.js .hero-output.pre-type { opacity: 0; }
.hero-output.typed-in { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .hero-output.typed-in { animation: rise 500ms cubic-bezier(0.16, 1, 0.3, 1) backwards; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
  }
}

/* ---------- Motion: reveals de sección (scroll-driven + fallback) ---------- */

@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    .reveal {
      animation: reveal-in auto cubic-bezier(0.16, 1, 0.3, 1) backwards;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }
  }
  @keyframes reveal-in {
    from { opacity: 0.01; transform: translateY(14px); }
  }
  /* Fallback IO: main.js añade .io-pending / .io-visible solo si no hay soporte */
  .reveal.io-pending { opacity: 0; transform: translateY(14px); }
  .reveal.io-visible {
    opacity: 1; transform: none;
    transition: opacity 550ms cubic-bezier(0.16, 1, 0.3, 1), transform 550ms cubic-bezier(0.16, 1, 0.3, 1);
  }
}

/* ---------- Desktop: la ventana flota sobre el escritorio ---------- */

@media (min-width: 720px) {
  body {
    background:
      radial-gradient(120% 90% at 50% 0%, #0a101c 0%, var(--desk) 60%),
      var(--desk);
    padding: clamp(1.5rem, 3vw, 3rem) clamp(1rem, 3vw, 2rem) clamp(2.5rem, 6vw, 5rem);
  }

  .window {
    max-width: 62rem;
    min-height: 0;
    margin-inline: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
    overflow: clip;
  }

  .titlebar { padding: 0.6rem 1rem; }
  .titlebar-title { display: block; }

  .session { padding: clamp(2rem, 4vw, 3rem) clamp(2rem, 4vw, 3.25rem); }
  .block + .block { margin-top: clamp(3.5rem, 7vw, 4.5rem); }

  .output { padding-left: 1.25rem; }
  .gitlog { margin-left: 0.3rem; }
  .commit { padding-left: 1.6rem; }

  .exit { padding: 0 clamp(2rem, 4vw, 3.25rem) clamp(1.5rem, 4vw, 3rem); }
}
