/*
  MarcOS: la portada con forma de escritorio.
  Los colores, radios y tipografías salen de marca/tokens.css.
  Sin JavaScript (sin la clase .os en <html>) el contenido se lee como un documento normal.
*/

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Idioma: el HTML lleva los dos textos y solo se muestra el activo. */
html[lang="en"] .es, html[lang="es"] .en { display: none !important; }

.label {
  margin: 0 0 .6rem;
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--subtle);
}
.dot {
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: .35rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--glow);
  vertical-align: middle;
}

/* ---------- Barra superior ---------- */
.menubar {
  position: fixed; inset: 0 0 auto 0;
  z-index: 800;
  display: flex; justify-content: space-between; align-items: center;
  height: 38px;
  padding: 0 .6rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: .82rem;
}
.menubar-left, .menubar-right { display: flex; align-items: center; gap: .55rem; position: relative; }
.mb-logo {
  display: grid; place-items: center;
  width: 40px; height: 28px;
  background: none; border: 1px solid transparent; border-radius: var(--radius-control);
}
.mb-logo svg { width: 28px; }
.mb-logo:hover, .mb-logo[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--line); }
.mb-name { font-weight: 600; letter-spacing: -.01em; }
.mb-active { color: var(--muted); }
.mb-active:not(:empty)::before { content: "/ "; color: var(--subtle); }
.status {
  display: flex; align-items: center; gap: .55rem;
  height: 28px; padding: 0 .5rem;
  background: none; border: 1px solid transparent; border-radius: var(--radius-control);
  color: var(--muted);
}
.status:hover, .status[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--line); color: var(--ink); }
.status svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.status .st-batt { width: 19px; }
.status .off { opacity: .3; }
.st-pct, .mb-date, .mb-clock { font-family: var(--font-mono); font-size: .74rem; }
.st-pct { margin-left: -.3rem; }
.st-pct:empty { display: none; }
.mb-clock { color: var(--ink); }
.quick {
  position: absolute; top: 44px; right: 0; z-index: 5;
  width: 290px; padding: .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.skins { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.skins button {
  display: grid; gap: .35rem; padding: .4rem;
  background: none; border: 1px solid var(--line); border-radius: var(--radius-card);
  font-size: .74rem; text-align: left; color: var(--muted);
}
.skins button:hover { border-color: var(--accent); color: var(--ink); }
.skins button[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 2px var(--accent-soft); }
.skins i { display: block; height: 30px; border-radius: var(--radius-tag); border: 1px solid rgba(128, 128, 128, .25); }
.quick-info { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin: .8rem 0 0; }
.quick-info div { padding: .5rem .6rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-card); }
.quick-info dt { font-family: var(--font-mono); font-size: .62rem; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--subtle); }
.quick-info dd { margin: .1rem 0 0; font-size: .82rem; }
.lang { display: flex; border: 1px solid var(--line); border-radius: var(--radius-control); overflow: hidden; }
.lang button {
  padding: 0 .55rem; height: 26px;
  background: none; border: 0;
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .08em; color: var(--subtle);
}
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--button-ink); }
.start {
  position: fixed; z-index: 850;
  left: 50%; bottom: 86px; transform: translateX(-50%);
  width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 150px);
  display: flex; flex-direction: column; gap: .7rem; padding: .8rem;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-sheet);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.start.from-top { left: .6rem; top: 44px; bottom: auto; transform: none; }
.start input {
  height: 38px; padding: 0 .8rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-control);
  color: var(--ink); font: inherit; outline: 0;
}
.start input:focus { border-color: var(--accent); }
.start-list { overflow-y: auto; }
.start-group { margin: .5rem .3rem .3rem; font-family: var(--font-mono); font-size: .64rem; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--subtle); }
.start-group:first-child { margin-top: 0; }
.start-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .2rem; }
.start-grid button {
  display: grid; justify-items: center; align-content: start; gap: .35rem; padding: .6rem .2rem;
  background: none; border: 0; border-radius: var(--radius-card);
  font-size: .76rem; line-height: 1.2; text-align: center;
  min-width: 0; overflow-wrap: anywhere;
}
.start-grid button:hover, .start-grid button:focus-visible { background: var(--accent-soft); }
.start-grid .tile { width: 42px; height: 42px; }
.start-grid .tile img { width: 26px; height: 26px; object-fit: contain; }
.start-empty { grid-column: 1 / -1; margin: .6rem 0; text-align: center; color: var(--subtle); font-size: .84rem; }
.start-foot { display: flex; flex-wrap: wrap; gap: .3rem; padding-top: .6rem; border-top: 1px solid var(--line); }
.start-foot button { padding: .35rem .6rem; background: none; border: 1px solid var(--line); border-radius: var(--radius-control); font-size: .76rem; color: var(--muted); }
.start-foot button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Contenido de las apps (común a ventana y a documento) ---------- */
.app h2 { margin: 0 0 .2rem; font-size: 1.65rem; line-height: 1.15; letter-spacing: var(--tracking-heading); }
.app h3 { margin: 1.5rem 0 .6rem; font-size: 1.02rem; letter-spacing: -.02em; }
.app h4 { margin: 0 0 .35rem; font-size: .92rem; }
.app p { margin: 0 0 .85rem; color: var(--muted); }
.app strong { color: var(--ink); font-weight: 600; }
.app .sub { color: var(--subtle); font-size: .88rem; }
.app code { font-family: var(--font-mono); color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: 0 0 .9rem; }
.chips > span {
  padding: .16rem .55rem;
  border: 1px solid var(--line); border-radius: var(--radius-tag);
  background: var(--bg);
  font-family: var(--font-mono); font-size: .72rem; color: var(--muted);
}
.chip-label { margin: 0 0 .35rem !important; font-size: .76rem; color: var(--subtle) !important; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 1.1rem 0 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
.facts div { padding: .65rem .8rem; background: var(--surface); }
.facts dt { font-family: var(--font-mono); font-size: .64rem; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--subtle); }
.facts dd { margin: .15rem 0 0; font-size: .88rem; }

.note { margin-top: 1.4rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-left: 2px solid var(--accent); border-radius: var(--radius-card); background: var(--accent-soft); }
.note h3 { margin-top: 0; }
.note .next { margin: 0; font-size: .85rem; color: var(--ink); }

.job header { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: .9rem; }
.period { font-family: var(--font-mono); font-size: .74rem; color: var(--accent) !important; white-space: nowrap; margin: .3rem 0 0 !important; }
.job ul { margin: 0 0 1.1rem; padding-left: 1.1rem; color: var(--muted); }
.job li { margin-bottom: .45rem; }
.job li::marker { color: var(--accent); }

.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; margin: 1rem 0; }
.file {
  display: grid; justify-items: center; gap: .3rem;
  padding: 1rem .6rem .85rem;
  border: 1px solid var(--line); border-radius: var(--radius-card);
  background: var(--bg);
  color: var(--ink); text-align: center; text-decoration: none;
  transition: border-color .2s var(--ease), transform .2s var(--ease), background .2s var(--ease);
}
.file:hover { border-color: var(--accent); background: var(--surface-hover); color: var(--ink); transform: translateY(-2px); }
.file img { width: 44px; height: 44px; object-fit: contain; border-radius: var(--radius-card); }
.file strong { font-size: .88rem; }
.file small { font-size: .74rem; color: var(--subtle); line-height: 1.3; }
.more { margin: 0 !important; font-size: .88rem; }

.p-head { display: flex; align-items: center; gap: .9rem; margin-bottom: .9rem; }
.p-head img { width: 48px; height: 48px; object-fit: contain; border-radius: var(--radius-card); }
.p-head .label { margin-bottom: .2rem; }
.shots { display: flex; gap: .6rem; margin: .4rem 0 1.1rem; overflow-x: auto; padding-bottom: .3rem; }
.shots img { height: 250px; width: auto; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--bg); }
.shots.wide img { height: 190px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.btn {
  display: inline-flex; align-items: center;
  padding: .5rem .9rem;
  border: 1px solid var(--line); border-radius: var(--radius-control);
  color: var(--ink); font-size: .86rem; font-weight: 600; text-decoration: none;
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--button-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--button-ink); }
.meta { font-family: var(--font-mono); font-size: .72rem; color: var(--subtle); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 1px solid var(--line); }
.timeline li { position: relative; padding-bottom: 1rem; }
.timeline li::before { content: ""; position: absolute; left: calc(-1rem - 4px); top: .5rem; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline h3 { margin: .1rem 0 0; }
.timeline .period { margin: 0 !important; }
.plain { margin: 0; padding-left: 1.1rem; color: var(--muted); }
.plain li { margin-bottom: .35rem; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.cards article { padding: .85rem .95rem; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); }
.cards p { margin: 0; font-size: .85rem; }

.links { list-style: none; margin: 1.1rem 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden; }
.links li { display: flex; gap: 1rem; padding: .65rem .85rem; background: var(--bg); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.links li:last-child { border-bottom: 0; }
.links .k { flex: 0 0 4.2rem; font-family: var(--font-mono); font-size: .68rem; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--subtle); padding-top: .2rem; }

.sys-mark { width: 92px; margin-bottom: .6rem; }

/* ---------- Sin JavaScript: documento normal ---------- */
html:not(.os) .desktop { max-width: 760px; margin: 0 auto; padding: 70px 1.2rem 2rem; }
html:not(.os) .app { padding: 2rem 0; border-top: 1px solid var(--line); }
html:not(.os) .wall-mark, html:not(.os) .terminal, html:not(.os) .browser, html:not(.os) #sistema,
html:not(.os) .dock, html:not(.os) .icons, html:not(.os) .lang, html:not(.os) .status, html:not(.os) .start { display: none; }
html:not(.os) .wall h1 { font-size: 3rem; letter-spacing: var(--tracking-display); margin: 0 0 .5rem; }
html:not(.os) .plain-footer { padding: 1.5rem; text-align: center; color: var(--subtle); font-size: .8rem; }
.wall h1 em { font-style: normal; color: var(--accent); }

/* ====================================================================
   Modo escritorio (con JavaScript)
   ==================================================================== */
html.os, html.os body { height: 100%; overflow: hidden; }
html.os .plain-footer { display: none; }
html.os .desktop { position: fixed; inset: 38px 0 0 0; overflow: hidden; }

.os .wall { position: absolute; inset: 0; background-color: var(--bg); }
.os .wall::after { /* atenúa la cuadrícula para que no compita con el contenido */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 45%, transparent, var(--bg) 78%);
  opacity: .82; pointer-events: none;
}
.os .wall-mark {
  position: absolute; z-index: 1;
  right: clamp(1.5rem, 9vw, 9rem); top: 50%;
  width: min(34vw, 440px);
  transform: translateY(-58%);
  color: var(--ink); opacity: .1;
}
.os .wall-copy {
  position: absolute; z-index: 1;
  left: clamp(1.2rem, 9.5rem, 11rem); bottom: 104px;
  max-width: 30rem;
}
.os .wall h1 { margin: 0 0 .5rem; font-size: clamp(2.6rem, 5.4vw, 4.6rem); line-height: .98; letter-spacing: var(--tracking-display); }
.os .wall-lead { margin: 0; color: var(--muted); font-size: 1rem; }

/* Iconos del escritorio: os.js los coloca en una cuadricula y se pueden arrastrar. */
.os .icons { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.icon {
  position: absolute; pointer-events: auto; touch-action: none; user-select: none;
  display: grid; justify-items: center; align-content: start; gap: .4rem;
  width: 92px; padding: .45rem .2rem;
  background: none; border: 0; border-radius: var(--radius-card);
  font-size: .78rem; line-height: 1.2; text-align: center;
  transition: left .2s var(--ease), top .2s var(--ease);
}
.icon:focus-visible { outline: 0; }
.icon.drag { transition: none; z-index: 5; opacity: .8; cursor: grabbing; }
.icon-name { padding: .05rem .4rem; border-radius: var(--radius-tag); transition: color .2s var(--ease); }
.tile {
  display: grid; place-items: center;
  width: 50px; height: 50px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
  color: var(--accent);
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.tile svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon:hover .tile, .icon:focus-visible .tile, .icon.drag .tile { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon:hover .icon-name, .icon:focus-visible .icon-name { color: var(--accent); }

/* Dock */
.os .dock {
  position: fixed; z-index: 700;
  left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: .4rem; padding: .4rem;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-sheet);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .3);
}
.dock button { position: relative; padding: 0; background: none; border: 0; border-radius: var(--radius-panel); }
.dock .tile { width: 44px; height: 44px; background: var(--bg); }
.dock button:hover .tile { transform: translateY(-3px); border-color: var(--accent); }
.dock .dock-start .tile { background: var(--accent); border-color: var(--accent); color: var(--button-ink); }
.dock .dock-start svg { width: 30px; height: auto; stroke-width: 9; }
.dock .dock-start circle { fill: currentColor; stroke: none; }
.dock-sep { width: 1px; margin: 4px 2px; background: var(--line); }
.dock button.open::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 12px; height: 2px; margin-left: -6px; background: var(--accent); }
.dock button[data-tip]:hover::before {
  content: attr(data-tip);
  position: absolute; bottom: 56px; left: 50%; transform: translateX(-50%);
  padding: .2rem .5rem; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control);
  font-size: .72rem; color: var(--ink);
}

/* Ventanas */
.win {
  position: absolute; z-index: 10;
  display: flex; flex-direction: column;
  min-width: 300px; min-height: 200px;
  max-width: 100%; max-height: 100%;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .45);
  overflow: hidden; resize: both;
  animation: win-in .26s var(--ease);
}
.win.focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: 0 30px 90px rgba(0, 0, 0, .5), 0 0 0 1px var(--accent-soft); }
.win.max, .win[data-snap] { border-radius: 0; resize: none; }
.win[hidden] { display: none; }
@keyframes win-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.win-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: .6rem;
  height: 36px; padding: 0 .35rem 0 .8rem;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  cursor: grab; user-select: none; touch-action: none;
}
.win-bar:active { cursor: grabbing; }
.win-title { flex: 1; font-family: var(--font-mono); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win.focus .win-title { color: var(--ink); }
.win.focus .win-title::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: .5rem; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.win-ctl { display: flex; gap: 2px; }
.win-ctl button {
  display: grid; place-items: center;
  width: 30px; height: 26px;
  background: none; border: 0; border-radius: var(--radius-control);
  color: var(--subtle); font-size: .95rem; line-height: 1;
}
.win-ctl button:hover { background: var(--accent-soft); color: var(--ink); }
.win-ctl .x:hover { background: var(--danger); color: #1d1020; }
.win-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.os .app { padding: 1.3rem 1.4rem 1.5rem; }

/* Terminal: la linea de entrada va justo debajo de la salida y baja con ella. */
.win-body:has(> .terminal) { background: var(--bg); }
.os .app.terminal { min-height: 100%; padding: .8rem 1rem; background: var(--bg); font-family: var(--font-mono); font-size: .8rem; line-height: 1.55; cursor: text; }
.term-out { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); }
.term-out .cmd { color: var(--ink); }
.term-out .cmd::before { content: "marc@marcos:~$ "; color: var(--accent); }
.term-out b { color: var(--accent); font-weight: 400; }
.term-out .neo { margin: .5rem 0; line-height: 1.22; }
.term-out .neo i { font-style: normal; color: var(--ink); }
.term-out .sw { display: inline-block; width: 1.5em; height: .95em; vertical-align: middle; }
.term-line { display: flex; gap: .5rem; }
.term-line label { color: var(--accent); white-space: nowrap; }
.term-line input { flex: 1; min-width: 0; padding: 0; background: none; border: 0; outline: 0; color: var(--ink); font: inherit; caret-color: var(--accent); }

/* Juegos */
.file-glyph { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface); color: var(--accent); font-size: 1.4rem; line-height: 1; }
.game-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; margin-bottom: .8rem; }
.game-top .btn { margin-left: auto; background: none; }
.score { margin: 0 !important; font-family: var(--font-mono); font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--subtle) !important; }
.score b { margin-left: .3rem; font-size: 1rem; color: var(--ink); font-weight: 600; }
.game-help { margin: .8rem 0 0 !important; font-size: .8rem; color: var(--subtle) !important; }
.snake-stage { position: relative; max-width: 400px; margin: 0 auto; }
.lives { display: inline-flex; gap: .2em; vertical-align: -.1em; color: var(--accent) !important; }
.lives .heart { width: .9em; height: .9em; fill: currentColor; }
.snake-stage canvas { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius-card); touch-action: none; }
.snake-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  margin: 0 !important; padding: .45rem .8rem; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control);
  font-family: var(--font-mono); font-size: .74rem; color: var(--ink) !important;
}
.pad { display: none; grid-template: "a up b" 44px "left down right" 44px / 52px 52px 52px; gap: 6px; justify-content: center; margin-top: .9rem; }
.pad button { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--accent); font-size: .8rem; }
.pad button:active { background: var(--accent-soft); border-color: var(--accent); }
.pad [data-dir="up"] { grid-area: up; } .pad [data-dir="left"] { grid-area: left; }
.pad [data-dir="down"] { grid-area: down; } .pad [data-dir="right"] { grid-area: right; }
@media (hover: none), (max-width: 640px) { .pad { display: grid; } .bpad { display: flex; } }
.pairs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; max-width: 400px; margin: 0 auto; }
.card {
  aspect-ratio: 1; padding: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-card);
  transition: border-color .2s var(--ease), background .2s var(--ease), transform .2s var(--ease);
}
.card:hover { border-color: var(--accent); }
.card::before { content: "M."; font-weight: 700; letter-spacing: -.05em; color: var(--line); font-size: 1.1rem; }
.card-face { display: none; width: 46%; height: 46%; margin: auto; background: var(--ink); mask: var(--symbol) center / contain no-repeat; -webkit-mask: var(--symbol) center / contain no-repeat; }
.card.up { background: var(--surface-hover); border-color: var(--accent); }
.card.up::before { content: none; }
.card.up .card-face { display: block; }
.card.ok { border-color: var(--ok); }
.card.ok .card-face { background: var(--ok); }

/* Navegador */
.os .app.browser { display: flex; flex-direction: column; height: 100%; padding: 0; }
.browser-bar { display: flex; align-items: center; gap: .5rem; padding: .4rem .7rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.browser-bar .url { flex: 1; padding: .2rem .6rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-control); font-family: var(--font-mono); font-size: .72rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browser-bar a { text-decoration: none; padding: 0 .3rem; }
.browser iframe { flex: 1; width: 100%; min-height: 0; border: 0; background: var(--bg); }

/* Arranque */
.boot {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-content: center; justify-items: center; gap: 1.1rem;
  background: #0a080d; color: #f0eaf3;
  transition: opacity .9s var(--ease), visibility .9s;
}
.boot.done { opacity: 0; visibility: hidden; }
/* Al saltar el arranque se quita la galaxia: el botón antiguo no debe asomar mientras la pantalla se desvanece. */
.boot.done .boot-power, .boot.done .boot-hint { visibility: hidden; animation: none; }
/* Antes de que cargue os.js: la pantalla ya tapa el escritorio, sin enseñar aún el botón. */
html.booting .boot[hidden] { display: grid; }
@media (prefers-reduced-motion: no-preference) {
  html.booting .boot:not(.cosmos):not(.running) > * { visibility: hidden; }
}
.boot-power {
  display: grid; justify-items: center; gap: .9rem;
  width: 168px; height: 168px; padding-top: 44px;
  background: #130f18; border: 1px solid #352d3d; border-radius: 50%;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: var(--tracking-label); text-transform: uppercase; color: #b6aabd;
  animation: pulse 2.4s ease-in-out infinite;
  transition: transform .25s var(--ease), border-color .25s var(--ease);
}
.boot-power svg { width: 78px; color: #f0eaf3; }
.boot-power:hover { transform: scale(1.04); border-color: #e896d6; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(232, 150, 214, .32); } 50% { box-shadow: 0 0 0 22px rgba(232, 150, 214, 0); } }
.boot-hint { margin: 0; color: #8d8095; font-size: .86rem; }
.boot-log { display: none; margin: 0; min-width: min(30rem, 86vw); min-height: 11.5em; font-family: var(--font-mono); font-size: .8rem; line-height: 1.65; color: #b6aabd; white-space: pre-wrap; }
.boot-log b { color: #8fd6b0; font-weight: 400; }
.boot-log i { color: #e896d6; font-style: normal; }
.boot.running .boot-power, .boot.running .boot-hint { display: none; }
.boot.running .boot-log { display: block; }
.boot-skip { position: absolute; right: 1.2rem; bottom: 1.1rem; background: none; border: 0; color: #8d8095; font-size: .8rem; }
.boot-skip:hover { color: #e896d6; }
/* Universo de arranque: escena viva que colapsa al tocarla, explota y se digitaliza hasta el logo. */
.boot-cosmos { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
.boot-hint-cosmos { display: none; }
.boot.cosmos { cursor: pointer; }
/* La galaxia se prepara a oscuras y solo se enciende (.lit) cuando ya va fluida; luego aparece despacio. */
.boot.cosmos .boot-cosmos { display: block; opacity: 0; transform: scale(1.06); transition: opacity 3.2s ease-in-out, transform 5s var(--ease); }
.boot.cosmos.lit .boot-cosmos { opacity: 1; transform: none; }
.boot.cosmos .boot-hint { display: none; }
/* El botón sigue ahí para el teclado (Enter o Espacio), pero no se ve ni tapa los clics. */
.boot.cosmos .boot-power { position: absolute; opacity: 0; pointer-events: none; animation: none; }
.boot.cosmos .boot-hint-cosmos {
  display: block; position: absolute; left: 0; right: 0; bottom: 9%; z-index: 1; pointer-events: none;
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: var(--tracking-label); text-transform: uppercase; text-align: center; color: #cbbfd2; text-shadow: 0 0 12px #0a080d, 0 0 4px #0a080d;
  opacity: 0; transition: opacity .3s;
}
/* El aviso aparece con la galaxia y se queda (respirando suave, sin apagarse) hasta que se toca. */
.boot.cosmos.lit:not(.collapsing) .boot-hint-cosmos { animation: hint-in 1.2s .8s both, hint-breathe 2.8s ease-in-out 2s infinite; }
.boot.collapsing { cursor: default; }
.boot.collapsing .boot-hint-cosmos { animation: none; opacity: 0; }
@keyframes hint-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }
@keyframes hint-in { from { opacity: 0; } to { opacity: 1; } }
.boot.cosmos .boot-skip { opacity: 0; transition: opacity 1.4s; }
.boot.cosmos.lit .boot-skip { opacity: 1; transition-delay: .8s; }
.boot-skip { z-index: 1; }

/* ---------- Ventana estrecha: lanzador y ventanas a pantalla completa ----------
   Los telefonos no llegan aqui: index.html los manda a movil.html. */
@media (max-width: 640px) {
  .mb-name, .mb-active { display: none; }
  .os .desktop {
    overflow-y: auto;
    background: radial-gradient(520px 360px at 92% -6%, var(--glow), transparent 65%), var(--bg);
  }
  .os .wall { position: relative; inset: auto; background: none; }
  .os .wall::after, .os .wall-mark { display: none; }
  .os .wall-copy { position: relative; left: auto; bottom: auto; padding: 2.2rem 1.25rem 0; max-width: none; }
  .os .icons {
    position: relative; inset: auto;
    grid-auto-flow: row; grid-template-rows: none; grid-template-columns: repeat(3, 1fr);
    gap: .6rem; padding: 1.6rem 1rem 2rem;
  }
  .os .icons { pointer-events: auto; display: grid; }
  .icon { position: static; touch-action: auto; width: auto; padding: .8rem .2rem; font-size: .8rem; background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--line); }
  .start, .start.from-top { left: .5rem; right: .5rem; top: 44px; bottom: auto; width: auto; transform: none; max-height: calc(100vh - 60px); }
  .mb-date, .st-pct { display: none; }
  .quick { width: min(290px, calc(100vw - 16px)); }
  .os .dock { display: none; }
  .win {
    position: fixed; inset: 38px 0 0 0 !important;
    width: auto !important; height: auto !important;
    min-width: 0; border: 0; border-radius: 0; resize: none; z-index: 600;
  }
  .win-bar { height: 44px; cursor: default; }
  .win-ctl .min, .win-ctl .mx { display: none; }
  .win-ctl .x { width: 44px; height: 36px; font-size: 1.2rem; }
  .os .app { padding: 1.2rem 1.15rem 2rem; }
  .cards, .facts { grid-template-columns: 1fr; }
  .shots img { height: 300px; }
  .term-line input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Temas ----------
   rosa y claro son los de marca (marca/tokens.css). El resto cambia los mismos tokens;
   data-theme sigue valiendo dark o light para las paginas de proyecto. */
:root[data-skin="oceano"] {
  --bg: #0a1017; --surface: #101924; --surface-hover: #16222f; --ink: #e6eff7; --muted: #a3b4c4; --subtle: #7d8fa1; --line: #23374a;
  --accent: #6cc7f5; --accent-hover: #9bdbfb; --accent-soft: rgba(108, 199, 245, .11); --glow: rgba(108, 199, 245, .26); --button-ink: #06202e;
}
:root[data-skin="bosque"] {
  --bg: #0c120e; --surface: #121b15; --surface-hover: #19251d; --ink: #e8f1ea; --muted: #a6b8ab; --subtle: #7c9083; --line: #283a2f;
  --accent: #7fdc9f; --accent-hover: #a5ecbc; --accent-soft: rgba(127, 220, 159, .1); --glow: rgba(127, 220, 159, .22); --button-ink: #082313;
}
:root[data-skin="ambar"] {
  --bg: #110d07; --surface: #19130a; --surface-hover: #221a0e; --ink: #f6e7c8; --muted: #c6b089; --subtle: #9a8764; --line: #392d17;
  --accent: #ffb347; --accent-hover: #ffc875; --accent-soft: rgba(255, 179, 71, .1); --glow: rgba(255, 179, 71, .22); --button-ink: #2a1800;
}
:root[data-skin="papel"] {
  --bg: #f5f0e6; --surface: #fffdf8; --surface-hover: #f4eddf; --ink: #2b2620; --muted: #645b4e; --subtle: #7c7263; --line: #e0d6c3;
  --accent: #b4532a; --accent-hover: #94401d; --accent-soft: rgba(180, 83, 42, .08); --glow: rgba(180, 83, 42, .16); --button-ink: #ffffff;
}

/* Logos de proyecto: todos sobre la misma ficha, igual en cualquier tema.
   Los de app van sobre el fondo oscuro de marca; el del club, sobre claro (como en styles.css). */
.file img, .p-head img, .start-grid .tile img {
  background: #110f16; border: 1px solid var(--line); border-radius: var(--radius-card); object-fit: contain;
}
.file img[src*="nou-padel"], .p-head img[src*="nou-padel"], .start-grid .tile img[src*="nou-padel"] { background: #faf7fb; padding: 3px; }
.start-grid .tile:has(img) { padding: 0; overflow: hidden; border: 0; background: none; }
.start-grid .tile img { width: 100%; height: 100%; }
.file { min-width: 0; }
.file strong { max-width: 100%; overflow-wrap: anywhere; }

/* ---------- Fondos de escritorio (os.js los aplica a .wall y a sus miniaturas .wp) ---------- */
.wall-cuadricula {
  background:
    radial-gradient(900px 520px at 88% -8%, var(--glow), transparent 62%),
    radial-gradient(700px 480px at -6% 108%, var(--accent-soft), transparent 60%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 56px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 56px 100%,
    var(--bg);
}
.wall-aurora {
  background:
    radial-gradient(60% 55% at 78% 18%, var(--glow), transparent 70%),
    radial-gradient(45% 50% at 22% 82%, var(--accent-soft), transparent 70%),
    radial-gradient(40% 40% at 55% 60%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--bg);
  background-size: 140% 140%, 130% 130%, 160% 160%, auto;
  animation: aurora 26s ease-in-out infinite alternate;
}
.wp.wall-aurora { animation: none; }
@keyframes aurora {
  from { background-position: 0% 0%, 100% 100%, 50% 50%, 0 0; }
  to { background-position: 100% 40%, 0% 60%, 20% 80%, 0 0; }
}
.wall-puntos {
  background:
    radial-gradient(800px 480px at 85% 0%, var(--glow), transparent 60%),
    radial-gradient(circle, color-mix(in srgb, var(--subtle) 55%, transparent) 1px, transparent 1.6px) 0 0 / 22px 22px,
    var(--bg);
}
.wall-diagonal {
  background:
    radial-gradient(800px 480px at 10% 0%, var(--accent-soft), transparent 60%),
    repeating-linear-gradient(135deg, var(--line) 0 1px, transparent 1px 26px),
    var(--bg);
}
.wall-horizonte {
  background:
    radial-gradient(70% 40% at 50% 100%, var(--glow), transparent 70%),
    linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 35%, transparent) 62.2%, transparent 62.6%),
    linear-gradient(var(--bg) 0%, color-mix(in srgb, var(--surface) 80%, var(--bg)) 100%);
}
.wall-liso { background: radial-gradient(1000px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg); }
.quick-sub { margin-top: .8rem !important; }
.walls i.wp { height: 34px; background-color: var(--bg); }

@media (prefers-reduced-motion: reduce) { .wall-aurora { animation: none; } }

/* ---------- Detalles de escritorio ---------- */
/* Sombra de la ventana activa con el color del tema. */
.win.focus {
  box-shadow: 0 34px 90px -24px var(--glow), 0 22px 60px rgba(0, 0, 0, .38), 0 0 0 1px var(--accent-soft);
}

/* Ventanas encajadas a media pantalla y la guía que aparece al arrastrar. */
.win.glide { transition: left .3s var(--ease), top .3s var(--ease), width .3s var(--ease), height .3s var(--ease), border-radius .3s var(--ease); }
.snap-ghost {
  position: absolute; z-index: 9; pointer-events: none;
  border: 1px solid var(--accent); border-radius: var(--radius-panel);
  background: var(--accent-soft);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: left .22s var(--ease), top .22s var(--ease), width .22s var(--ease), height .22s var(--ease), opacity .18s var(--ease);
}
.snap-ghost.on { opacity: 1; }
.snap-ghost.instant { transition: none; }

/* Calendario del panel rápido. */
.cal { margin-bottom: .9rem; padding-bottom: .8rem; border-bottom: 1px solid var(--line); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .45rem; }
.cal-head strong { font-size: .86rem; text-transform: capitalize; }
.cal-head button { width: 26px; height: 24px; background: none; border: 1px solid transparent; border-radius: var(--radius-control); color: var(--muted); }
.cal-head button:hover { border-color: var(--line); color: var(--accent); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: .74rem; }
.cal-wd { padding: .15rem 0; font-family: var(--font-mono); font-size: .6rem; color: var(--subtle); }
.cal-day { padding: .22rem 0; border-radius: var(--radius-control); color: var(--muted); }
.cal-day.today { background: var(--accent); color: var(--button-ink); font-weight: 600; }
.skins:not(.walls) { grid-template-columns: repeat(4, 1fr); }
.skins:not(.walls) button { font-size: .7rem; }

/* Menú del clic derecho. */
.ctx {
  position: fixed; z-index: 900; min-width: 200px; padding: .3rem;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--line); border-radius: var(--radius-panel);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
  animation: ctx-in .12s var(--ease);
}
@keyframes ctx-in { from { opacity: 0; transform: scale(.97); } }
.ctx button { display: block; width: 100%; padding: .42rem .7rem; text-align: left; background: none; border: 0; border-radius: var(--radius-control); font-size: .82rem; }
.ctx button:hover, .ctx button:focus-visible { background: var(--accent); color: var(--button-ink); outline: 0; }
.ctx hr { margin: .25rem .4rem; border: 0; border-top: 1px solid var(--line); }

/* Selección de iconos. */
.lasso { position: absolute; z-index: 3; pointer-events: none; border: 1px solid var(--accent); background: var(--accent-soft); border-radius: 2px; }
.icon.sel .tile { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface)); }
.icon.sel .icon-name { background: var(--accent); color: var(--button-ink); }

/* Salvapantallas: el logo rebota despacio y el reloj queda abajo. */
.saver { position: fixed; inset: 0; z-index: 1100; background: #08060b; opacity: 0; transition: opacity .8s var(--ease); cursor: none; overflow: hidden; }
.saver.on { opacity: 1; }
.saver-x { position: absolute; inset: 0; animation: saver-x 17s linear infinite alternate; }
.saver-y { position: absolute; left: 0; top: 0; animation: saver-y 11s linear infinite alternate; color: #f0eaf3; }
.saver-y svg { display: block; width: 200px; filter: drop-shadow(0 0 24px var(--glow)); }
.saver-y circle { fill: var(--accent); }
@keyframes saver-x { from { transform: translateX(4vw); } to { transform: translateX(calc(96vw - 200px)); } }
@keyframes saver-y { from { transform: translateY(5vh); } to { transform: translateY(calc(82vh - 110px)); } }
.saver-clock { position: absolute; left: 0; right: 0; bottom: 6vh; margin: 0; text-align: center; font-family: var(--font-mono); font-size: clamp(2rem, 6vw, 4rem); letter-spacing: .08em; color: #8d8095; }

/* ---------- Bloques ---------- */
.blocks-stage { display: flex; justify-content: center; align-items: flex-start; gap: 1rem; }
.blocks-board { flex: 0 1 240px; margin: 0; }
.blocks-side { display: grid; justify-items: center; gap: .4rem; }
.blocks-side canvas { width: 96px; height: 96px; border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--bg); }
.bpad { display: none; justify-content: center; gap: 6px; margin-top: .9rem; }
.bpad button { width: 52px; height: 44px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--accent); }
.bpad button:active { background: var(--accent-soft); border-color: var(--accent); }

/* ---------- Buscaminas ---------- */
.mines { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; max-width: 360px; margin: 0 auto; user-select: none; }
.mines button {
  aspect-ratio: 1; padding: 0;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid var(--line); border-radius: var(--radius-control);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--ink) 10%, transparent);
  font-family: var(--font-mono); font-size: .95rem; font-weight: 700; line-height: 1;
  transition: background .12s var(--ease), border-color .12s var(--ease);
}
.mines button:not(.open):hover { border-color: var(--accent); }
.mines button.open { background: transparent; border-color: color-mix(in srgb, var(--line) 45%, transparent); box-shadow: none; cursor: default; }
.mines button.flag { color: var(--accent); }
.mines button.boom { background: var(--danger); color: #1d1020; }
.mines button.mine { color: var(--danger); }
.mines [data-n="1"] { color: var(--accent); }
.mines [data-n="2"] { color: var(--ok); }
.mines [data-n="3"] { color: var(--danger); }
.mines [data-n="4"] { color: var(--warn); }
.mines [data-n="5"], .mines [data-n="6"], .mines [data-n="7"], .mines [data-n="8"] { color: var(--ink); }

/* ---------- Teclea código ---------- */
.typing-snippet {
  margin: 0 0 .7rem !important; padding: 1rem 1.1rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-card);
  font-family: var(--font-mono); font-size: .98rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--subtle) !important;
}
.typing-snippet .ok { color: var(--ink); }
.typing-snippet .bad { background: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--ink); border-radius: 2px; }
.typing-snippet .cur { box-shadow: inset 0 -2px 0 var(--accent); }
.typing-input {
  width: 100%; height: 42px; padding: 0 .8rem;
  background: var(--surface-hover); border: 1px solid var(--line); border-radius: var(--radius-control);
  font-family: var(--font-mono); font-size: 16px; color: var(--ink); outline: 0;
}
.typing-input:focus { border-color: var(--accent); }

/* ---------- Palabra clave ---------- */
.word-board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; max-width: 270px; margin: 0 auto; }
.word-board .tile {
  display: grid; place-items: center; aspect-ratio: 1;
  border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--bg);
  font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; color: var(--ink);
}
.word-board .tile.filled { border-color: var(--muted); }
.word-board .tile.reveal { animation: tile-flip .4s var(--ease) both; animation-delay: var(--delay, 0ms); }
.word-board .tile.ok { background: color-mix(in srgb, var(--ok) 32%, var(--bg)); border-color: var(--ok); }
.word-board .tile.near { background: color-mix(in srgb, var(--warn) 32%, var(--bg)); border-color: var(--warn); }
.word-board .tile.miss { background: color-mix(in srgb, var(--muted) 22%, var(--bg)); border-color: transparent; color: var(--subtle); }
.word-board .tile.shake { animation: tile-shake .3s var(--ease); }
@keyframes tile-flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
@keyframes tile-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.word-msg { min-height: 1.4em; text-align: center; }
.word-keys { display: grid; gap: 5px; max-width: 400px; margin: .2rem auto 0; user-select: none; }
.word-row { display: flex; justify-content: center; gap: 4px; }
.word-row button {
  flex: 1 1 0; max-width: 36px; height: 42px; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-control);
  font-family: var(--font-mono); font-size: .8rem; font-weight: 600; color: var(--ink);
}
.word-row button.wide { flex-grow: 1.6; max-width: 56px; color: var(--accent); }
.word-row button:hover { border-color: var(--accent); }
.word-row button[data-state="ok"] { background: color-mix(in srgb, var(--ok) 32%, var(--bg)); border-color: var(--ok); }
.word-row button[data-state="near"] { background: color-mix(in srgb, var(--warn) 32%, var(--bg)); border-color: var(--warn); }
.word-row button[data-state="miss"] { background: transparent; color: var(--subtle); opacity: .55; }

/* ---------- Cuatro en línea ---------- */
.c4 {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; max-width: 380px; margin: 0 auto; padding: 8px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid var(--line); border-radius: var(--radius-card);
  overflow: hidden; user-select: none;
}
.c4 button { aspect-ratio: 1; padding: 0; background: none; border: 0; border-radius: 50%; cursor: pointer; }
.c4 .disc { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--bg); box-shadow: inset 0 2px 4px color-mix(in srgb, #000 30%, transparent); }
.c4 button.hot .disc { background: color-mix(in srgb, var(--accent) 14%, var(--bg)); }
.c4 button.you .disc { background: var(--accent); box-shadow: inset 0 -3px 0 color-mix(in srgb, #000 22%, transparent); }
.c4 button.cpu .disc { background: var(--ink); box-shadow: inset 0 -3px 0 color-mix(in srgb, #000 22%, transparent); }
.c4 button.drop .disc { animation: c4-drop calc(.12s + var(--fall, 1) * .05s) cubic-bezier(.4, 0, 1, 1); }
.c4 button.win .disc { outline: 3px solid var(--ok); outline-offset: 2px; }
.c4.thinking { cursor: progress; }
@keyframes c4-drop { from { transform: translateY(calc(var(--fall, 1) * -110%)); } }
@media (prefers-reduced-motion: reduce) {
  .word-board .tile.reveal, .word-board .tile.shake, .c4 button.drop .disc { animation: none; }
}
