/* cajigas.es home. Standalone: the other pages keep using styles.css.
   No viewport-height tricks. Below 62rem it is one column; above, a fixed side column. */

:root {
  --bg: #fbfaf7;
  --panel: #f2eee4;
  --ink: #1c1916;
  --muted: #5e574e;
  --rule: #ddd6c8;
  --mark: #9f2d22;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --pad: 1.25rem;
  --side: 18.5rem;
  --gap: clamp(2.5rem, 5vw, 5rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513;
    --panel: #1f1d1a;
    --ink: #ece7dc;
    --muted: #b7b0a4;
    --rule: #3a342c;
    --mark: #e07a68;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 4rem;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
h1, h2, h3 { font-weight: 400; line-height: 1.15; text-wrap: balance; }
p { text-wrap: pretty; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

::selection { background: #f0d4cf; color: #1c1916; }
@media (prefers-color-scheme: dark) {
  ::selection { background: #5c2a24; color: #fbfaf7; }
}

a {
  color: inherit;
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: color 0.2s var(--ease), text-decoration-thickness 0.2s var(--ease);
}
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--mark); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  a, .sitenav a::after { transition: none; }
}

html.is-en [data-lang="es"],
html.is-es [data-lang="en"],
html.is-en .when-es,
html.is-es .when-en { display: none !important; }

.skip {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 30;
  padding: 0.4rem 0.6rem;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 0.9rem;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

/* Shell ------------------------------------------------------------ */

.shell {
  max-width: 78rem;
  margin: 0 auto;
  padding: 0 var(--pad);
}

/* Below 62rem the side wrapper disappears and masthead and nav stack. */
.side { display: contents; }

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "bar bar" "ident portrait";
  align-items: start;
  column-gap: 1rem;
  padding: 0.9rem 0 1.5rem;
}

.bar {
  grid-area: bar;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.brand { font-weight: 600; text-decoration: none; letter-spacing: 0.02em; }
.lang { color: var(--muted); white-space: nowrap; }
.lang:hover { color: var(--ink); }
.lang:active { transform: translateY(1px); }

.portrait { grid-area: portrait; margin-top: 0.3rem; }
.portrait img {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  border-radius: 3px;
  mix-blend-mode: multiply;
}
@media (prefers-color-scheme: dark) {
  .portrait img { mix-blend-mode: normal; filter: brightness(0.82) contrast(1.05); }
}

.ident { grid-area: ident; min-width: 0; }

.eyebrow {
  margin-bottom: 0.9rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::after {
  content: "";
  display: block;
  width: 2.25rem;
  height: 2px;
  margin-top: 0.8rem;
  background: var(--mark);
}

h1 {
  font-size: clamp(2.3rem, 10.5vw, 3.6rem);
  line-height: 1.04;
  letter-spacing: -0.04em;
}
h1 .line { display: block; }
.accent { color: var(--mark); }

.lede {
  grid-column: 1 / -1;
  max-width: 26rem;
  margin-top: 1.1rem;
  font-size: 1.2rem;
  line-height: 1.4;
}

/* Section nav. A sticky bar on small screens. */
.sitenav {
  counter-reset: section;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 calc(var(--pad) * -1);
  padding: 0 var(--pad);
  background: var(--bg);
  border-block: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: clamp(0.68rem, 3.3vw, 0.82rem);
}
.sitenav a {
  padding: 0.85rem 0;
  text-decoration: none;
  white-space: nowrap;
  color: var(--muted);
}
.sitenav a:hover { color: var(--ink); }
.sitenav a.is-here { color: var(--mark); }
.sitenav a::before { counter-increment: section; }
.sitenav a:active { transform: translateY(1px); }

/* Content ---------------------------------------------------------- */

.content { min-width: 0; }

main > section {
  padding: 3.5rem 0;
  border-top: 1px solid var(--rule);
}
main > section:first-child { border-top: 0; padding-top: 3rem; }

.kicker {
  margin-bottom: 0.7rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--mark);
}

h2 {
  margin-bottom: 1.5rem;
  font-size: clamp(2.3rem, 6vw, 3.4rem);
  letter-spacing: -0.035em;
}

h3 { font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
h3 a { text-decoration: none; }
h3 a:hover { text-decoration: underline; }

.intro { max-width: 38rem; margin: -0.4rem 0 1.75rem; }

/* About */
.about { display: grid; gap: 1.25rem; max-width: 40rem; }
.about p { font-size: 1.15rem; }
.about .lead {
  font-size: clamp(1.45rem, 3.6vw, 1.95rem);
  line-height: 1.28;
  letter-spacing: -0.018em;
}

/* Insparya figures */
.figures {
  margin-top: 3rem;
  padding: 1.5rem var(--pad) 1.4rem;
  background: var(--panel);
}
.figures-title {
  margin-bottom: 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mark);
}
.figures-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.75rem 1.25rem;
}
.figure {
  font-size: clamp(2.8rem, 9vw, 4.25rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.figure-label {
  max-width: 12rem;
  margin-top: 0.45rem;
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--muted);
}
.figures-source {
  max-width: 40rem;
  margin-top: 1.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--muted);
}

/* Work and projects share one row pattern. */
.rows { border-bottom: 1px solid var(--rule); }
.row-item {
  display: grid;
  gap: 0.35rem 2rem;
  padding: 1.3rem 0 1.4rem;
  border-top: 1px solid var(--rule);
}
.row-item p { max-width: 38rem; }
.what h3, .work-name h3 { margin-bottom: 0.4rem; }
.work-name h3 { margin-bottom: 0.5rem; overflow-wrap: anywhere; }

.when, .kind, .links, .more {
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}
.when { padding-top: 0.2rem; }
.is-current .when { color: var(--mark); }
.is-current .when::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.kind {
  display: inline-block;
  padding: 0.05rem 0.55rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
}

.work-body p + p { margin-top: 0.6rem; }
.links { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; }
.links a { color: var(--ink); }

.note { max-width: 40rem; margin-top: 1.75rem; }
.more { margin-top: 1rem; }
.more a { color: var(--ink); }
.libs { max-width: 40rem; margin-top: 1.75rem; font-size: 0.98rem; color: var(--muted); }
.libs a { color: var(--ink); }

/* Contact */
.ghost {
  margin-bottom: 0.5rem;
  font-size: clamp(3.6rem, 15vw, 8rem);
  line-height: 0.85;
  letter-spacing: -0.045em;
  color: transparent;
  -webkit-text-stroke: 1px color-mix(in srgb, var(--ink) 42%, transparent);
  user-select: none;
}

.email {
  display: inline-block;
  font-size: clamp(1.4rem, 5.6vw, 2.5rem);
  letter-spacing: -0.025em;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--mark);
  text-underline-offset: 0.2em;
  overflow-wrap: anywhere;
}
.email { transition: color 0.2s var(--ease); }
.email:hover { color: var(--mark); }

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
  font-family: var(--sans);
  font-size: 0.92rem;
}
.social a {
  display: inline-block;
  padding: 0.45rem 1rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  text-decoration: none;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.1s var(--ease);
}
.social a:hover { background: var(--ink); color: var(--bg); }
.social a:active { transform: scale(0.97); }

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  padding: 1.1rem 0 1.75rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}
footer a { color: var(--ink); }

/* Wider than a phone ------------------------------------------------ */

@media (min-width: 36rem) {
  :root { --pad: 2rem; }
  .portrait img { width: 7rem; height: 7rem; }
  .figures { padding: 1.75rem 1.75rem 1.6rem; }
}

@media (min-width: 48rem) {
  .figures-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .row-item { grid-template-columns: 9.5rem minmax(0, 1fr); }
  .projects .row-item { grid-template-columns: 13rem minmax(0, 1fr); }
  main > section { padding: 4.5rem 0; }
  main > section:first-child { padding-top: 3.5rem; }
}

/* Side column ------------------------------------------------------- */

@media (min-width: 62rem) {
  html { scroll-padding-top: 2rem; }

  .shell {
    display: grid;
    grid-template-columns: var(--side) minmax(0, 1fr);
    column-gap: var(--gap);
  }

  .side {
    position: sticky;
    top: 0;
    align-self: start;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: 1.75rem 0 1.75rem;
    overflow-y: auto;
    background: var(--bg);
  }
  body.cookie-open .side { height: calc(100dvh - var(--cookie-h, 0px)); }

  .masthead {
    display: block;
    padding: 0;
  }
  .bar { margin-bottom: 2.25rem; }
  .portrait { margin: 0 0 1.5rem; }
  .portrait img { width: 8.5rem; height: 8.5rem; }
  h1 { font-size: 3.4rem; }
  .lede { margin-top: 1.1rem; }

  .sitenav {
    position: static;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0;
    margin: auto 0 0;
    padding: 2rem 0 0;
    background: none;
    border: 0;
    font-size: 0.82rem;
  }
  .sitenav a {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.4rem 0;
    letter-spacing: 0.03em;
  }
  .sitenav a::before {
    content: counter(section, decimal-leading-zero);
    content: counter(section, decimal-leading-zero) / "";
    font-size: 0.7rem;
    opacity: 0.8;
  }
  .sitenav a::after {
    content: "";
    width: 0;
    height: 1px;
    background: currentColor;
    transition: width 0.25s var(--ease);
  }
  .sitenav a.is-here::after,
  .sitenav a:hover::after { width: 1.75rem; }

  main > section:first-child { padding-top: 3.25rem; }
}

@media (min-width: 62rem) and (max-width: 74.99rem) {
  .figures-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 62rem) and (max-height: 40rem) {
  .portrait img { width: 5.5rem; height: 5.5rem; }
  h1 { font-size: 2.6rem; }
  .bar { margin-bottom: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .sitenav a::after { transition: none; }
}

/* Cookie notice. Hidden until script.js shows it. */
.cookie-notice {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding: 0.9rem var(--pad) calc(0.9rem + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--rule);
  box-shadow: 0 -8px 24px color-mix(in srgb, #1c1916 12%, transparent);
  font-family: var(--sans);
  font-size: 0.92rem;
  line-height: 1.4;
}
.cookie-notice[hidden] { display: none; }
.cookie-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  max-width: 72rem;
  margin: 0 auto;
}
.cookie-title { font-family: var(--serif); font-size: 1.15rem; letter-spacing: -0.02em; }
.cookie-inner > p:nth-child(2) { flex: 1 1 18rem; }
.cookie-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cookie-actions button {
  appearance: none;
  padding: 0.5rem 0.95rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.1s var(--ease);
}
.cookie-actions button:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.cookie-actions button:active { transform: scale(0.97); }
.cookie-actions button[data-consent="all"] { background: var(--ink); color: var(--bg); }
.cookie-actions button[data-consent="all"]:hover { background: color-mix(in srgb, var(--ink) 85%, var(--bg)); }
body.cookie-open { padding-bottom: var(--cookie-h, 8rem); }

@media print {
  .skip, .lang, .sitenav, .ghost, .cookie-notice { display: none !important; }
  body, .side { background: #fff; color: #000; }
  .side { position: static; height: auto; overflow: visible; }
  .shell { display: block; }
  .portrait img { width: 3.5cm; height: 3.5cm; mix-blend-mode: normal; filter: none; }
  .figures { background: none; border: 1px solid #ccc; }
  a { text-decoration: none; }
}
