/* ==========================================================================
   Jesús Reyes — Portfolio
   Pure CSS3 · Mobile first · Themes via CSS variables
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Typography */
  --font-sans: "DM Sans", "Google Sans", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Helvetica, Arial, sans-serif;
  --font-size: 0.875rem;      /* 14px */
  --line-height: 1.5714;      /* 22px */
  --font-weight: 400;

  /* Layout */
  --column: 540px;
  --gutter: 24px;
  --space-top: 64px;
  --space-section: 40px;      /* between sections */
  --space-label: 14px;        /* section label → content */
  --space-row: 6px;           /* between simple rows */
  --space-item: 16px;         /* between richer items (projects) */

  /* Colors — light */
  --color-bg: #fafafa;
  --color-text: #0e0e0e;
  --color-muted: #737373;     /* 4.6:1 on bg, AA for small text */
  --color-label: #525252;     /* section titles: darker than muted, same size */
  --color-faint: #d4d4d4;
  --color-hover: #737373;

  --transition: 0.16s ease;
  color-scheme: light;
}

/* Dark — follows the system unless the user picked light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0e0e0e;
    --color-text: #ededed;
    --color-muted: #8f8f8f;
    --color-label: #b5b5b5;
    --color-faint: #333333;
    --color-hover: #8f8f8f;
    color-scheme: dark;
  }
}

/* Dark — chosen manually */
:root[data-theme="dark"] {
  --color-bg: #0e0e0e;
  --color-text: #ededed;
  --color-muted: #8f8f8f;
  --color-label: #b5b5b5;
  --color-faint: #333333;
  --color-hover: #8f8f8f;
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--font-size);
  font-weight: var(--font-weight);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, p, ul, ol, figure {
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
}

ul, ol { list-style: none; }

a {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color var(--transition), text-decoration-color var(--transition);
}

/* Typographic hover only: color + subtle underline. No boxes. */
a:hover {
  color: var(--color-hover);
  text-decoration-line: underline;
  text-decoration-color: var(--color-faint);
}

/* Inline links inside running text (anchors, mailto):
   dotted underline so they read as clickable without looking
   like a default hyperlink. Turns solid on hover. */
.intro p a,
.section > p a,
.prose a {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--color-muted);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}

.intro p a:hover,
.section > p a:hover,
.prose a:hover {
  color: var(--color-hover);
  text-decoration-style: solid;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--color-muted);
}

:focus-visible {
  outline: 1px dashed currentColor;
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
}
.skip-link:focus { top: 12px; }

.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;
}

.muted { color: var(--color-muted); }

/* ---------- 3. Layout ---------- */
.site-header,
.site-main,
.site-footer {
  width: 100%;
  max-width: calc(var(--column) + var(--gutter) * 2);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- 4. Header ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
}

.site-header__name {
  color: var(--color-text);
}

.site-header__tools {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Language selector: ES | EN */
.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-muted);
}

.lang-switch a { color: var(--color-muted); }
.lang-switch a[aria-current="page"] { color: var(--color-text); }
.lang-switch a[aria-current="page"]:hover { text-decoration: none; }

/* Theme toggle — icon only, no box */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-text);
  cursor: pointer;
  transition: color var(--transition), transform 0.3s ease;
}

.theme-toggle:hover { color: var(--color-hover); }
.theme-toggle svg { width: 14px; height: 14px; display: block; }
:root[data-theme-active="dark"] .theme-toggle svg { transform: rotate(180deg); }

/* ---------- 5. Intro ---------- */
.intro {
  padding-top: var(--space-top);
  margin-bottom: var(--space-section);
}

.intro__greeting {
  color: var(--color-label);
  font-weight: 500;
  margin-bottom: var(--space-label);
}

.intro h1 + p,
.intro p + p { margin-top: 12px; }

/* ---------- 6. Sections ---------- */
.section {
  margin-bottom: var(--space-section);
}

.section__title {
  color: var(--color-label);
  font-weight: 500;
  margin-bottom: var(--space-label);
}

/* Simple rows: label left, meta right */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  column-gap: 14px;
}

.row__meta {
  color: var(--color-muted);
  white-space: nowrap;
}

/* ---------- 7. Focus areas ---------- */
.focus-list > li + li { margin-top: var(--space-item); }
.focus-list p { color: var(--color-muted); }

/* ---------- 8. Case studies list ---------- */
.project-list > li + li { margin-top: var(--space-item); }

.arrow {
  display: inline-block;
  margin-left: 2px;
  color: var(--color-muted);
  transition: transform var(--transition), color var(--transition);
}

a:hover .arrow {
  transform: translate(1px, -1px);
}

.project__desc {
  color: var(--color-muted);
  max-width: 46ch;
}

.project--soon .project__title { color: var(--color-muted); }

/* ---------- 9. About & contact ---------- */
.prose p + p { margin-top: 12px; }

.contact-links {
  margin-top: var(--space-label);
}
.contact-links li + li { margin-top: var(--space-row); }

/* ---------- 9b. 404 page ---------- */
/* Language buttons look exactly like the ES | EN links */
.lang-switch button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--color-muted);
  cursor: pointer;
  transition: color var(--transition);
}
.lang-switch button:hover { color: var(--color-text); }
.lang-switch button[aria-pressed="true"] { color: var(--color-text); cursor: default; }

.section__title h2 { color: var(--color-label); }
.link-list li + li { margin-top: var(--space-row); }

/* ---------- 10. Footer ---------- */
.site-footer {
  padding-top: 24px;
  padding-bottom: 48px;
  color: var(--color-muted);
}

/* ---------- 11. Larger screens ---------- */
@media (min-width: 768px) {
  :root {
    --gutter: 32px;
    --space-top: 96px;
    --space-section: 48px;
  }
  .site-header { padding-top: 32px; }
}

@media (min-width: 1024px) {
  :root {
    --space-top: 120px;
  }
}

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

/* ==========================================================================
   13. Case study and article pages
   Rhythm: 8px base · groups separated more than their parts (proximity)
   ========================================================================== */

/* ---------- Larger hit areas in the header (Fitts's law) ---------- */
.lang-switch a {
  display: inline-block;
  padding: 10px 4px;
  margin: -10px -4px;
}
.theme-toggle {
  width: 40px;
  height: 40px;
  margin: -8px -8px -8px 0;
}

/* ---------- Home: only the title is clickable, with a → arrow ----------
   → = goes to a page inside the site · ↗ = opens another site in a new tab */
.project-list .project__title a {
  display: inline-block;
  padding: 6px 0;                /* taller hit area without moving the layout */
  margin: -6px 0;
}
.arrow--next {
  margin-left: 6px;
}
a:hover .arrow--next {
  color: var(--color-hover);
  transform: translateX(3px);
}

/* ---------- Back link ---------- */
.case-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 40px;
  padding: 8px 0;
  color: var(--color-muted);
}
.case-back:hover { color: var(--color-text); text-decoration: none; }

/* ---------- Header group: eyebrow + title + lead ---------- */
.case-header {
  margin-top: 32px;
}
.case-header__eyebrow {
  color: var(--color-muted);
  margin-bottom: 8px;
}
.case-header h1 {
  font-size: 1.75rem;            /* 28px */
  line-height: 1.2;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.case-header__lead {
  margin-top: 12px;
  font-size: 1.125rem;           /* 18px */
  line-height: 1.5;
  color: var(--color-muted);
}

/* Project facts: a separate group, framed by hairlines */
.case-meta {
  margin: 32px 0 0;
  padding: 16px 0;
  border-top: 1px solid var(--color-faint);
  border-bottom: 1px solid var(--color-faint);
}
.case-meta .row { column-gap: 24px; }
.case-meta .row + .row { margin-top: 8px; }
.case-meta dt { color: var(--color-muted); }
.case-meta dd { margin: 0; text-align: right; }

/* ---------- Body text ---------- */
.case-body {
  margin-top: 56px;
  font-size: 1rem;               /* 16px */
  line-height: 1.75;
}
.case-body > * { margin-top: 0; margin-bottom: 0; }
.case-body > * + * { margin-top: 16px; }

/* Headings: much more space above than below, so each heading
   belongs to the text that follows it */
.case-body h2 {
  margin-top: 64px;
  font-size: 1.25rem;            /* 20px */
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.case-body h3 {
  margin-top: 40px;
  font-size: 1rem;
  line-height: 1.5;
  font-weight: 500;
}
.case-body > h2:first-child { margin-top: 0; }
.case-body h2 + *,
.case-body h3 + * { margin-top: 8px; }
.case-body h2 + h3 { margin-top: 24px; }

.case-body em { font-style: italic; }

.case-body ul,
.case-body ol { padding-left: 1.25em; }
.case-body ul { list-style: disc; }
.case-body ol { list-style: decimal; }
.case-body li + li { margin-top: 6px; }
.case-body li::marker { color: var(--color-muted); }

.case-body blockquote {
  margin: 32px 0;
  padding-left: 20px;
  border-left: 2px solid var(--color-muted);
  font-size: 1.0625rem;          /* 17px */
  line-height: 1.6;
}
.case-body blockquote p + p { margin-top: 12px; }
.case-body > blockquote + * { margin-top: 32px; }

.case-body a {
  text-decoration-line: underline;
  text-decoration-style: dotted;
  text-decoration-color: var(--color-muted);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.case-body a:hover {
  color: var(--color-hover);
  text-decoration-style: solid;
  text-decoration-thickness: 1px;
}

/* ---------- Figures, galleries, videos ---------- */
.case-figure,
.case-video,
.case-anim,
.case-gallery {
  margin-top: 40px !important;
}
.case-body > .case-figure + *,
.case-body > .case-video + *,
.case-body > .case-anim + *,
.case-body > .case-gallery + * {
  margin-top: 40px;
}

.case-figure .zoom {
  display: block;
  cursor: zoom-in;
  text-decoration: none;
}
.case-figure img,
.case-anim video {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: var(--color-faint);
}

figcaption {
  margin-top: 8px;
  color: var(--color-muted);
  font-size: var(--font-size);   /* 14px */
  line-height: var(--line-height);
}

/* Consecutive images: one group, 2 columns on large screens */
.case-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
.case-gallery .case-figure { margin: 0 !important; }
/* uniform tiles: the full image is shown in the zoom */
.case-gallery .case-figure img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center top;
}
.case-gallery > figcaption { margin-top: -16px; }

/* Placeholder while an image is missing */
.case-figure.is-missing .zoom {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 10;
  border: 1px dashed var(--color-faint);
  border-radius: 6px;
  cursor: default;
  color: var(--color-muted);
  font-size: var(--font-size);
}
.case-figure.is-missing img { display: none; }
.case-figure.is-missing .zoom::after { content: attr(data-placeholder); }

.case-video__frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  overflow: hidden;
  background: var(--color-faint);
}
.case-video__frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Media a bit wider than the text column on large screens */
@media (min-width: 860px) {
  .case-figure,
  .case-video,
  .case-anim,
  .case-gallery {
    margin-left: -80px;
    margin-right: -80px;
  }
  .case-figure figcaption,
  .case-video figcaption,
  .case-anim figcaption,
  .case-gallery > figcaption {
    padding-left: 80px;
    padding-right: 80px;
  }
  .case-gallery {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .case-gallery .case-figure figcaption { padding: 0; }
  .case-gallery > figcaption { grid-column: 1 / -1; }
  /* odd number of images: the first one takes the full width */
  .case-gallery--odd > .case-figure:first-child { grid-column: 1 / -1; }
}

/* ---------- End of page: its own group ---------- */
.case-end {
  margin-top: 72px;
  padding-top: 24px;
  border-top: 1px solid var(--color-faint);
}
.case-original {
  color: var(--color-muted);
}
.case-next {
  margin-top: 32px;
  margin-bottom: 0;
}
.case-next .row a { padding: 6px 0; }
.case-back--end {
  margin-top: 32px;
}

/* ---------- Lightbox (native <dialog>) ---------- */
.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ededed;
}
.lightbox[open] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.lightbox::backdrop {
  background: rgba(14, 14, 14, 0.97);
}
.lightbox__img {
  max-width: 94vw;
  max-height: 84vh;
  object-fit: contain;
  cursor: zoom-out;
}
.lightbox__caption {
  max-width: 640px;
  padding: 0 24px;
  text-align: center;
  color: #b5b5b5;
}
.lightbox__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  color: #ededed;
  font: inherit;
  font-size: 20px;
  cursor: pointer;
}
.lightbox__close:hover { color: #9f9f9f; }

html:has(.lightbox[open]) { overflow: hidden; }

@media (min-width: 768px) {
  .case-header h1 { font-size: 2rem; }   /* 32px */
}

/* Headings always keep their space above, whatever comes before them */
.case-body > * + h2 { margin-top: 64px; }
.case-body > * + h3 { margin-top: 40px; }
.case-body > h2 + h3 { margin-top: 24px; }
