:root {
  color-scheme: light;
  --bg: #eceff3;
  --surface: #f8fafc;
  --surface-alt: #e2e7ee;
  --ink: #111418;
  --muted: #475260;
  --accent: #d94f1e;
  --accent-ink: #b53a0e;
  --accent-hover: #962e09;
  --focus: #b53a0e;
  --line: #bfc7d1;
  --line-subtle: #d8dfe8;
  --gutter: clamp(1rem, 4.2vw, 3.5rem);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-enter: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scrollbar-color: #9aa5b4 var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.58;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--accent-ink);
}

::selection {
  background: var(--ink);
  color: var(--surface);
}

img,
svg {
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

code,
.mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

code {
  font-size: 0.88em;
  padding: 0.12em 0.38em;
  background: var(--surface-alt);
  border: 1px solid var(--line-subtle);
  border-radius: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -4rem;
  left: 1rem;
  z-index: 100;
  padding: 0.65rem 1rem;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.875rem;
  font-weight: 600;
}

.skip-link:focus {
  top: 1rem;
}

.site {
  width: min(76rem, calc(100% - 2 * var(--gutter)));
  min-height: 100vh;
  min-height: 100dvh;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
}

/* Header & Footer */
.site-header,
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.site-header {
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  font-family: "Archivo", sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  transition: transform 150ms var(--ease);
}

.brand:hover img,
.brand:focus-visible img {
  transform: scale(1.04);
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem clamp(1rem, 2.5vw, 2rem);
}

.nav a,
.site-footer a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 150ms var(--ease);
}

.nav a::after,
.site-footer a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  height: 1.5px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 160ms var(--ease);
}

.nav a:hover,
.nav a:focus-visible,
.site-footer a:hover,
.site-footer a:focus-visible {
  color: var(--ink);
}

.nav a:hover::after,
.nav a:focus-visible::after,
.site-footer a:hover::after,
.site-footer a:focus-visible::after {
  transform: scaleX(1);
}

main {
  flex: 1;
}

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

h1,
h2,
h3 {
  font-family: "Archivo", sans-serif;
  color: var(--ink);
}

/* Hero / Portada */
.intro {
  container-type: inline-size;
  padding-top: 2.25rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--line);
}

.intro h1 {
  font-size: clamp(1.55rem, 8.1vw, 5.15rem);
  font-size: clamp(1.55rem, 8.1cqi, 5.15rem);
  font-weight: 800;
  line-height: 0.96;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

@media (max-width: 19.5rem) {
  .intro h1 {
    font-size: 1.75rem;
    white-space: normal;
  }
}

.intro-spec {
  margin-top: 1.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--line-subtle);
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) repeat(2, minmax(0, 1fr));
  gap: 1.25rem 2rem;
  align-items: start;
}

.intro-copy {
  color: #2c3540;
  font-size: clamp(1rem, 0.95rem + 0.35vw, 1.15rem);
  line-height: 1.5;
  max-width: 40rem;
}

.intro-meta {
  display: contents;
}

.spec-cell {
  display: grid;
  gap: 0.25rem;
}

.spec-cell dt {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.spec-cell dd {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.38;
}

.spec-sub {
  display: block;
  margin-top: 0.15rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
}

/* Entrance settle (no content hidden if JS disabled) */
.js-enter .intro h1,
.js-enter .intro-spec {
  animation: dossier-enter 560ms var(--ease-enter) both;
}

.js-enter .intro-spec {
  animation-delay: 80ms;
}

@keyframes dossier-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Projects Section */
.section-block {
  padding-top: clamp(1.75rem, 4vw, 2.75rem);
}

.section-block--spaced {
  padding-top: clamp(3.25rem, 6.5vw, 4.75rem);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  margin-bottom: clamp(1.25rem, 2.5vw, 1.75rem);
}

.section-heading h2 {
  font-size: clamp(1.4rem, 1.15rem + 1.1vw, 2rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.03em;
}

.section-summary {
  color: var(--muted);
  max-width: 30rem;
  font-size: 0.95rem;
}

/* Interactive Platform Filter */
.platform-filter {
  display: inline-flex;
  flex-wrap: nowrap;
  max-width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
}

.filter-btn {
  appearance: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  transition: background-color 140ms var(--ease), color 140ms var(--ease), transform 90ms var(--ease);
}

.filter-btn:last-child {
  border-right: 0;
}

.filter-btn:hover {
  color: var(--ink);
  background: var(--surface-alt);
}

.filter-btn:active {
  transform: scale(0.985);
}

.filter-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}

/* Dossier Grid */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 1.25rem;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  transition: border-color 160ms var(--ease), transform 180ms var(--ease), opacity 180ms var(--ease);
}

.project-card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.project-card.is-dimmed {
  opacity: 0.42;
}

.project-card.is-highlighted {
  border-color: var(--accent);
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.85rem 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-subtle);
}

.project-identity {
  display: flex;
  align-items: center;
  gap: 0.95rem;
  min-inline-size: 0;
}

.app-icon {
  aspect-ratio: 1 / 1;
  border-radius: 22%;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.project-card-header h3 {
  font-size: clamp(1.45rem, 1.25rem + 0.7vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.project-card-header h3 a:hover {
  color: var(--accent-ink);
}

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.status-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.project-card-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.project-card-summary {
  color: #2c3540;
  font-size: 0.975rem;
  line-height: 1.54;
}

.spec-table {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-top: 1px solid var(--line-subtle);
  border-radius: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8125rem;
}

.spec-table--sheet {
  border-top: 0;
}

.spec-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line-subtle);
}

.spec-table--sheet .spec-row:last-child {
  border-bottom: 0;
}

.spec-row dt {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.spec-row dd {
  color: var(--ink);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}

.project-card-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  padding-top: 0.25rem;
}

/* Unified Action System */
.store-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.store-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 46px;
  padding: 0.45rem 1rem;
  border-radius: 0;
  border: 1px solid var(--line);
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease), transform 90ms var(--ease);
}

.store-badge:hover {
  transform: translateY(-1px);
}

.store-badge:active {
  transform: translateY(1px) scale(0.985);
}

.store-badge--play {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.store-badge--play:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
  color: var(--surface);
}

.store-badge--play .badge-kicker {
  color: #cbd5e1;
}

.store-badge--web {
  background: var(--bg);
  border-color: var(--line);
  color: var(--ink);
}

.store-badge--web:hover {
  background: var(--surface-alt);
  border-color: var(--ink);
  color: var(--ink);
}

.store-badge--web .badge-kicker {
  color: var(--muted);
}

.store-badge--status {
  background: transparent;
  border-style: dashed;
  border-color: var(--line);
  color: var(--muted);
  pointer-events: none;
}

.badge-icon {
  flex-shrink: 0;
}

.badge-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.badge-kicker {
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-title {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-detail-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding-inline: 0;
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 0.92rem;
  transition: color 140ms var(--ease);
}

.card-detail-link .arrow {
  display: inline-block;
  transition: transform 150ms var(--ease);
}

.card-detail-link:hover {
  color: var(--accent-hover);
}

.card-detail-link:hover .arrow {
  transform: translateX(3px);
}

/* Architecture & Pillars (Swiss Ruled Ledger, zero boxed cards) */
.pillars-ledger {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.75rem 2.25rem;
}

.pillar-item {
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pillar-item h3 {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.pillar-item p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.arch-flow {
  margin-top: 2rem;
  padding: 1.35rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) auto minmax(0, 2.2fr);
  align-items: center;
  gap: 1.25rem 1.5rem;
}

.arch-core {
  display: grid;
  gap: 0.25rem;
}

.arch-core strong {
  font-family: "Archivo", sans-serif;
  font-size: 1rem;
}

.arch-core span {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.arch-bridge {
  width: 2.5rem;
  height: 1px;
  background: var(--ink);
  position: relative;
}

.arch-bridge::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  width: 7px;
  height: 7px;
  border-top: 1.5px solid var(--ink);
  border-right: 1.5px solid var(--ink);
  transform: rotate(45deg);
}

.arch-targets {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
}

.arch-target {
  padding: 0.55rem 1.1rem;
  display: grid;
  gap: 0.2rem;
}

@media (min-width: 36.01rem) {
  .arch-target + .arch-target {
    border-left: 1px solid var(--line-subtle);
  }
}

.arch-target strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.arch-target span {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  color: var(--muted);
}

.arch-target--live span {
  color: var(--accent-ink);
}

/* Detail Pages (/terretatrad/ & /mdnote/) */
.detail {
  padding-top: clamp(1.5rem, 3.5vw, 2.5rem);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 140ms var(--ease);
}

.back-link:hover {
  color: var(--accent-ink);
}

.detail-header {
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
}

.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

.detail h1 {
  font-size: clamp(2.15rem, 1.4rem + 3.2vw, 3.6rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.detail-copy {
  margin-top: 1.15rem;
  color: #2c3540;
  font-size: clamp(1.05rem, 1rem + 0.5vw, 1.25rem);
  line-height: 1.5;
  max-width: 44rem;
}

.detail-links {
  margin-top: 1.5rem;
}

.detail-section,
.availability {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
}

.detail-section h2,
.availability h2,
.other-project h2 {
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 1.1rem;
}

.detail-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1.5rem 2.5rem;
  align-items: start;
}

.detail-overview-prose p {
  max-width: 65ch;
  color: #2c3540;
  font-size: 1rem;
  line-height: 1.62;
}

.detail-overview-prose p + p {
  margin-top: 0.9rem;
}

.detail-spec-sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.75rem 1.5rem;
}

.feature-ledger {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem 2.5rem;
}

.feature-item {
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
}

.feature-item h3 {
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.45rem;
}

.feature-item p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.availability dl {
  border-top: 1px solid var(--line);
  background: var(--surface);
  border-inline: 1px solid var(--line);
}

.availability dl div {
  display: grid;
  grid-template-columns: minmax(7.5rem, 11rem) minmax(0, 1fr);
  gap: 0.5rem 1.25rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
}

.availability dt {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.availability dd {
  color: var(--ink);
  font-size: 0.95rem;
  min-inline-size: 0;
}

.inline-link {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.22em;
}

.inline-link:hover {
  color: var(--accent-hover);
}

.other-project {
  margin-top: clamp(2.75rem, 6vw, 4rem);
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}

.other-project-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  transition: border-color 150ms var(--ease), transform 180ms var(--ease);
}

.other-project-link:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.other-project-link > span:nth-child(2) {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-inline-size: 0;
}

.other-project-link strong {
  font-family: "Archivo", sans-serif;
  font-size: 1.08rem;
  letter-spacing: -0.02em;
}

.other-project-link > span:nth-child(2) span {
  color: var(--muted);
  font-size: 0.92rem;
}

.app-arrow {
  color: var(--accent-ink);
  font-size: 1.25rem;
  transition: transform 150ms var(--ease);
}

.other-project-link:hover .app-arrow {
  transform: translateX(3px);
}

.site-footer {
  margin-top: clamp(3.25rem, 6.5vw, 5rem);
  padding-block: 1.5rem 2rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

/* Responsive */
@media (max-width: 60rem) {
  .intro-spec {
    grid-template-columns: 1fr 1fr;
  }
  .intro-copy {
    grid-column: 1 / -1;
  }
  .project-grid,
  .pillars-ledger,
  .detail-overview,
  .feature-ledger {
    grid-template-columns: 1fr;
  }
  .arch-flow {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .arch-core {
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--line-subtle);
  }
  .arch-bridge {
    display: none;
  }
  .arch-targets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 36rem) {
  .intro-spec,
  .arch-targets {
    grid-template-columns: 1fr;
  }
  .project-card,
  .detail-header {
    padding: 1.35rem;
  }
  .arch-target {
    padding: 0.65rem 0.75rem;
  }
  .arch-target + .arch-target {
    border-top: 1px solid var(--line-subtle);
  }
  .availability dl div {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
  .store-badges,
  .store-badge {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js-enter .intro h1,
  .js-enter .intro-spec {
    animation: none;
  }
  .brand img,
  .nav a::after,
  .site-footer a::after,
  .filter-btn,
  .project-card,
  .store-badge,
  .card-detail-link .arrow,
  .other-project-link,
  .app-arrow {
    transition: none;
  }
  .brand:hover img,
  .brand:focus-visible img,
  .project-card:hover,
  .store-badge:hover,
  .store-badge:active,
  .card-detail-link:hover .arrow,
  .other-project-link:hover,
  .other-project-link:hover .app-arrow {
    transform: none;
  }
}
