/* =============================================================================
   Terminal "hackeado" — estilos
   O calor da história é controlado por body[data-calor="0..5"].
   ========================================================================== */

/* Propriedades registradas para que as cores possam transicionar suavemente. */
@property --fg      { syntax: '<color>'; inherits: true; initial-value: #ffb000; }
@property --dim     { syntax: '<color>'; inherits: true; initial-value: #7d5410; }
@property --acento  { syntax: '<color>'; inherits: true; initial-value: #ffd27a; }
@property --rosa    { syntax: '<color>'; inherits: true; initial-value: #ffb000; }
@property --bg      { syntax: '<color>'; inherits: true; initial-value: #0a0603; }
@property --brilho  { syntax: '<color>'; inherits: true; initial-value: rgba(255, 176, 0, .42); }

:root {
  --altura: 100dvh;
  --topo: 0px;
  --gutter: 16px;
  --mono: 'Fragment Mono', ui-monospace, 'Cascadia Mono', 'SF Mono', Menlo, Consolas, monospace;
  --serif: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --erro: #ff6a4d;
  --ok: #c8ff8a;
}

/* ----- escala de calor ---------------------------------------------------- */
body {
  --fg: #ffb000; --dim: #7d5410; --acento: #ffd27a; --rosa: #ffb000;
  --bg: #0a0603; --brilho: rgba(255, 176, 0, .42);
  transition: --fg 3s ease, --dim 3s ease, --acento 3s ease, --rosa 3s ease,
              --bg 3s ease, --brilho 3s ease;
}
body[data-calor="1"] { --fg: #ffb33f; --dim: #80561a; --acento: #ffdaa3; --rosa: #ff9a8a; --bg: #0b0604; --brilho: rgba(255, 170, 60, .42); }
body[data-calor="2"] { --fg: #ffab6a; --dim: #86522f; --acento: #ffcfae; --rosa: #ff7f9e; --bg: #0d0507; --brilho: rgba(255, 150, 110, .42); }
body[data-calor="3"] { --fg: #ff9f94; --dim: #8a4652; --acento: #ffd3d9; --rosa: #ff5c8a; --bg: #110509; --brilho: rgba(255, 120, 140, .45); }
body[data-calor="4"] { --fg: #ff9fb8; --dim: #8b3b5a; --acento: #ffe1eb; --rosa: #ff3d77; --bg: #15040d; --brilho: rgba(255, 90, 150, .48); }
body[data-calor="5"] { --fg: #ffc3d5; --dim: #9a4567; --acento: #fff0f5; --rosa: #ff2d6b; --bg: #1c0512; --brilho: rgba(255, 70, 140, .5); }

/* ----- base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
}

body {
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 420px) { body { font-size: 15px; } }
@media (min-width: 900px) { body { font-size: 16px; } }

button { font: inherit; color: inherit; }
:focus-visible { outline: 1px dashed var(--acento); outline-offset: 3px; }
::selection { background: var(--fg); color: var(--bg); }

/* ----- moldura ------------------------------------------------------------- */
.crt {
  position: fixed;
  left: 0; right: 0; top: 0;
  height: var(--altura);
  transform: translateY(var(--topo));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
  isolation: isolate;
}

/* Brilho rosado que sobe do rodapé conforme a história esquenta. */
.calor-fundo {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 55% at 50% 115%, color-mix(in srgb, var(--rosa) 30%, transparent), transparent 70%),
    radial-gradient(90% 60% at 50% 40%, color-mix(in srgb, var(--fg) 5%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity 3s ease;
}
body[data-calor="2"] .calor-fundo { opacity: .35; }
body[data-calor="3"] .calor-fundo { opacity: .6; }
body[data-calor="4"] .calor-fundo { opacity: .85; }
body[data-calor="5"] .calor-fundo { opacity: 1; }

.scanlines {
  position: absolute; inset: 0; z-index: 20;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, .24) 2px 3px);
  animation: cintilar 5s steps(60) infinite;
}
.scanlines::after {
  content: '';
  position: absolute; left: 0; right: 0; top: -20%;
  height: 18%;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--fg) 6%, transparent), transparent);
  animation: varredura 9s linear infinite;
}
.vinheta {
  position: absolute; inset: 0; z-index: 21;
  pointer-events: none;
  background: radial-gradient(130% 100% at 50% 50%, transparent 55%, rgba(0, 0, 0, .6) 100%);
}

@keyframes cintilar { 0%, 100% { opacity: 1; } 50% { opacity: .86; } }
@keyframes varredura { to { transform: translateY(700%); } }

/* ----- barra superior ------------------------------------------------------ */
.barra {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 8px;
  border-bottom: 1px dashed color-mix(in srgb, var(--dim) 80%, transparent);
  font-size: 12px;
  color: var(--dim);
  letter-spacing: .02em;
}
.barra__sessao { display: inline-flex; align-items: center; gap: 8px; }
@media (max-width: 420px) { #sessao { display: none; } }
.barra__led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--fg);
  box-shadow: 0 0 8px var(--brilho);
  animation: piscar-led 2.4s ease-in-out infinite;
}
body[data-calor="4"] .barra__led,
body[data-calor="5"] .barra__led {
  background: var(--rosa);
  animation: batida 1.1s ease-in-out infinite;
}
.barra__status {
  flex: 1;
  min-width: 0;
  text-align: center;
  color: var(--fg);
  opacity: .8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.barra__som {
  background: none;
  border: 1px solid color-mix(in srgb, var(--dim) 80%, transparent);
  padding: 4px 10px;
  min-height: 30px;
  cursor: pointer;
  color: var(--dim);
  font-size: 12px;
}
.barra__som[aria-pressed="true"] { color: var(--bg); background: var(--fg); border-color: var(--fg); }

@keyframes piscar-led { 50% { opacity: .35; } }
@keyframes batida {
  0%, 100% { transform: scale(1); }
  15% { transform: scale(1.5); }
  30% { transform: scale(1); }
  45% { transform: scale(1.35); }
}

/* ----- saída do terminal --------------------------------------------------- */
.saida {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px var(--gutter) 18px;
  text-shadow: 0 0 6px var(--brilho);
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
  -webkit-overflow-scrolling: touch;
}

.linha {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 1.6em;
  max-width: 72ch;
}
.linha.sis::before   { content: '> '; color: var(--dim); }
.linha.dim           { color: var(--dim); }
.linha.aviso         { color: var(--acento); }
.linha.rosa          { color: var(--rosa); }
.linha.erro          { color: var(--erro); }
.linha.sucesso       { color: var(--ok); }
body[data-calor="4"] .linha.sucesso,
body[data-calor="5"] .linha.sucesso { color: var(--acento); }
.linha.proximo       { color: var(--dim); margin-top: 6px; }
.linha.proximo::before { content: '› '; color: var(--rosa); }
.linha.arte          { white-space: pre; line-height: 1.15; overflow-x: auto; margin: 6px 0; }
.linha.separador     { color: var(--dim); white-space: nowrap; overflow: hidden; }

.linha.cmd { color: var(--acento); margin-top: 12px; }
.linha.cmd .cmd__prompt { color: var(--dim); }

.linha.digitando::after,
.linha.esperando::after {
  content: '';
  display: inline-block;
  width: .6em; height: 1.05em;
  margin-left: 1px;
  vertical-align: -.18em;
  background: var(--fg);
  box-shadow: 0 0 6px var(--brilho);
  animation: cursor 1s steps(1) infinite;
}
@keyframes cursor { 50% { opacity: 0; } }

/* Tabela de ajuda e lista de arquivos */
.tabela { display: grid; grid-template-columns: max-content 1fr; column-gap: 2ch; margin: 4px 0 4px 2ch; }
.tabela dt { color: var(--acento); }
.tabela dd { margin: 0; color: var(--dim); }
@media (max-width: 380px) {
  .tabela { grid-template-columns: 1fr; }
  .tabela dd { margin-bottom: 6px; padding-left: 2ch; }
}

.arquivos { list-style: none; margin: 4px 0; padding: 0 0 0 1ch; }
.arquivos li { display: flex; gap: 1ch; align-items: baseline; }
.arquivos .marca { color: var(--dim); flex: none; }
.arquivos li.lido .marca { color: var(--rosa); }
.arquivos li.bloqueado { color: var(--dim); }
.arquivos .nota { color: var(--dim); font-size: .85em; white-space: nowrap; }

.arquivo {
  background: none; border: 0; padding: 5px 0; margin: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
  text-shadow: inherit;
  text-decoration: underline dotted color-mix(in srgb, var(--dim) 90%, transparent);
  text-underline-offset: 4px;
  overflow-wrap: anywhere;
}
.arquivo:hover { color: var(--acento); }
.arquivo:disabled { cursor: default; text-decoration: none; }

/* ----- fotos que "carregam" ----------------------------------------------- */
.foto { margin: 10px 0 12px; width: min(100%, 360px); }
.foto__quadro { position: relative; border: 1px solid color-mix(in srgb, var(--dim) 80%, transparent); padding: 6px; }
.foto__ascii {
  margin: 0;
  white-space: pre;
  line-height: 1;
  letter-spacing: 0;
  overflow: hidden;
  color: var(--fg);
}
.foto canvas, .foto img { display: block; width: 100%; height: auto; }
.foto canvas { image-rendering: pixelated; }
.foto img { animation: revelar .9s ease forwards; }
.foto figcaption { color: var(--dim); font-size: .85em; margin-top: 6px; }
@keyframes revelar { from { opacity: 0; filter: brightness(2) contrast(.6); } to { opacity: 1; filter: none; } }

/* ----- entrada ------------------------------------------------------------- */
.entrada {
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  border-top: 1px dashed color-mix(in srgb, var(--dim) 80%, transparent);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  text-shadow: 0 0 6px var(--brilho);
}

.prompt { display: flex; align-items: center; gap: 1ch; font-size: 16px; }
.prompt__rotulo { color: var(--rosa); white-space: nowrap; flex: none; }
body[data-calor="0"] .prompt__rotulo { color: var(--acento); }

.campo { position: relative; flex: 1; min-width: 0; height: 2em; display: flex; align-items: center; }
.campo__espelho {
  width: 100%;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
}
.campo__input {
  position: absolute; inset: 0;
  width: 100%;
  border: 0; outline: 0; margin: 0; padding: 0;
  background: transparent;
  font: inherit;
  font-size: 16px; /* evita zoom automático no iPhone */
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
}
.cursor {
  background: var(--fg);
  color: var(--bg);
  box-shadow: 0 0 6px var(--brilho);
  text-shadow: none;
  animation: cursor 1s steps(1) infinite;
}
.campo--ocupado .cursor { animation: none; opacity: .35; }
.campo__dica { color: var(--dim); padding-left: 1ch; }

.prompt__enviar {
  flex: none;
  background: none;
  border: 1px solid color-mix(in srgb, var(--dim) 80%, transparent);
  color: var(--fg);
  width: 40px; height: 36px;
  cursor: pointer;
}
.prompt__enviar:active { background: var(--fg); color: var(--bg); }

.chips {
  display: flex;
  gap: 8px;
  margin: 10px calc(var(--gutter) * -1) 0;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 38px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  background: none;
  border: 1px solid var(--dim);
  color: var(--fg);
  font-size: 13px;
  padding: 0 12px;
  min-height: 38px;
  cursor: pointer;
  white-space: nowrap;
  animation: surgir .4s ease both;
}
.chip::before { content: '$ '; color: var(--dim); }
.chip:hover, .chip:active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip:hover::before, .chip:active::before { color: var(--bg); }
.chip--principal { border-color: var(--rosa); color: var(--rosa); }
.chip:disabled { opacity: .35; pointer-events: none; }
@keyframes surgir { from { opacity: 0; } }

/* ----- corações no fundo --------------------------------------------------- */
.coracoes-fundo { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.coracoes-fundo span {
  position: absolute;
  bottom: -2em;
  color: var(--rosa);
  opacity: 0;
  animation: subir linear infinite;
  text-shadow: 0 0 8px var(--brilho);
}
@keyframes subir {
  0%   { transform: translateY(0); opacity: 0; }
  12%  { opacity: var(--op, .14); }
  85%  { opacity: var(--op, .14); }
  100% { transform: translateY(calc(-1 * var(--altura) - 4em)); opacity: 0; }
}
.barra, .saida, .entrada { position: relative; z-index: 1; }

/* ----- glitch -------------------------------------------------------------- */
.crt.glitch .saida { animation: glitch .2s steps(2) 1; }
.crt.glitch-forte .saida,
.crt.glitch-forte .barra { animation: glitch .16s steps(2) 5; }
.crt.glitch-forte .scanlines { background: repeating-linear-gradient(to bottom, transparent 0 1px, rgba(0, 0, 0, .5) 1px 3px); }

@keyframes glitch {
  0%   { transform: translate(0); text-shadow: 2px 0 var(--rosa), -2px 0 #52d6ff; }
  33%  { transform: translate(-3px, 1px) skewX(-3deg); clip-path: inset(8% 0 40% 0); }
  66%  { transform: translate(2px, -1px); clip-path: inset(50% 0 6% 0); text-shadow: -3px 0 var(--rosa), 3px 0 #52d6ff; }
  100% { transform: none; clip-path: none; }
}

/* ----- tela final ---------------------------------------------------------- */
.final {
  position: fixed; inset: 0; z-index: 50;
  background:
    radial-gradient(80% 60% at 50% 0%, #4a0f2a 0%, transparent 70%),
    radial-gradient(100% 70% at 50% 110%, #5c0d2c 0%, transparent 65%),
    #1a0410;
  color: #ffe8ef;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.final[hidden] { display: none; }
.final.visivel { opacity: 1; }
.final__particulas { position: absolute; inset: 0; width: 100%; height: 100%; }
.final__rolagem {
  position: absolute; inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(48px + env(safe-area-inset-top)) var(--gutter) calc(56px + env(safe-area-inset-bottom));
}
.final__carta { max-width: 34rem; margin: 0 auto; }
.final__arte {
  font-family: var(--mono);
  color: #ff6b98;
  text-shadow: 0 0 10px rgba(255, 70, 140, .6);
  font-size: 14px;
  line-height: 1.15;
  margin: 0 0 28px;
}
.final__titulo {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -.01em;
  margin: 0 0 1.4rem;
  color: #fff3f6;
}
.final__texto p {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.3rem;
  line-height: 1.6;
  margin: 0 0 1.1em;
  color: #ffe1ea;
  opacity: 0;
  filter: blur(3px);
  transition: opacity 1.4s ease, filter 1.4s ease;
}
.final__texto p.vis { opacity: 1; filter: none; }
.final__assinatura {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.35;
  white-space: pre-line;
  text-align: right;
  margin: 2rem 0 0;
  color: #ffb3c9;
  opacity: 0;
  transition: opacity 1.6s ease;
}
.final__assinatura.vis { opacity: 1; }
.final__acoes {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-top: 2.6rem;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.final__acoes.vis { opacity: 1; }
.final__botao {
  font-family: var(--mono);
  font-size: 13px;
  background: #ff3d77;
  color: #1a0410;
  border: 0;
  padding: 12px 16px;
  min-height: 44px;
  cursor: pointer;
}
.final__botao[aria-pressed="true"] { background: #ffe1ea; }
.final__botao--discreto { background: none; color: #ffb3c9; border: 1px solid rgba(255, 179, 201, .4); }

/* ----- movimento reduzido -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .scanlines, .scanlines::after, .barra__led, .coracoes-fundo span, .chip { animation: none !important; }
  .crt.glitch .saida, .crt.glitch-forte .saida, .crt.glitch-forte .barra { animation: none; }
  .final__texto p { filter: none; }
}
