/* =============================================================================
   styles.css - Samuel Espinoza Velandia
   Mobile-first. Light theme by default, dark theme follows the OS setting.
   ============================================================================= */

/* --- Tokens --- */
:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --surface: #f5f7fa;
  --border: #e2e8f0;
  --text: #0f1b2d;
  --muted: #4a5568;
  --accent: #1769a3;
  --accent-hover: #11558a;
  --on-accent: #ffffff;
  --header-bg: rgb(255 255 255 / 0.88);
  --shadow: 0 1px 2px rgb(15 27 45 / 0.05), 0 8px 24px rgb(15 27 45 / 0.06);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 12px;
  --container: 64rem;
  --header-h: 4rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1320;
    --surface: #121c2c;
    --border: #24324a;
    --text: #e6edf6;
    --muted: #a3b1c6;
    --accent: #6cc0ea;
    --accent-hover: #93d2f0;
    --on-accent: #06192a;
    --header-bg: rgb(11 19 32 / 0.88);
    --shadow: none;
  }

  /* Without shadows, cards on a plain section need their own fill to stand out */
  .section:not(.section-alt) .card {
    background: var(--surface);
  }
}

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

/* scroll-padding keeps anchor targets and focused elements clear of the sticky header */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1rem/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

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

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

/* <main> is focusable only so the skip link can move focus into it */
#main:focus {
  outline: none;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

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

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* While i18n.js applies a non-English language, hide the English source text.
   The delayed animation reveals the page anyway if the script never finishes. */
.i18n-pending body {
  visibility: hidden;
  animation: i18n-reveal 0s 1.5s forwards;
}

@keyframes i18n-reveal {
  to {
    visibility: visible;
  }
}

/* --- Skip link --- */
.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
}

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

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.625rem 1.125rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.btn-secondary {
  border-color: var(--border);
  background: var(--bg);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
}

/* Without JS the phone header wraps to two rows; don't let it cover the content */
@media (max-width: 47.99rem) {
  html:not(.js) .site-header {
    position: static;
  }
}

.header-inner {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  margin-right: auto;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.brand:hover {
  color: var(--text);
}

.brand img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* Logo only on phones; the name stays available to screen readers */
@media (max-width: 29.99rem) {
  .brand-name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

.site-nav {
  display: flex;
  align-items: center;
}

.nav-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-menu a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
}

.nav-menu a:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-menu a[aria-current] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.4em;
}

/* Menu toggle: only with JS, only below the desktop breakpoint */
.nav-toggle {
  display: none;
}

.js .nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.nav-toggle .icon-close,
.nav-open .nav-toggle .icon-open {
  display: none;
}

.nav-open .nav-toggle .icon-close {
  display: block;
}

.js .nav-menu {
  display: none;
}

.js .nav-open .nav-menu {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--header-h));
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.75rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.js .nav-open .nav-menu a {
  padding: 0.75rem;
}

/* Language switch (needs JS, hidden without it) */
.lang-switch {
  display: none;
}

.js .lang-switch {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.lang-switch button {
  min-width: 2.5rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.625rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 0.8125rem/1 var(--font);
  letter-spacing: 0.04em;
  cursor: pointer;
}

.lang-switch button:hover {
  color: var(--text);
}

.lang-switch button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* An outside ring would blend into the pressed button next to it */
.lang-switch button:focus-visible {
  outline-color: currentColor;
  outline-offset: -4px;
}

@media (forced-colors: active) {
  .lang-switch button[aria-pressed="true"] {
    forced-color-adjust: none;
    background: Highlight;
    color: HighlightText;
  }
}

/* --- Hero --- */
.hero {
  padding: 4rem 0 3.5rem;
  background: radial-gradient(60rem 30rem at 85% -10%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%);
}

.hero-inner {
  display: grid;
  gap: 1.5rem;
}

.hero-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--border);
}

.hero h1 {
  font-size: clamp(2.25rem, 1.5rem + 3.5vw, 3.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero-role {
  margin: 0.5rem 0 0;
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 600;
}

.hero-lead {
  max-width: 38rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 1.125rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

/* --- Sections --- */
.section {
  padding: 4rem 0;
}

.section-alt {
  border-block: 1px solid var(--border);
  background: var(--surface);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-lead {
  max-width: 40rem;
  margin: 0 0 2rem;
  color: var(--muted);
  font-size: 1.0625rem;
}

/* Pulls the lead closer to the title: depends on .section-title's margin-bottom */
.section-title + .section-lead {
  margin-top: -0.75rem;
}

/* About */
.about-grid {
  display: grid;
  gap: 2.5rem;
}

.prose {
  max-width: 40rem;
  font-size: 1.0625rem;
}

.prose p:last-child {
  margin-bottom: 0;
}

.facts {
  display: grid;
  gap: 1.75rem;
  align-content: start;
}

.facts h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.facts p {
  margin: 0;
  color: var(--muted);
}

/* Cards (services, experience): 1 column, then 2 per row, then 3 per row
   (exactly 4 cards stay 2 per row). An incomplete last row stretches so the grid never leaves a hole. */
.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 36rem) {
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

@media (min-width: 64rem) {
  .cards {
    grid-template-columns: repeat(6, 1fr);
  }

  .card,
  .card:last-child:nth-child(odd) {
    grid-column: span 2;
  }

  /* Last row of two */
  .card:nth-last-child(2):nth-child(3n + 1),
  .card:last-child:nth-child(3n + 2) {
    grid-column: span 3;
  }

  /* Last row of one */
  .card:last-child:nth-child(3n + 1) {
    grid-column: 1 / -1;
  }

  /* Exactly four cards: 2 + 2 */
  .card:first-child:nth-last-child(4),
  .card:first-child:nth-last-child(4) ~ .card {
    grid-column: span 3;
  }
}

.card {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  box-shadow: var(--shadow);
}

.card-icon {
  display: inline-flex;
  margin-bottom: 1rem;
  padding: 0.625rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.card h3 {
  margin-bottom: 0.5rem;
  font-size: 1.0625rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Contact */
.contact-panel {
  padding: 3rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
}

.contact-panel h2 {
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.contact-panel p {
  max-width: 32rem;
  margin: 0.75rem auto 0;
  color: var(--muted);
  font-size: 1.0625rem;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

/* Full-width stacked buttons on phones, a centered wrapping row from there up */
@media (max-width: 33.99rem) {
  .contact-panel {
    padding-inline: 1rem;
  }

  .contact-actions {
    flex-direction: column;
  }

  .contact-actions .btn {
    justify-content: center;
    width: 100%;
    padding-inline: 0.75rem;
  }
}

/* --- Desktop --- */
@media (min-width: 48rem) {
  .container {
    padding-inline: 2rem;
  }

  .header-inner {
    flex-wrap: nowrap;
    gap: 1rem;
  }

  .brand-name {
    white-space: nowrap;
  }

  .nav-menu a {
    padding-inline: 0.625rem;
  }

  .js .nav-toggle {
    display: none;
  }

  .js .nav-menu,
  .js .nav-open .nav-menu {
    position: static;
    display: flex;
    flex-direction: row;
    max-height: none;
    overflow: visible;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }

  .hero {
    padding: 6rem 0 5rem;
  }

  .hero-inner {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 2.5rem;
  }

  .hero-avatar {
    width: 144px;
    height: 144px;
  }

  .section {
    padding: 5rem 0;
  }

  .about-grid {
    grid-template-columns: 1.6fr 1fr;
    gap: 4rem;
  }

  .contact-panel {
    padding: 4rem 2rem;
  }
}

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

/* --- Print: services, experience and contact details without the page chrome --- */
@media print {
  :root {
    --bg: #ffffff;
    --surface: #ffffff;
    --border: #cccccc;
    --text: #000000;
    --muted: #333333;
    --accent: #000000;
    --shadow: none;
  }

  .i18n-pending body {
    visibility: visible;
  }

  .site-header,
  .skip-link,
  .hero-actions,
  .hero-avatar {
    display: none !important;
  }

  html {
    font-size: 11pt;
  }

  .hero {
    padding: 0 0 1rem;
    background: none;
  }

  .section,
  .contact-panel {
    padding: 1rem 0;
  }

  .section-alt,
  .contact-panel {
    border: 0;
  }

  .card,
  .contact-panel {
    break-inside: avoid;
  }

  .contact-panel {
    text-align: left;
  }

  .contact-actions {
    justify-content: flex-start;
  }

  .contact-actions .btn {
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #000;
  }

  .contact-actions .icon {
    display: none;
  }

  .contact-actions a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-weight: 400;
  }
}
