/*
 * Tracker UI — canonical shared styles. Hero-only rules live in hero.css.
 * ACTUALIZAR CIFRAS: cambiar datos, no formato, colores, tipografía ni estructura.
 * Status colors are defined ONCE below and read by app.js for canvas rendering.
 * Base rules are grouped by component; responsive overrides are ordered last.
 */

@font-face {
  font-family: Nunito;
  src: url("assets/Nunito-Variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
}

@font-face {
  font-family: Menu;
  src: url("assets/LilitaOne-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* Foundations, shared controls and accessibility */
:root {
  --line: #061427;
  --text: #fffef3;
  --exact: #67df47;
  --behavior: #ffd044;
  --pending: #275c96;
  --unmapped: #153c68;
  --font: Nunito, Arial, sans-serif;
  --menu: Menu, "Arial Black", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --ink-shadow:
    2px 2px 0 #071222, -1px -1px 0 #071222, 1px -1px 0 #071222,
    -1px 1px 0 #071222;
  --map-background: #0a284c;
  --map-filtered: #52677c;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 30px;
}

body {
  margin: 0;
  min-width: 0;
  background: linear-gradient(
      #4b90ee 0%,
      #9be4ff 35%,
      #3094cb 51%,
      #237eb5 100%
    )
    fixed;
  color: var(--text);
  font: 15px/1.5 var(--font);
}

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.wallpaper:before {
  content: "";
  position: absolute;
  inset: -10px;
  background: url("assets/wallpaper.png") center 43% / cover no-repeat;
  filter: blur(6px);
  opacity: 0.28;
}

.wallpaper:after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #548af61a, #9fe5ff55 45%, #1685b455 100%);
}

.shell {
  max-width: 1410px;
  margin: auto;
  padding: 0 44px;
}

a {
  color: inherit;
  text-underline-offset: 4px;
}

button,
input,
select {
  font: inherit;
}

button,
select,
summary {
  cursor: pointer;
}

button {
  border: 3px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: linear-gradient(#3879ba, #174b83);
  padding: 9px 16px;
  min-height: 44px;
  font: 18px/1.15 var(--menu);
  text-shadow: var(--ink-shadow);
  box-shadow:
    inset 0 2px 0 #80c2e3,
    inset 0 -3px 0 #082c57,
    0 2px 0 #061427;
  transition:
    transform 0.12s,
    box-shadow 0.12s;
}

button:hover {
  color: #ffda4f;
  background: linear-gradient(#508dd0, #225891);
  box-shadow:
    inset 0 0 0 2px #ffd340,
    0 2px 0 #061427;
}

button:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 3px #061427;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

button[hidden],
[hidden] {
  display: none !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
canvas:focus-visible {
  outline: 4px solid #ffdf46;
  outline-offset: 4px;
}

.skip {
  position: absolute;
  left: 20px;
  top: -100px;
  background: #103f73;
  padding: 14px;
  z-index: 20;
}

.skip:focus {
  top: 12px;
}

.text-button {
  font-size: 17px;
  min-height: 40px;
  padding: 8px 15px;
  text-decoration: none;
}

select {
  max-width: 100%;
  min-height: 44px;
  padding: 8px 36px 8px 12px;
  border: 3px solid #07172b;
  border-radius: 8px;
  background: #143e6c;
  color: #84eb75;
  box-shadow:
    0 0 0 3px #ffce36,
    inset 0 2px 0 #1e2a44;
  font: 16px var(--menu);
  text-shadow: 1px 2px #041328;
}

select option {
  background: #133f70;
  color: #fff;
}

dl {
  font-size: 13px;
}

dt {
  color: #ffdc55;
  font-weight: bold;
  margin-top: 14px;
}

dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}

dd.code {
  font: 10px/1.7 var(--mono);
}

input::placeholder {
  color: #c1d5ec;
}

.sprite { display: none; }

/* Section panels and headings */
h1,
h2,
h3,
.section-index {
  font-family: var(--menu);
  font-weight: 400;
  letter-spacing: 0;
  text-shadow: var(--ink-shadow);
}

h2 {
  color: #ffd33c;
  font-size: 32px;
  line-height: 1.1;
  margin: 0;
}

h3 {
  font-size: 23px;
  line-height: 1.25;
  margin: 0 0 14px;
  overflow-wrap: anywhere;
}

.section-index {
  font-size: 21px;
  margin: 0 0 16px;
  color: #ffd33c;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 0 20px;
}

.section-heading > h2 {
  margin: 0;
  padding: 0;
  background: none;
}

.sync {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e4f1ff;
  font-size: 12px;
  font-weight: 700;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.error {
  border: 3px solid #ffd33c;
  border-radius: 10px;
  padding: 14px;
  background: #573c2d;
  color: #fff1cb;
  margin-bottom: 14px;
}

/* Code map, inspector, controls and status palette */
.map-section,
.inventory-section,
.method {
  position: relative;
  border: 4px solid var(--line);
  border-radius: 25px;
  background: linear-gradient(125deg, #4974b0f5, #315c99fa);
  box-shadow:
    inset 0 2px 0 #9fc8e2,
    0 4px 0 #16416d;
  padding: 26px 22px 20px;
  margin-top: 66px;
}

.map-toolbar {
  display: grid;
  align-items: center;
  gap: 24px;
  border: 3px solid #061427;
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  padding: 16px 18px;
  background: linear-gradient(#245c96, #123f70);
  font-size: 13px;
  box-shadow: inset 0 2px 0 #7ba8c9;
  grid-template-columns: minmax(0, 1fr) auto;
}

.compact {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff1b1;
  font: 17px var(--menu);
}

.map-workspace {
  display: block;
  border: 3px solid #061427;
  background: #123f70;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}

.map-wrap {
  min-width: 0;
  position: relative;
  padding: 12px 12px 0;
  background: #092c53;
  box-shadow: inset 0 0 0 2px #4e85ad;
}

#treemap {
  display: block;
  width: 100%;
  height: 430px;
  touch-action: pan-y;
  cursor: crosshair;
}

.map-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 1px;
  font-size: 11px;
  color: #c9e3fa;
}

.map-tip {
  position: absolute;
  left: 20px;
  bottom: 45px;
  max-width: calc(100% - 40px);
  background: #082a50f5;
  border: 2px solid #ffd23c;
  border-radius: 7px;
  padding: 8px 12px;
  pointer-events: none;
  overflow-wrap: anywhere;
  font: 11px var(--mono);
  z-index: 2;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding-top: 17px;
  font-size: 12px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.swatch {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid #07182b;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 #ffffff66;
}

.exact {
  background: var(--exact);
}

.behavior {
  background: var(--behavior);
}

.pending {
  background: var(--pending);
}

.unmapped {
  background: var(--unmapped);
}

#inspector {
  min-width: 0;
  border: 0;
  padding: 0;
  background: none;
}

.selection-summary {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

#inspector .section-index {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  margin: 0;
  font-size: 20px;
}

.selection-identity {
  min-width: 0;
}

#detail-name {
  font-size: 20px;
  line-height: 1.2;
  margin: 0;
  color: #fff;
}

#detail-description {
  font-size: 12px;
  line-height: 1.5;
  margin: 5px 0 0;
  color: #e1edfb;
  overflow-wrap: anywhere;
}

#detail-values {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  margin: 14px 0 0;
}

#detail-values:empty {
  display: none;
}

#detail-values > div {
  min-width: 0;
  max-width: 100%;
}

#detail-values dt {
  font-size: 11px;
  margin: 0;
}

#detail-values dd {
  font-size: 12px;
  margin-top: 2px;
}

#detail-values dd.code {
  font-size: 10px;
}

#inspect-region {
  margin-top: 12px;
  font-size: 14px;
  min-height: 40px;
  padding: 7px 12px;
}

.map-controls {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 20px;
  flex-wrap: wrap;
}

#back {
  font-size: 14px;
  min-height: 42px;
  padding: 7px 12px;
}

.map-heading {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  min-width: 0;
}

.map-context {
  font: 32px/1.1 var(--menu);
  color: #ffd33c;
  text-shadow: var(--ink-shadow);
  overflow-wrap: anywhere;
}

#detail-description:empty {
  display: none;
}

.map-label-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px;
  cursor: pointer;
  flex-shrink: 0;
  border: 3px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: linear-gradient(#3879ba, #174b83);
  box-shadow:
    inset 0 2px 0 #80c2e3,
    inset 0 -3px 0 #082c57,
    0 2px 0 #061427;
}

.map-label-toggle input {
  width: 13px;
  height: 13px;
  margin: 0;
  accent-color: var(--exact);
  cursor: pointer;
}

.map-label-toggle:focus-within {
  outline: 3px solid #ffdc45;
  outline-offset: 3px;
}

.map-label-toggle:hover {
  color: #ffda4f;
  background: linear-gradient(#508dd0, #225891);
}

.map-label-letter {
  font: 17px/1 var(--menu);
  text-shadow: var(--ink-shadow);
}

.map-heading h2 {
  white-space: nowrap;
}

.map-filter-note {
  color: var(--text);
  font-size: 12px;
  margin: 12px 0 0;
}

.map-section .section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

/* Function inventory, search and pagination */
.inventory-tools {
  display: flex;
  align-items: end;
  gap: 24px;
}

.search-label {
  flex: 1;
}

.search-label span,
.filter-label {
  font: 18px var(--menu);
  color: #ffdc55;
  text-shadow: var(--ink-shadow);
}

input[type="search"] {
  display: block;
  margin-top: 10px;
  width: 100%;
  height: 48px;
  border: 3px solid #081729;
  border-radius: 9px;
  background: #123e70;
  color: #fff;
  padding: 10px 13px;
  box-shadow: inset 0 2px 0 #06172e;
  font: 14px var(--font);
}

.filter-label select {
  display: block;
  margin-top: 10px;
  min-width: 190px;
  height: 46px;
}

.result-count {
  font-size: 12px;
  color: #e0efff;
  margin: 20px 0 12px;
  min-height: 18px;
}

.table-scroll {
  overflow-x: auto;
  border: 3px solid #081729;
  border-radius: 12px;
  background: #0e3c6b;
  box-shadow: inset 0 0 0 2px #80a8c6;
}

table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  text-align: left;
  font-size: 13px;
}

th {
  color: #ffdc55;
  font: 17px var(--menu);
  padding: 13px 12px;
  border-bottom: 3px solid #07182b;
  background: #183d68;
  text-shadow: var(--ink-shadow);
}

th:first-child {
  width: 44%;
}

th:nth-child(2) {
  width: 23%;
}

th:nth-child(3) {
  width: 12%;
}

th:last-child {
  width: 21%;
}

td {
  padding: 10px 12px;
  border-bottom: 2px solid #082b4d;
  overflow-wrap: anywhere;
  background: linear-gradient(#245a92, #1a4c81);
}

tr:nth-child(even) td {
  background: linear-gradient(#2a629b, #235589);
}

tr:hover td {
  background: #3376b4;
}

td button {
  background: transparent !important;
  border: 0;
  border-radius: 0;
  box-shadow: none !important;
  min-height: 36px;
  max-width: 100%;
  padding: 0;
  color: #fff;
  font: 12px var(--mono);
  text-align: left;
  text-shadow: none;
}

td button:hover {
  color: #ffe14d;
  text-decoration: underline;
}

td small {
  display: block;
  color: #c4dcf3;
  font: 10px var(--mono);
  margin-top: 3px;
}

.status-text {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  padding-top: 18px;
  color: #e0efff;
  font-size: 12px;
}

.pagination div {
  display: flex;
  gap: 10px;
}

.pagination button {
  font-size: 16px;
}

.empty {
  padding: 24px;
  background: #184b7e;
  border: 2px solid #07182b;
  border-radius: 10px;
}

.function-description {
  font: 12px/1.55 var(--font);
  color: #e0efff;
  margin: 8px 0 0;
  text-shadow: none;
}

/* Methodology and footer */
.method {
  margin: 46px 0 28px;
  padding-top: 19px;
  font-size: 13px;
  min-height: 0;
}

.method:after {
  content: "";
  display: block;
  clear: both;
}

.method summary {
  font: 21px var(--menu);
  color: #ffdc55;
  text-shadow: var(--ink-shadow);
}

.method p {
  color: #e4efff;
  line-height: 1.8;
  max-width: 850px;
}

.method-art {
  float: right;
  width: 130px;
  height: 130px;
  object-fit: cover;
  border: 3px solid #061427;
  border-radius: 16px;
  margin: 20px 0 0 25px;
  box-shadow: 3px 3px #173c67;
}

.scope-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 790px;
}

.scope-facts dt {
  margin-top: 0;
}

.snapshot-label {
  font: 10px/1.8 var(--mono);
  overflow-wrap: anywhere;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 0 4px 30px;
  color: #e2f1ff;
  font-size: 11px;
  text-shadow: 1px 1px #17416f;
}

footer a {
  color: #fff2b1;
}

@media (min-width: 1500px) {
  #treemap {
    height: 480px;
  }
}

@media (max-width: 1050px) {
  .shell {
    padding: 0 30px;
  }

  .compact {
    font-size: 15px;
    gap: 8px;
  }

  select {
    font-size: 14px;
  }

  .map-toolbar {
    gap: 14px;
    padding: 14px;
  }

  .selection-summary {
    gap: 12px;
  }

  #inspector .section-index {
    font-size: 18px;
  }

  #inspector .sprite {
    --sprite-size: 28px;
  }

  #detail-name {
    font-size: 18px;
  }

  .map-controls {
    gap: 12px;
  }

  .compact select {
    max-width: 185px;
  }

  .map-context {
    font-size: 24px;
  }
}

@media (max-width: 800px) {
  .map-toolbar {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .map-controls {
    justify-content: space-between;
    border-top: 1px solid #6f9aca80;
    padding-top: 14px;
  }

  .map-controls .compact {
    margin-left: auto;
    width: auto;
    gap: 8px;
    justify-content: end;
  }

  .map-controls .compact select {
    max-width: 180px;
    flex: initial;
  }

  #detail-values {
    gap: 10px 20px;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 0 16px;
  }

  .map-section,
  .inventory-section {
    padding: 23px 12px 15px;
    border-radius: 20px;
    margin-top: 52px;
  }

  .section-heading {
    gap: 12px;
  }

  .section-heading > h2 {
    font-size: 27px;
    margin: 0;
  }

  .text-button {
    font-size: 15px;
    padding: 6px 10px;
    min-height: 38px;
  }

  .compact {
    width: 100%;
    justify-content: space-between;
  }

  .compact select {
    flex: 1;
    max-width: 80%;
  }

  #treemap {
    height: 345px;
  }

  .map-caption {
    font-size: 9px;
    gap: 8px;
  }

  .legend {
    font-size: 10px;
    gap: 11px 15px;
  }

  .inventory-tools {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }

  .search-label span,
  .filter-label {
    font-size: 17px;
  }

  .filter-label select {
    width: 100%;
  }

  .section-heading > .outline-button {
    font-size: 14px;
    padding: 8px 10px;
    min-height: 40px;
  }

  th:first-child {
    width: 52%;
  }

  th:nth-child(2),
  td:nth-child(2) {
    display: none;
  }

  th:nth-child(3) {
    width: 15%;
  }

  th:last-child {
    width: 33%;
  }

  th {
    font-size: 14px;
    padding: 10px 7px;
  }

  td {
    padding: 9px 7px;
    font-size: 11px;
  }

  td button {
    font-size: 10px;
  }

  .status-text {
    font-size: 10px;
    gap: 5px;
  }

  .swatch {
    width: 10px;
    height: 10px;
  }

  .pagination {
    font-size: 11px;
  }

  .pagination button {
    font-size: 14px;
    padding: 7px 10px;
  }

  .pagination div {
    gap: 6px;
  }

  .method {
    padding: 16px 14px;
    margin-top: 32px;
  }

  .method summary {
    font-size: 19px;
  }

  .method-art {
    width: 86px;
    height: 86px;
    margin-left: 14px;
  }

  .scope-facts {
    grid-template-columns: minmax(0, 1fr);
    font-size: 11px;
  }

  footer {
    font-size: 10px;
    align-items: start;
    gap: 10px;
  }

  .wallpaper:before {
    background-position: 52% center;
  }

  .function-description {
    font-size: 11px;
    line-height: 1.5;
  }

  .map-heading h2 {
    font-size: 27px;
  }

  .map-context {
    font-size: 23px;
  }

  .map-label-toggle {
    padding: 6px;
    min-width: 42px;
  }

  .map-section .section-heading {
    grid-template-columns: minmax(0, 1fr);
  }

  .sync {
    justify-content: flex-start;
    font-size: 11px;
    gap: 8px;
  }

  #sync-text {
    flex: 1;
    min-width: 120px;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 450px) {
  .map-toolbar {
    padding: 12px 10px;
  }

  .map-controls {
    gap: 12px;
  }

  .map-controls .compact {
    font-size: 14px;
  }

  .map-controls .compact select {
    font-size: 13px;
    max-width: 155px;
  }

  #back {
    font-size: 12px;
    padding: 7px 9px;
  }

  .selection-summary {
    flex-wrap: wrap;
    gap: 10px 16px;
  }

  .selection-identity {
    flex: 1;
    min-width: 120px;
  }

  #detail-description {
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  button {
    transition: none;
  }

  button:active {
    transform: none;
  }
}
