/* ============================================
   PORTFOLIO OS — David Fontanet Bujaldón
   Terminal-inspired design system
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400;1,500&display=swap');

:root {
  /* surfaces */
  --bg-deep: #05080d;
  --bg: #0a0e14;
  --bg-elev: #0f141c;
  --bg-hover: #141a26;

  /* borders */
  --border: #1a2230;
  --border-soft: #121826;
  --border-bright: #243042;

  /* text */
  --text: #c5d4e6;
  --text-bright: #e6edf7;
  --text-muted: #5a6b80;
  --text-dim: #2e3d50;

  /* neon blue accents */
  --neon: #00d4ff;
  --neon-soft: #4ec5ff;
  --neon-deep: #0099cc;
  --neon-glow: rgba(0, 212, 255, 0.35);
  --neon-faint: rgba(0, 212, 255, 0.08);
  --neon-border: rgba(0, 212, 255, 0.22);

  /* status */
  --warn: #ffb454;
  --success: #4ade80;
  --error: #ff6e6e;
  --magenta: #c792ea;

  /* sizes */
  --sidebar-w: 280px;
  --topbar-h: 36px;
  --statusbar-h: 32px;
  --content-pad: 48px;

  /* type */
  --font: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Menlo, monospace;
  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-base: 14px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 28px;
  --fs-2xl: 40px;
  --fs-hero: clamp(48px, 8vw, 96px);
}

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

html, body {
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  overflow: hidden;
}

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

a { color: var(--neon); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--neon-soft); text-shadow: 0 0 8px var(--neon-glow); }

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
}

::selection { background: var(--neon-glow); color: var(--bg-deep); }

/* scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ============================================
   WINDOW SHELL
   ============================================ */
.os {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr var(--statusbar-h);
  height: 100vh;
  background: var(--bg);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  padding: 0 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  gap: 14px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  user-select: none;
}
.traffic { display: flex; gap: 8px; }
.traffic span {
  width: 12px; height: 12px; border-radius: 50%;
  background: #2a3242;
  border: 1px solid rgba(255,255,255,.04);
}
.traffic span:nth-child(1) { background: #ff5f57; }
.traffic span:nth-child(2) { background: #febc2e; }
.traffic span:nth-child(3) { background: #28c840; }

.topbar-title {
  flex: 1;
  text-align: center;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
}
.topbar-title .path-segment { color: var(--text); }
.topbar-title .path-sep { color: var(--text-dim); margin: 0 4px; }

.topbar-right { display: flex; gap: 14px; align-items: center; }
.topbar-right .clock { color: var(--text); }
.topbar-right .lang-toggle {
  display: flex; gap: 0; border: 1px solid var(--border);
  border-radius: 3px; overflow: hidden;
}
.topbar-right .lang-toggle button {
  padding: 2px 8px; font-size: 10px; color: var(--text-muted);
  letter-spacing: 0.08em; cursor: pointer;
}
.topbar-right .lang-toggle button.active {
  background: var(--neon-faint); color: var(--neon);
}
.topbar-right .lang-toggle button:hover:not(.active) { color: var(--text); }

/* ============================================
   SIDEBAR — FILE TREE NAV
   ============================================ */
.sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
  user-select: none;
  font-size: var(--fs-sm);
}
.sidebar-heading {
  padding: 4px 16px 12px;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.tree { list-style: none; }
.tree li { line-height: 1.9; }
.tree-folder > .tree-label {
  color: var(--text);
  padding: 2px 16px;
  display: flex; align-items: center; gap: 6px;
}
.tree-folder > .tree-label::before {
  content: '▾'; font-size: 9px; color: var(--text-muted);
}
.tree-folder > ul { padding-left: 22px; }
.tree a {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 16px 2px 4px;
  color: var(--text-muted);
  position: relative;
  transition: all .12s;
}
.tree a::before {
  content: '─'; color: var(--text-dim); font-size: 11px;
}
.tree a:hover {
  color: var(--text-bright);
  background: var(--neon-faint);
  text-shadow: none;
}
.tree a.active {
  color: var(--neon);
  background: linear-gradient(90deg, var(--neon-faint), transparent);
  border-left: 2px solid var(--neon);
  padding-left: 2px;
}
.tree a.active::before { content: '▸'; color: var(--neon); }
.tree .icon { color: var(--text-dim); font-size: 11px; }
.tree a.active .icon { color: var(--neon); }

.sidebar-section { margin-top: 24px; }
.sidebar-meta {
  padding: 14px 16px;
  margin-top: auto;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.7;
  border-top: 1px solid var(--border-soft);
}
.sidebar-meta .key { color: var(--text-muted); }
.sidebar-meta .val { color: var(--text); }
.sidebar-meta a { color: var(--neon-soft); }

.led {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--success); box-shadow: 0 0 6px var(--success);
  margin-right: 6px; animation: pulse-led 2s ease-in-out infinite;
}
@keyframes pulse-led {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================
   CONTENT
   ============================================ */
.content {
  overflow-y: auto;
  padding: var(--content-pad);
  position: relative;
}
.content-inner { max-width: 1080px; margin: 0 auto; }

.prompt-line {
  display: flex; align-items: center; gap: 0;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: var(--fs-sm);
  flex-wrap: wrap;
  min-height: 1.6em;
}
.prompt-user { color: var(--success); }
.prompt-sep { color: var(--text-dim); margin: 0 2px; }
.prompt-host { color: var(--neon); }
.prompt-path { color: var(--magenta); }
.prompt-dollar { color: var(--text); margin: 0 8px 0 4px; }
.prompt-cmd { color: var(--text-bright); }
.prompt-flag { color: var(--warn); }
.prompt-arg { color: var(--text); }

/* spaces between command tokens (JSX swallows literal whitespace between sibling spans) */
.prompt-cmd + .prompt-flag,
.prompt-cmd + .prompt-arg,
.prompt-flag + .prompt-flag,
.prompt-flag + .prompt-arg,
.prompt-arg + .prompt-flag,
.prompt-arg + .prompt-arg { margin-left: 0.45em; }

.caret {
  display: inline-block; width: 9px; height: 1.1em;
  background: var(--neon); vertical-align: -2px; margin-left: 4px;
  animation: blink 1.1s steps(1) infinite;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
.h1, h1 {
  font-size: var(--fs-2xl);
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.h2, h2 {
  font-size: var(--fs-xl);
  font-weight: 500;
  color: var(--text-bright);
  letter-spacing: -0.01em;
  margin: 48px 0 16px;
}
.h3, h3 {
  font-size: var(--fs-lg);
  font-weight: 500;
  color: var(--neon);
  margin: 32px 0 12px;
}
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.bright { color: var(--text-bright); }
.neon { color: var(--neon); }
.warn { color: var(--warn); }
.success { color: var(--success); }
.magenta { color: var(--magenta); }
.error { color: var(--error); }

p { margin-bottom: 16px; }
p strong { color: var(--text-bright); font-weight: 500; }
p em { color: var(--neon-soft); font-style: italic; }

.comment { color: var(--text-dim); }
/* the text already starts with // so no automatic prefix */

.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-bright);
  border-bottom-width: 2px;
  border-radius: 3px;
  background: var(--bg-elev);
  font-size: 11px;
  color: var(--text-bright);
}

/* ============================================
   STATUS BAR
   ============================================ */
.statusbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  padding: 0 14px;
  font-size: 11px;
  color: var(--text-muted);
  gap: 16px;
  user-select: none;
}
.statusbar .seg { display: flex; align-items: center; gap: 6px; }
.statusbar .seg.accent { color: var(--neon); }
.statusbar .seg.spacer { flex: 1; }

.cmd-input-wrap {
  flex: 1;
  display: flex; align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 4px 10px;
  margin: 4px 8px;
  max-width: 520px;
  position: relative;
}
.cmd-suggestions {
  position: absolute;
  left: -1px; right: -1px;
  bottom: calc(100% + 4px);
  background: var(--bg-elev);
  border: 1px solid var(--neon-border);
  border-left: 2px solid var(--neon);
  padding: 6px 12px;
  display: flex; flex-wrap: wrap; gap: 4px 18px;
  font-size: 11px;
  box-shadow: 0 -4px 18px rgba(0,0,0,.45), 0 0 12px var(--neon-faint);
  animation: sug-in .14s ease-out;
  z-index: 50;
}
@keyframes sug-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cmd-suggestions .sug {
  color: var(--text-muted);
  padding: 1px 2px;
  white-space: nowrap;
}
.cmd-suggestions .sug.active {
  color: var(--neon);
  text-shadow: 0 0 6px var(--neon-glow);
  background: var(--neon-faint);
  padding: 1px 6px;
  border-radius: 2px;
}
.cmd-suggestions .dim { color: var(--text-dim); }
.cmd-suggestions .sug.active .dim { color: var(--neon-soft); }
.cmd-input-wrap .prompt-mini {
  color: var(--neon); font-size: var(--fs-xs);
}
.cmd-input {
  flex: 1; color: var(--text-bright);
  font-size: var(--fs-xs);
}
.cmd-input::placeholder { color: var(--text-dim); }
.cmd-hint { color: var(--text-dim); font-size: 10px; }

/* ============================================
   TOAST (easter-egg output)
   ============================================ */
.toast-stack {
  position: fixed;
  bottom: calc(var(--statusbar-h) + 12px);
  left: var(--sidebar-w);
  margin-left: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9000;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--neon-border);
  border-left: 3px solid var(--neon);
  padding: 10px 14px;
  font-size: var(--fs-sm);
  color: var(--text-bright);
  max-width: min(620px, calc(100vw - var(--sidebar-w) - 32px));
  box-shadow: 0 4px 24px rgba(0,0,0,.4), 0 0 16px var(--neon-faint);
  animation: toast-in .25s ease-out;
}
.toast.warn { border-left-color: var(--warn); border-color: rgba(255,180,84,.3); }
.toast.error { border-left-color: var(--error); border-color: rgba(255,110,110,.3); }
.toast.success { border-left-color: var(--success); border-color: rgba(74,222,128,.3); }
.toast.fade-out { animation: toast-out .25s ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px); }
}
.toast .label { color: var(--text-muted); font-size: 10px; letter-spacing: 0.1em; }
.toast .help-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 18px;
  row-gap: 4px;
  font-size: 11.5px;
  line-height: 1.6;
  margin-top: 8px;
}
.toast .help-row { display: contents; }
.toast .help-row .help-k { color: var(--neon); white-space: nowrap; }
.toast .help-row .help-v { color: var(--text-muted); }

/* ============================================
   COMMON BLOCKS
   ============================================ */
.codeblock {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: var(--fs-sm);
  white-space: pre-wrap;
  overflow-x: auto;
}
.codeblock-header {
  display: flex; justify-content: space-between;
  background: var(--bg-elev);
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  margin-top: 16px;
}
.codeblock-header + .codeblock { margin-top: 0; border-radius: 0 0 4px 4px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--border-bright);
  border-radius: 3px;
  font-size: 11px;
  color: var(--text);
  background: var(--bg-elev);
}
.badge.neon { border-color: var(--neon-border); color: var(--neon); background: var(--neon-faint); }
.badge.dim { color: var(--text-muted); }

/* boot screen */
.boot {
  position: fixed; inset: 0;
  background: var(--bg-deep);
  z-index: 8000;
  padding: 40px;
  color: var(--text);
  font-size: var(--fs-sm);
  display: flex; flex-direction: column; gap: 4px;
  overflow: hidden;
  transition: opacity .4s ease;
}
.boot.gone { opacity: 0; pointer-events: none; }
.boot .b-line { opacity: 0; animation: boot-in .12s forwards; }
.boot .b-ok { color: var(--success); }
.boot .b-warn { color: var(--warn); }
.boot .b-info { color: var(--neon); }
.boot .b-dim { color: var(--text-muted); }
@keyframes boot-in { to { opacity: 1; } }

/* matrix easter egg overlay */
.matrix-canvas {
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none; opacity: 0;
  transition: opacity .3s;
}
.matrix-canvas.on { opacity: 1; pointer-events: auto; }
.matrix-exit-hint {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  color: var(--neon); font-size: 13px;
  background: var(--bg-deep); padding: 8px 14px;
  border: 1px solid var(--neon-border);
  z-index: 10000; opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.matrix-canvas.on ~ .matrix-exit-hint { opacity: 1; }

/* ============================================
   STAGE SEQUENCE — typewriter + staged reveals
   ============================================ */
.tw-stage > * { transition: opacity .35s ease; }
.tw-hidden { opacity: 0 !important; visibility: hidden !important; }
.tw-shown {
  opacity: 1; visibility: visible;
  animation: tw-fade-up .42s cubic-bezier(.2,.7,.3,1) backwards;
}
@keyframes tw-fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* live caret on the element currently being typed */
.tw-active::after {
  content: '';
  display: inline-block;
  width: 8px;
  height: 1.05em;
  background: var(--neon);
  vertical-align: -2px;
  margin-left: 3px;
  box-shadow: 0 0 6px var(--neon-glow);
  animation: blink 1s steps(1) infinite;
}
.tw-active.prompt-line::after { height: 1em; }
.tw-done::after { display: none; }

/* ASCII art "scan" reveal */
.ascii-name.tw-scan {
  clip-path: inset(0 0 100% 0);
  animation: tw-scan .85s cubic-bezier(.5,0,.2,1) forwards;
}
@keyframes tw-scan {
  0%   { clip-path: inset(0 0 100% 0); filter: brightness(1.7) blur(0.6px); }
  60%  { filter: brightness(1.3) blur(0); }
  100% { clip-path: inset(0 0 0 0); filter: brightness(1) blur(0); }
}

/* glitch on `theme` cmd */
html.glitch { animation: glitch .12s steps(3) 12; }
@keyframes glitch {
  0% { filter: hue-rotate(0deg); }
  25% { filter: hue-rotate(-40deg) saturate(1.3); transform: translateX(-1px); }
  50% { filter: hue-rotate(20deg); transform: translateX(1px); }
  75% { filter: hue-rotate(-10deg); transform: translateX(0); }
  100% { filter: hue-rotate(0deg); }
}

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  .tw-hidden { opacity: 1 !important; visibility: visible !important; }
  .tw-active::after { display: none; }
  .ascii-name.tw-scan { animation: none; clip-path: none; }
  .tw-shown { animation: none; }
}

/* responsive */
@media (max-width: 880px) {
  :root { --sidebar-w: 0px; --content-pad: 24px; }
  .sidebar { display: none; }
  .topbar-title { font-size: 10px; }
  .cmd-input-wrap { display: none; }
}

/* ============================================
   ROUTE LOADER — mini bash splash between pages
   ============================================ */
.route-load {
  position: fixed; inset: 0; z-index: 100000;
  background: rgba(5, 8, 13, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease;
}
.route-load.on { opacity: 1; pointer-events: auto; }
.rl-card {
  background: var(--bg);
  border: 1px solid var(--neon-border);
  box-shadow: 0 0 32px var(--neon-faint), 0 12px 60px rgba(0,0,0,.55);
  padding: 18px 22px 20px;
  min-width: 380px;
  max-width: 86vw;
  font-size: var(--fs-sm);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  transform: translateY(-4px) scale(.98);
  opacity: 0;
  animation: rl-card-in .22s cubic-bezier(.2,.7,.3,1) forwards;
}
.rl-card::before {
  /* faint top scanline */
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--neon), transparent);
  opacity: .5;
  animation: rl-scan 1.2s linear infinite;
}
@keyframes rl-card-in { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes rl-scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.rl-prompt { color: var(--text-muted); margin-bottom: 8px; line-height: 1.5; }
.rl-prompt .u { color: var(--success); }
.rl-prompt .h { color: var(--neon); }
.rl-prompt .d { color: var(--text-dim); }
.rl-prompt .cmd { color: var(--text-bright); }
.rl-status {
  color: var(--text); margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
  font-size: var(--fs-xs);
}
.rl-status .badge {
  background: var(--neon-faint);
  border: 1px solid var(--neon-border);
  color: var(--neon); padding: 1px 6px; border-radius: 2px;
  font-size: 10px; letter-spacing: 0.08em;
  animation: pulse-led .6s ease-in-out infinite;
}
.rl-status .target { color: var(--neon); }
.rl-bar {
  height: 6px; background: var(--bg-deep); border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.rl-bar > i {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, var(--neon-deep), var(--neon));
  box-shadow: 0 0 10px var(--neon-glow);
  width: 0;
  animation: rl-fill .48s cubic-bezier(.3,.7,.4,1) forwards;
}
.rl-bar::after {
  /* moving highlight */
  content: ''; position: absolute; top: 0; bottom: 0; width: 24px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: rl-sweep .9s linear infinite;
}
@keyframes rl-fill { to { width: 100%; } }
@keyframes rl-sweep { 0% { left: -24px; } 100% { left: 100%; } }
.rl-meta {
  margin-top: 8px;
  display: flex; gap: 12px; justify-content: space-between;
  font-size: 10px; color: var(--text-dim);
  letter-spacing: 0.08em;
}
.rl-meta .ok { color: var(--success); }

@media (prefers-reduced-motion: reduce) {
  .rl-card { animation: none; opacity: 1; transform: none; }
  .rl-card::before, .rl-bar::after { display: none; }
  .rl-bar > i { animation: none; width: 100%; }
}
