/* =========================================================
   CNT Sevilla · Portal de aplicaciones
   Lanzador de apps con la bandera rojinegra.
   Sin CDNs: la fuente Inter va en /fonts (SIL OFL 1.1).
   ========================================================= */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Variables ---------- */

:root {
  --red: #c8102e;
  --flag-black: #161616;

  --bg: #f6f4f1;
  --surface: #ffffff;
  --text: #161616;
  --muted: #625d56;
  --border: #e4dfd8;
  --accent: #b80d29;

  --ok: #1d7f45;
  --ko: #c8102e;
  --unknown: #a29b92;

  /* Icono de app: brillo + resplandor rojo suave */
  --icon-gloss: linear-gradient(180deg, rgb(255 255 255 / .14) 0%, rgb(255 255 255 / 0) 50%);
  --icon-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 7px 16px -9px rgb(200 16 46 / .32);
  --icon-shadow-hover: 0 2px 4px rgb(0 0 0 / .14), 0 12px 24px -10px rgb(200 16 46 / .5);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* Tamaños del lanzador (escritorio) */
  --tile-w: 108px;
  --icon-size: 76px;
  --icon-radius: 22px;
  --glyph: 36px;
  --name-size: 14px;
  --dot: 12px;
  --cols: 4;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --flag-black: #000000;

  --bg: #121212;
  --surface: #1c1c1c;
  --text: #f2f0ec;
  --muted: #a8a29a;
  --border: #2c2c2c;
  --accent: #ff4d66;

  --ok: #3fbf74;
  --ko: #ff4d66;
  --unknown: #6f6962;

  --icon-gloss: linear-gradient(180deg, rgb(255 255 255 / .16) 0%, rgb(255 255 255 / .04) 45%, rgb(255 255 255 / 0) 60%);
  --icon-shadow: 0 1px 3px rgb(0 0 0 / .5), 0 8px 18px -10px rgb(230 30 60 / .42);
  --icon-shadow-hover: 0 2px 4px rgb(0 0 0 / .5), 0 12px 24px -10px rgb(230 30 60 / .55);

  color-scheme: dark;
}

/* ---------- Base ---------- */

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--accent); }

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
  border-radius: 6px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Cabecera ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 32px;
  padding-top: max(20px, env(safe-area-inset-top));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand__flag {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background:
    var(--icon-gloss),
    linear-gradient(135deg, var(--red) 0 50%, var(--flag-black) 50% 100%);
  box-shadow: var(--icon-shadow);
}

.brand__name {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.theme-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color .15s ease;
}

.theme-btn:hover { border-color: var(--muted); }

.theme-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Contenido ---------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 56px 24px 64px;
}

.title {
  margin: 0 0 22px;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* ---------- Buscador ---------- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 560px;
  max-width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.search:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgb(200 16 46 / .14);
}

.search__icon {
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2.2;
  stroke-linecap: round;
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { cursor: pointer; }

.search__kbd {
  padding: 2px 7px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.search input:focus ~ .search__kbd,
.search input:not(:placeholder-shown) ~ .search__kbd { display: none; }

/* ---------- Lanzador de apps ---------- */

.apps {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tile-w));
  gap: 36px 40px;
  margin-top: 56px;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  border-radius: 12px;
  transition: transform .15s ease;
}

.app:hover { transform: translateY(-3px); }
.app:active { transform: translateY(0) scale(.97); }

.app__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--icon-size);
  height: var(--icon-size);
  color: #fff;
  border-radius: var(--icon-radius);
  background:
    var(--icon-gloss),
    linear-gradient(135deg, var(--red) 0 50%, var(--flag-black) 50% 100%);
  box-shadow: var(--icon-shadow);
  transition: box-shadow .2s ease;
}

.app:hover .app__icon,
.app:focus-visible .app__icon { box-shadow: var(--icon-shadow-hover); }

.app__icon svg {
  width: var(--glyph);
  height: var(--glyph);
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app__name {
  max-width: calc(100% + 12px);   /* puede asomar un poco sobre el hueco entre columnas */
  font-size: var(--name-size);
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
  letter-spacing: -0.01em;
  hyphens: auto;
  overflow-wrap: break-word;
}

/* Punto de estado en la esquina del icono */
.app__status {
  position: absolute;
  top: -3px;
  right: -3px;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--unknown);
  box-shadow: 0 0 0 3px var(--bg);
  transition: background .2s ease;
}

.app__status[data-state="up"] { background: var(--ok); }
.app__status[data-state="down"] { background: var(--ko); }
.app__status[data-state="checking"] { animation: pulse 1s ease-in-out infinite; }
.app__status[data-state="off"] { display: none; }

@keyframes pulse { 50% { opacity: .3; } }

/* App deshabilitada («próximamente») */
.app.is-disabled {
  pointer-events: none;
  opacity: .45;
  filter: grayscale(.6);
}

/* ---------- Avisos y pie ---------- */

.notice {
  margin: 48px 0 0;
  color: var(--muted);
  text-align: center;
}

.notice--error { color: var(--ko); }

.footer {
  padding: 20px 32px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* =========================================================
   Responsive
   ========================================================= */

/* Tablet / ventana estrecha: el lanzador se ajusta solo */
@media (max-width: 760px) {
  .apps {
    grid-template-columns: repeat(auto-fill, var(--tile-w));
    justify-content: center;
    width: 100%;
    max-width: 560px;
    gap: 32px 24px;
  }
}

/* Móvil: 3 columnas, iconos y textos grandes, alineado a la izquierda */
@media (max-width: 600px) {
  :root {
    --icon-size: 92px;
    --icon-radius: 27px;
    --glyph: 42px;
    --name-size: 16px;
    --dot: 14px;
  }

  .topbar { padding: 18px 20px; padding-top: max(18px, env(safe-area-inset-top)); }
  .brand__flag { width: 32px; height: 32px; border-radius: 9px; }
  .brand__name { font-size: 19px; }

  .main {
    align-items: stretch;
    padding: 12px 20px 32px;
  }

  .title { margin-bottom: 18px; font-size: 34px; }

  .search { width: 100%; height: 54px; }
  .search input { font-size: 17px; }   /* ≥16px: iOS no hace zoom al enfocar */
  .search__kbd { display: none; }

  .apps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-items: center;
    max-width: none;
    gap: 30px 12px;
    margin-top: 34px;
  }
}

/* Pantallas muy estrechas */
@media (max-width: 340px) {
  :root { --icon-size: 76px; --icon-radius: 22px; --glyph: 36px; --name-size: 14px; }
}

@media (hover: none) {
  .app:hover { transform: none; }
}

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