/* ============================================================
   Mateo González Silva — portfolio. Un color, líneas finas.
   ============================================================ */
:root {
  --bg: #14233f;
  --fg: #fff8ef;
  --soft: rgba(255, 248, 239, 0.76);
  --line: rgba(255, 248, 239, 0.35);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --pad: clamp(1.25rem, 6vw, 5rem);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--fg); font-family: "Space Grotesk", system-ui, sans-serif;
  line-height: 1.4; overflow-x: hidden; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; text-align: left; }
img { display: block; }
::selection { background: var(--fg); color: var(--bg); }

#track { position: fixed; inset: 0; z-index: 0; }
main { position: relative; z-index: 1; }

.meter {
  position: fixed; right: var(--pad); top: 1.2rem; z-index: 5; pointer-events: none;
  font-size: 0.85rem; font-variant-numeric: tabular-nums;
}

/* ---------- Inicio ---------- */
.start { min-height: 100svh; padding: 4rem var(--pad) 3rem; display: flex; flex-direction: column; justify-content: flex-end; }
.start h1 { flex: none; white-space: nowrap; font-family: "Anton", Impact, sans-serif; font-weight: 400; font-size: min(clamp(4.5rem, 16vw, 15rem), 25svh); line-height: 1.04; }
.start__text { margin-top: 1.4rem; font-size: clamp(1rem, 1.6vw, 1.35rem); max-width: 30ch; }

/* Letras del nombre: cada una sube desde detrás de su máscara */
.ch { display: inline-block; overflow: hidden; vertical-align: top; padding-top: 0.14em; margin-top: -0.14em; }
.ch > i { display: inline-block; font-style: normal; transition: transform 0.3s var(--ease); }
.js .ch > i { transform: translateY(115%); animation: rise 0.9s var(--ease) forwards; animation-delay: calc(var(--i) * 32ms + 120ms); }
@keyframes rise { to { transform: none; } }
.ch:hover > i { translate: 0 -0.05em; }

/* ---------- Secciones ---------- */
.sec { padding: 5rem var(--pad) 0; }
.sec h2 { font-size: 0.9rem; font-weight: 500; margin-bottom: 0.8rem; }

.rows > li { position: relative; }
/* La línea se dibuja de izquierda a derecha al entrar en pantalla */
.rows > li::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--line);
  transform-origin: left; transition: transform 1.1s var(--ease);
}
.js .rows > li[data-reveal]:not(.in)::before { transform: scaleX(0); }

.row { display: flex; align-items: center; gap: 1rem; width: 100%; padding: 1.05rem 0; }
.row img { flex: none; width: 40px; height: 40px; object-fit: cover; border-radius: 9px; transition: transform 0.4s var(--ease); }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; transition: transform 0.4s var(--ease); }
.row__title { font-size: clamp(1.1rem, 2vw, 1.45rem); font-weight: 500; line-height: 1.2; }
.row__title--scramble { display: block; white-space: nowrap; overflow: hidden; user-select: none; }
.scramble__loose { opacity: 0.35; }
.row__title--scramble.is-wrong { color: #ff6b5e; animation: nope 0.35s ease; }
@keyframes nope { 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.row__tag { font-size: clamp(0.98rem, 1.4vw, 1.1rem); margin-top: 0.15rem; }
.row__sub { overflow-wrap: anywhere; font-size: 0.9rem; color: var(--soft); margin-top: 0.15rem; }
.row__meta { flex: none; font-size: 0.9rem; color: var(--soft); }
.row__go { flex: none; width: 1.2em; height: 1.2em; overflow: hidden; opacity: 0; transform: translateX(-10px); transition: transform 0.4s var(--ease), opacity 0.25s; }

.row--link:hover .row__main, .row--link:focus-visible .row__main { transform: translateX(8px); }
.row--link:hover img { transform: rotate(-4deg) scale(1.06); }
.row--link:hover .row__go, .row--link:focus-visible .row__go { opacity: 1; transform: none; }
.row--link:active .row__main { transform: translateX(3px); }
.row--link:focus-visible { outline: 0; }

.tile { flex: none; width: 40px; height: 40px; border-radius: 9px; background: #fff; display: grid; place-items: center; }
.tile img { width: 72%; height: 72%; object-fit: contain; border-radius: 0; }
.tile--a { background: #d97757; }

/* ---------- Final ---------- */
.end { padding: 8rem var(--pad) 5rem; }
.end__mail {
  font-family: "Anton", Impact, sans-serif; font-size: clamp(1.9rem, 7.4vw, 7rem); line-height: 1.1;
  overflow-wrap: anywhere; background: linear-gradient(currentColor, currentColor) left bottom / 0 3px no-repeat;
  transition: background-size 0.5s var(--ease), opacity 0.8s, transform 0.8s var(--ease);
}
.end__mail:hover { background-size: 100% 3px; }
.end__links { display: flex; gap: 1.4rem; margin-top: 1.4rem; flex-wrap: wrap; }
.end__links a { background: linear-gradient(currentColor, currentColor) right bottom / 100% 1px no-repeat; transition: background-size 0.35s var(--ease); }
.end__links a:hover { background-size: 0 1px; }

/* ---------- Entrada al hacer scroll ---------- */
.js [data-reveal] { opacity: 0; transform: translateY(14px); transition: opacity 0.8s ease, transform 0.8s var(--ease); transition-delay: var(--d, 0ms); }
.js [data-reveal].in { opacity: 1; transform: none; }

/* ---------- Ventanas ---------- */
.win {
  position: fixed; z-index: 50; display: flex; flex-direction: column; min-width: 280px; min-height: 180px;
  border-radius: 12px; background: #1c1c1e; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 24px 70px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.2s;
}
.win[hidden] { display: none; }
.win.is-front { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 34px 100px rgba(0, 0, 0, 0.6); }
.win.is-busy { user-select: none; }
.win.is-busy .win__view { pointer-events: none; }
.win.is-eased { transition: left 0.32s var(--ease), top 0.32s var(--ease), width 0.32s var(--ease), height 0.32s var(--ease); }
.win__bar {
  flex: none; display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 14px; cursor: grab;
  touch-action: none; user-select: none; font-size: 13px; color: #aaa; border-radius: 12px 12px 0 0; background: #2a2a2d;
}
.win.is-busy .win__bar { cursor: grabbing; }
.win__dots { flex: none; display: flex; gap: 8px; width: 56px; }
.win__dots button { width: 13px; height: 13px; padding: 0; border-radius: 50%; background: #ff5f57; }
.win__dots button:nth-child(2) { background: #febc2e; }
.win__dots button:nth-child(3) { background: #28c840; }
.win__dots button:hover { filter: brightness(1.15); }
.win__title { flex: 1; min-width: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.win__title:hover { color: #fff; }
.win__view { flex: 1; min-height: 0; position: relative; overflow: hidden; background: #000; border-radius: 0 0 12px 12px; }
.win__view iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; }

/* Agarraderas: bordes y esquinas, más grandes que lo que se ve */
.grip { position: absolute; z-index: 2; touch-action: none; }
.grip--n, .grip--s { left: 14px; right: 14px; height: 12px; cursor: ns-resize; }
.grip--e, .grip--w { top: 14px; bottom: 14px; width: 12px; cursor: ew-resize; }
.grip--n { top: -6px; } .grip--s { bottom: -6px; } .grip--e { right: -6px; } .grip--w { left: -6px; }
.grip--nw, .grip--ne, .grip--sw, .grip--se { width: 24px; height: 24px; }
.grip--nw { left: -8px; top: -8px; cursor: nwse-resize; } .grip--se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.grip--ne { right: -8px; top: -8px; cursor: nesw-resize; } .grip--sw { left: -8px; bottom: -8px; cursor: nesw-resize; }

/* Terminal */
.term {
  flex: 1; min-height: 0; overflow: auto; padding: 16px 18px; background: #0f1012; color: #d7dae0; outline: 0;
  border-radius: 0 0 12px 12px; font: 13.5px/1.6 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
}
.term { scrollbar-width: none; }
.term::-webkit-scrollbar { display: none; }
.term .p { color: #7ee787; }
.term .h { color: #fff; font-weight: 700; }
.term .k { color: #79c0ff; }
.term .d { color: #7d8590; }
.term a { color: #79c0ff; text-decoration: underline; }
.term .cur { display: inline-block; width: 0.6em; height: 1.1em; vertical-align: text-bottom; background: #d7dae0; animation: blink 1.1s steps(1) infinite; }
.term__more { font: inherit; color: #79c0ff; text-decoration: underline; }
.term__media { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.term__media img, .term__media video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: #000; }
@keyframes blink { 50% { opacity: 0; } }

/* Escritorio: título a la izquierda, contenido a la derecha */
@media (min-width: 900px) {
  .start { flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 2rem; }
  .start__text { margin: 0 0 0.6rem; text-align: right; }
  .sec { display: grid; grid-template-columns: minmax(200px, 24%) 1fr; gap: 2rem; padding-top: 6.5rem; }
  .sec h2 { position: sticky; top: 1.4rem; align-self: start; font-family: "Anton", Impact, sans-serif; font-weight: 400; font-size: clamp(1.8rem, 2.8vw, 2.8rem); line-height: 1.1; }
  .row { padding: 1.35rem 0; gap: 1.4rem; }
  .row--proj img { width: 64px; height: 64px; border-radius: 14px; }
  .row--proj .row__title { font-family: "Anton", Impact, sans-serif; font-weight: 400; font-size: clamp(2rem, 3.4vw, 3.4rem); line-height: 1.1; }
}

@media (max-width: 560px) {
  .row__sub, .row__meta { font-size: 0.82rem; }
  .row__go { display: none; }
  .term { font-size: 12.5px; padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before { animation: none !important; transition: none !important; }
  .js .ch > i, .js [data-reveal] { opacity: 1; transform: none; }
  .js .rows > li[data-reveal]:not(.in)::before { transform: none; }
}
