/* ==========================================================================
   Práctica de Cifrado - Estilos de la página de hashes
   ========================================================================== */

/* ---------- Fuentes (IBM Plex, licencia SIL OFL) ---------- */
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fuentes/plex-sans-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Sans";
  src: url("fuentes/plex-sans-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fuentes/plex-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fuentes/plex-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}

/* ---------- Variables ---------- */
:root {
  --papel: #f4f5f0;
  --superficie: #fff;
  --tinta: #17302a;
  --tinta-suave: #4b5f58;
  --linea: #c9d2cb;
  --hover: #e9ede7;
  --resalte: #ffe15a; /* color de marcador */
  --ok: #1d7a4e;
  --error: #b42318;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--tinta);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
p,
dl,
dd,
figure {
  margin: 0;
}

a {
  color: var(--tinta);
  text-underline-offset: 0.15em;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--tinta);
  outline-offset: 3px;
}

.pagina {
  max-width: 60rem;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 4.5rem) clamp(1.25rem, 4vw, 2.5rem) 2.5rem;
}

/* ---------- Cabecera ---------- */
.cabecera__curso {
  font-size: 0.9375rem;
  color: var(--tinta-suave);
}

.cabecera__titulo {
  margin-top: 0.5rem;
  font-size: clamp(2.25rem, 1.4rem + 3.2vw, 3.5rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.cabecera__texto {
  max-width: 58ch;
  margin-top: 1rem;
  font-size: 1.125rem;
  color: var(--tinta-suave);
}

/* ---------- Los tres botones ---------- */
.selector {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 2.5rem;
}

.selector__boton {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 5.25rem;
  padding: 1rem 1.125rem;
  border: 1.5px solid var(--tinta);
  border-radius: 10px;
  text-align: left;
  background: var(--superficie);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.selector__boton:hover {
  background: var(--hover);
}

.selector__nombre {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.2;
}

.selector__archivo {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--tinta-suave);
  overflow-wrap: anywhere;
}

.selector__boton[aria-pressed="true"] {
  color: #fff;
  background: var(--tinta);
  box-shadow: inset 0 5px 0 var(--resalte);
}

.selector__boton[aria-pressed="true"] .selector__archivo {
  color: rgba(255, 255, 255, 0.78);
}

.vacio {
  margin-top: 1.5rem;
  padding: 2.25rem 1.5rem;
  border: 1.5px dashed var(--linea);
  border-radius: 12px;
  text-align: center;
  color: var(--tinta-suave);
}

/* ---------- Resultado ---------- */
.resultado {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 2rem;
  margin-top: 1.5rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--linea);
  border-radius: 14px;
  background: var(--superficie);
}

.resultado[hidden] {
  display: none;
}

.resultado__nombre {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.15;
}

.resultado__detalle {
  margin-top: 0.25rem;
  color: var(--tinta-suave);
}

.resultado__origen {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--tinta-suave);
  overflow-wrap: anywhere;
}

.hashes {
  display: grid;
  gap: 1.25rem;
  margin-top: 1.75rem;
}

.hash__algoritmo {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-weight: 600;
}

.hash__bits {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--tinta-suave);
}

.hash__valor {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0.375rem;
}

/* Los grupos de 4 caracteres se separan con CSS, así al copiar no hay espacios */
.hash__codigo {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  column-gap: 0.6ch;
  min-width: 0;
  padding: 0.625rem 0.75rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.6;
  background: var(--papel);
  transition: background-color 0.4s ease;
}

.hash__codigo.recien-copiado {
  background: var(--resalte);
}

.copiar {
  flex: none;
  min-width: 7.25rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.875rem;
  border: 1.5px solid var(--tinta);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  background: transparent;
  cursor: pointer;
}

.copiar:hover {
  background: var(--hover);
}

/* ---------- Randomart del SHA-256 ---------- */
.arte {
  padding: 1.25rem 1.5rem 1.375rem;
  border-radius: 12px;
  color: #e8efe9;
  background: var(--tinta);
}

.arte__dibujo {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.0625rem;
  line-height: 1.22;
}

.arte__marca {
  font-weight: 500;
  color: var(--resalte);
}

.arte__pie {
  max-width: 17rem;
  margin-top: 0.875rem;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: rgba(232, 239, 233, 0.78);
}

/* ---------- Comprobar un archivo ---------- */
.comprobar {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--linea);
}

.comprobar__titulo {
  font-size: 1.25rem;
  font-weight: 600;
}

.comprobar__texto {
  max-width: 60ch;
  margin-top: 0.375rem;
  color: var(--tinta-suave);
}

.comprobar__boton {
  position: relative;
  display: inline-flex;
  margin-top: 1rem;
}

.comprobar__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.comprobar__boton span {
  padding: 0.625rem 1.125rem;
  border: 1.5px solid var(--tinta);
  border-radius: 8px;
  font-weight: 600;
  background: var(--superficie);
  cursor: pointer;
}

.comprobar__boton:hover span {
  background: var(--hover);
}

.comprobar__boton:focus-within span {
  outline: 3px solid var(--tinta);
  outline-offset: 3px;
}

.comprobar__resultado {
  margin-top: 1rem;
  overflow-wrap: anywhere;
}

.comprobar__resultado[data-estado="ok"] {
  font-weight: 600;
  color: var(--ok);
}

.comprobar__resultado[data-estado="error"] {
  font-weight: 600;
  color: var(--error);
}

.comprobar__hash {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--tinta-suave);
}

/* ---------- Pie ---------- */
.pie {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--linea);
  font-size: 0.8125rem;
  color: var(--tinta-suave);
}

/* ---------- Pantallas pequeñas ---------- */
@media (max-width: 48em) {
  .selector {
    grid-template-columns: 1fr;
  }

  .selector__boton {
    min-height: 0;
  }

  .resultado {
    grid-template-columns: 1fr;
  }

  .arte {
    justify-self: start;
  }
}

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