/* =========================================================
   Alan Del Angel portfolio - main stylesheet
   To change colors or fonts, edit only the variables in
   :root (light theme) and in the dark theme blocks.
   ========================================================= */

:root {
  /* Colors - light theme */
  --bg: #F4F7EE;          /* page background */
  --surface: #FFFFFF;     /* cards */
  --ink: #15200E;         /* main text */
  --muted: #56634C;       /* secondary text */
  --line: #D9E1CE;        /* borders and dividers */
  --forest: #31521B;      /* dark green (brand color) */
  --lime: #99CB38;        /* lime green (accent) */
  --lime-soft: #E6F1CF;   /* very light green (soft backgrounds) */
  --on-forest: #F4F7EE;   /* text on dark green */

  /* Fonts */
  --display: "Archivo", "Arial Narrow", Arial, sans-serif;
  --body: "Libre Franklin", "Franklin Gothic Book", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  --wrap: 1120px;         /* max content width */
  color-scheme: light;
}

/* Automatic dark theme (follows the visitor's system setting) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10170C; --surface: #172112; --ink: #E7EEDD; --muted: #9DAB91; --line: #2A3822;
    --forest: #A9D652; --lime: #8FC12F; --lime-soft: #22331A; --on-forest: #10170C;
    color-scheme: dark;
  }
}
/* Dark theme chosen with the toggle button */
:root[data-theme="dark"] {
  --bg: #10170C; --surface: #172112; --ink: #E7EEDD; --muted: #9DAB91; --line: #2A3822;
  --forest: #A9D652; --lime: #8FC12F; --lime-soft: #22331A; --on-forest: #10170C;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 17px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
img { max-width: 100%; display: block; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--lime); outline-offset: 3px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.wrap {
  max-width: var(--wrap); margin: 0 auto;
  padding-left: max(24px, env(safe-area-inset-left, 0px));
  padding-right: max(24px, env(safe-area-inset-right, 0px));
}
@media (max-width: 520px) {
  .wrap { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}

/* ---------- navigation bar ---------- */
.nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.nav .wrap { display: flex; align-items: center; gap: 16px; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; font-family: var(--display); font-weight: 800; font-stretch: 112%; white-space: nowrap; }
/* Brand mark: the diamond is drawn by ::after and its shadow by ::before,
   so the shadow can spin slowly on its own axis behind the diamond */
.mark { position: relative; width: 20px; height: 20px; flex: none; }
.mark::before, .mark::after { content: ""; position: absolute; inset: 0; box-sizing: border-box; }
.mark::after { background: var(--lime); border: 2px solid var(--forest); transform: rotate(45deg); }
.mark::before { background: var(--lime-soft); background: color-mix(in srgb, var(--lime) 15%, var(--lime-soft)); transform: translate(3px, 3px) rotate(45deg); animation: mark-spin 20s linear infinite; }
@keyframes mark-spin { from { transform: translate(3px, 3px) rotate(45deg); } to { transform: translate(3px, 3px) rotate(405deg); } }
@media (prefers-reduced-motion: reduce) { .mark::before { animation: none; } }
.nav-links { display: flex; gap: 20px; list-style: none; margin: 0 0 0 auto; padding: 0; font-size: 15px; }
.nav-links a { text-decoration: none; color: var(--muted); }
.nav-links a:hover { color: var(--ink); }
.nav-tools { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1.5px solid var(--forest); background: transparent; color: var(--ink); font: 600 13px var(--body); text-decoration: none; cursor: pointer; white-space: nowrap; }
.pill:hover { background: var(--lime-soft); }
.pill-solid { background: var(--forest); color: var(--on-forest); }
.pill-solid:hover { background: var(--forest); opacity: .9; }
.theme-btn { width: 36px; height: 36px; padding: 0; justify-content: center; }
.theme-btn svg { width: 18px; height: 18px; }
@media (max-width: 900px) { .nav-links { display: none; } .nav-tools { margin-left: auto; } }
@media (max-width: 420px) { .brand span:last-child { display: none; } }

/* ---------- hero ---------- */
.hero { position: relative; overflow: hidden; }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 40px; align-items: center; padding-block: 10px 40px; }
.eyebrow { font-family: var(--mono); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 18px; }
.hero h1 { font-family: var(--display); font-weight: 900; font-stretch: 125%; font-size: clamp(44px, 7.4vw, 92px); line-height: .95; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.hero h1 .accent { color: var(--forest); }

/* Terminal effect on the name: .ghost reserves the space of the full name
   (invisible) so the page does not jump, and .typed shows the letters typed so far */
.hero h1.typewriter { position: relative; text-wrap: wrap; }
.hero h1.typewriter .ghost { visibility: hidden; }
.hero h1.typewriter .typed { position: absolute; inset: 0; }
.cursor {
  display: inline-block; width: .5em; height: .82em; margin-left: .06em;
  vertical-align: -.04em; background: var(--ink);
  animation: parpadeo 1.06s step-end infinite;
}
/* While typing or erasing, the cursor stays solid (like a real terminal) */
.hero h1.typing .cursor { animation: none; }
@keyframes parpadeo { 50% { opacity: 0; } }
.lede { font-size: 18px; line-height: 1.45; max-width: 36em; margin: 26px 0 32px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 13px 22px; border-radius: 999px; font-weight: 600; font-size: 15px; text-decoration: none; border: 2px solid var(--forest); cursor: pointer; transition: transform .15s ease; }
.btn:hover { transform: translateY(-2px); }
.btn-solid { background: var(--forest); color: var(--on-forest); }
.btn-ghost { background: transparent; color: var(--ink); }

.emblem { position: relative; aspect-ratio: 1; max-width: 420px; width: 100%; justify-self: end; }
.emblem .diamond { position: absolute; inset: 14%; background: var(--lime); border: 3px solid var(--forest); transform: rotate(45deg); box-shadow: 18px 18px 0 var(--lime-soft); animation: settle 1.1s cubic-bezier(.2,.8,.2,1) both; }
/* Optional profile photo: main.js shows it (and hides "AD") only if assets/img/photo.jpg loads.
   The photo sits inside the rotated diamond, counter-rotated so it stays upright and clipped by the border. */
.emblem .diamond { overflow: hidden; }
.emblem .photo { position: absolute; left: 50%; top: 50%; width: 142%; height: 142%; max-width: none; object-fit: cover; transform: translate(-50%, -50%) rotate(-45deg); }
.emblem .photo[hidden] { display: none; }
.emblem.has-photo .initials { display: none; }
.emblem .initials { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--display); font-weight: 900; font-stretch: 125%; font-size: clamp(56px, 9vw, 104px); color: #15200E; letter-spacing: -.02em; }
@keyframes settle { from { transform: rotate(20deg) scale(.92); } to { transform: rotate(45deg) scale(1); } }
.coords { position: absolute; top: calc(100% + 44px); left: 0; right: 0; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.cerro { display: block; width: 100%; height: auto; margin-top: -8px; }
.cerro .fill { fill: var(--lime-soft); }
.cerro .ridge { fill: none; stroke: var(--forest); stroke-width: 2; }
@media (max-width: 820px) {
  .hero .wrap { grid-template-columns: 1fr; padding-block: 26px 24px; }
  .emblem { justify-self: start; max-width: 220px; order: -1; margin-bottom: 66px; }
  .coords { text-align: left; }
}

/* ---------- key figures ---------- */
.stats { background: var(--forest); color: var(--on-forest); }
/* 3 equal columns with centered text, so the spacing stays symmetric */
.stats .wrap { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 40px; padding-block: 44px; text-align: center; }
.stat b { display: block; font-family: var(--display); font-weight: 900; font-stretch: 125%; font-size: clamp(40px, 5.2vw, 64px); line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin: 10px auto 0; font-size: 15px; line-height: 1.4; opacity: .9; max-width: 24ch; }
@media (max-width: 560px) { .stats .wrap { grid-template-columns: 1fr; gap: 28px; } }

/* ---------- sections ---------- */
section.block { padding-block: 88px 8px; }
.head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 32px; margin-bottom: 32px; }
.head h2 { font-family: var(--display); font-weight: 800; font-stretch: 118%; font-size: clamp(32px, 4.4vw, 52px); line-height: 1; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.head p { margin: 0; color: var(--muted); max-width: 46ch; }
.subhead { font-family: var(--display); font-weight: 800; font-stretch: 112%; font-size: clamp(22px, 2.6vw, 30px); margin: 64px 0 20px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.filter { padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font: 500 14px var(--body); cursor: pointer; }
.filter:hover { border-color: var(--forest); }
.filter[aria-pressed="true"] { background: var(--forest); border-color: var(--forest); color: var(--on-forest); }

/* project cards */
.projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; }
.project { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; min-width: 0; }
.project.wide { grid-column: 1 / -1; flex-direction: row; }
.project .visual { aspect-ratio: 16 / 10; background: var(--lime-soft); border-bottom: 1px solid var(--line); overflow: hidden; }
.project .visual img { width: 100%; height: 100%; object-fit: cover; }
.project .visual.fig { background: #FFFFFF; }
.project .visual.fig img { object-fit: contain; padding: 14px; }
.project.wide .visual { flex: 1.2; aspect-ratio: auto; min-height: 320px; border-bottom: 0; border-right: 1px solid var(--line); }
.project.wide .body { flex: 1; }
.body { padding: 26px 28px 30px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.kind { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.project h3 { font-family: var(--display); font-weight: 800; font-stretch: 112%; font-size: 26px; line-height: 1.1; margin: 0; text-wrap: balance; }
.project h3 a { text-decoration: none; }
.project h3 a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.project p { margin: 0; }
.result { font-weight: 600; color: var(--forest); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 4px 0 0; }
.tags li { font-family: var(--mono); font-size: 12.5px; padding: 4px 10px; border-radius: 999px; background: var(--lime-soft); color: var(--ink); }
.more { margin-top: auto; padding-top: 6px; font-weight: 600; color: var(--forest); text-decoration: none; }
.more:hover { text-decoration: underline; }
.links { margin-top: auto; padding-top: 6px; display: flex; flex-wrap: wrap; gap: 6px 22px; }
.links .more { margin-top: 0; padding-top: 0; }
.project[hidden] { display: none; }
@media (max-width: 820px) {
  .projects { grid-template-columns: 1fr; }
  .project.wide { flex-direction: column; }
  .project.wide .visual { min-height: 0; aspect-ratio: 16 / 10; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* research and reports */
.docs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.docs li { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 8px 28px; align-items: center; padding-block: 22px; border-bottom: 1px solid var(--line); }
.docs .type { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.docs h3 { margin: 0; font-size: 19px; font-weight: 600; line-height: 1.35; }
.docs p { margin: 4px 0 0; color: var(--muted); font-size: 15.5px; }
@media (max-width: 680px) { .docs li { grid-template-columns: 1fr; } .docs .pill { justify-self: start; } }

/* education */
.edu { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px 56px; align-items: center; padding: 36px 40px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.edu-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.edu-main h3 { font-family: var(--display); font-weight: 800; font-stretch: 112%; font-size: clamp(26px, 3vw, 34px); line-height: 1.1; margin: 0; text-wrap: balance; }
.edu-main p { margin: 0; max-width: 60ch; }
.edu-dates { font-family: var(--mono); font-size: 13.5px; color: var(--muted); }
.edu-gpa { text-align: center; padding-left: 48px; border-left: 1px solid var(--line); }
.edu-gpa b { display: block; font-family: var(--display); font-weight: 900; font-stretch: 125%; font-size: clamp(56px, 7vw, 88px); line-height: 1; color: var(--forest); font-variant-numeric: tabular-nums; }
.edu-gpa span { display: block; margin-top: 8px; font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.edu-tags li { font-size: 13.5px; padding: 6px 12px; }
.edu-note { margin: 14px 0 0; color: var(--muted); font-size: 15px; }
@media (max-width: 760px) {
  .edu { grid-template-columns: 1fr; padding: 28px 24px; }
  .edu-gpa { text-align: left; padding: 24px 0 0; border-left: 0; border-top: 1px solid var(--line); }
}

/* principles */
.principles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px; }
.principle { border-top: 4px solid var(--lime); padding-top: 18px; }
.principle h3 { font-family: var(--display); font-weight: 800; font-stretch: 112%; font-size: 23px; line-height: 1.15; margin: 0 0 10px; text-wrap: balance; }
.principle p { margin: 0; color: var(--muted); }
.principle small { display: block; margin-top: 12px; font-family: var(--mono); font-size: 12.5px; color: var(--forest); }
@media (max-width: 820px) { .principles { grid-template-columns: 1fr; } }

/* experience */
.timeline { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 8px 32px; padding-block: 26px; border-bottom: 1px solid var(--line); }
.when { font-family: var(--mono); font-size: 13.5px; color: var(--muted); padding-top: 4px; font-variant-numeric: tabular-nums; }
.timeline h3 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.timeline .org { color: var(--forest); font-weight: 500; }
.timeline p { margin: 6px 0 0; color: var(--muted); max-width: 68ch; }
.timeline .more { display: inline-block; margin-top: 10px; padding-top: 0; }
@media (max-width: 680px) { .timeline li { grid-template-columns: 1fr; } }

/* skills */
.skills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 28px 40px; }
.skills h3 { font-family: var(--mono); font-size: 13px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.skills p { margin: 0; font-size: 19px; line-height: 1.5; }
/* Languages: full row below the other skills */
.skills .langs { grid-column: 1 / -1; padding-top: 28px; border-top: 1px solid var(--line); }
.langs ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.langs li { display: flex; flex-direction: column; gap: 4px; padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.langs b { font-family: var(--display); font-weight: 800; font-stretch: 118%; font-size: 28px; line-height: 1.1; }
.langs span { font-family: var(--mono); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--forest); }
@media (max-width: 820px) { .langs ul { grid-template-columns: 1fr; } }
@media (max-width: 820px) { .skills { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .skills { grid-template-columns: 1fr; } }
.cert-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cert { display: flex; gap: 18px; align-items: flex-start; padding: 20px 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.cert[hidden] { display: none; }
/* If the Credly image does not load, the issuer's initials show instead */
.cert .badge { position: relative; flex: none; width: 64px; height: 64px; border-radius: 50%; background: var(--lime-soft); display: grid; place-items: center; }
.cert .badge::before { content: attr(data-ini); font: 600 12px var(--mono); letter-spacing: .06em; color: var(--forest); }
.cert .badge img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity .3s; }
.cert .badge.ok { background: transparent; }
.cert .badge.ok::before { content: none; }
.cert .badge.ok img { opacity: 1; }
.cert .badge.square img { border-radius: 14px; }
.cert h4 { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; }
.cert p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.cert .more { display: inline-block; margin-top: 8px; padding-top: 0; font-size: 15px; }
@media (max-width: 680px) { .cert-grid { grid-template-columns: 1fr; } }

/* learning now */
.learning { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; padding: 26px 30px; border-radius: 18px; background: var(--lime-soft); }
.learning .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 6px color-mix(in srgb, var(--lime) 30%, transparent); flex: none; }
.learning p { margin: 0; font-size: 19px; min-width: 0; flex: 1 1 280px; }
.learning b { font-family: var(--mono); font-weight: 500; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; display: block; color: var(--muted); }

/* off the clock */
.offline { display: flex; flex-wrap: wrap; gap: 10px 28px; list-style: none; margin: 0; padding: 0; font-family: var(--display); font-weight: 800; font-stretch: 118%; font-size: clamp(26px, 3.6vw, 44px); line-height: 1.1; }
.offline li:nth-child(even) { color: var(--forest); }

/* contact */
.contact { margin-top: 96px; background: var(--forest); color: var(--on-forest); }
.contact .wrap { padding-block: 72px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.contact h2 { font-family: var(--display); font-weight: 900; font-stretch: 125%; font-size: clamp(38px, 5.6vw, 72px); line-height: .98; margin: 0; text-wrap: balance; }
.channels { display: flex; flex-direction: column; gap: 6px; }
.channel { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid color-mix(in srgb, var(--on-forest) 30%, transparent); min-width: 0; }
.channel .label { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; display: block; }
.channel .value { font-size: 18px; font-weight: 500; overflow-wrap: anywhere; text-decoration: none; }
.channel a.value:hover { text-decoration: underline; }
.copy { flex: none; background: transparent; color: var(--on-forest); border: 1.5px solid currentColor; border-radius: 999px; padding: 6px 14px; font: 600 13px var(--body); cursor: pointer; }
@media (max-width: 820px) { .contact .wrap { grid-template-columns: 1fr; } }

footer { padding-block: 28px; font-size: 14px; color: var(--muted); }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

/* ---------- project pages (case studies) ---------- */
.case-hero { padding-block: 56px 32px; }
.back { display: inline-flex; gap: 8px; color: var(--muted); text-decoration: none; font-size: 15px; margin-bottom: 28px; }
.back:hover { color: var(--ink); }
.case-hero h1 { font-family: var(--display); font-weight: 900; font-stretch: 125%; font-size: clamp(38px, 6vw, 72px); line-height: 1; margin: 0 0 20px; text-wrap: balance; }
.case-hero .lede { max-width: 46ch; margin: 0 0 32px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-block: 20px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 4px 0 0; font-weight: 500; }
@media (max-width: 760px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.case-cover { margin-block: 40px; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--lime-soft); }
.case-cover img { width: 100%; height: auto; }
.case-body { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px 48px; padding-bottom: 40px; }
.case-body h2 { font-family: var(--display); font-weight: 800; font-stretch: 112%; font-size: 24px; line-height: 1.15; margin: 0; padding-top: 4px; }
.case-body > div { max-width: 66ch; margin-bottom: 36px; }
.case-body p { margin: 0 0 14px; }
.case-body ul { margin: 0 0 14px; padding-left: 20px; }
.case-body ul.tags { padding-left: 0; }
.case-body li { margin-bottom: 6px; }
.big-result { font-family: var(--display); font-weight: 900; font-stretch: 125%; font-size: clamp(40px, 6vw, 64px); line-height: 1; color: var(--forest); margin: 0 0 8px; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.gallery figure { margin: 0; }
.gallery img { border-radius: 12px; border: 1px solid var(--line); background: var(--lime-soft); }
.gallery figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; }
.case-body .note { font-size: 14px; color: var(--muted); margin-top: 14px; }
@media (max-width: 760px) { .case-body { grid-template-columns: 1fr; } .gallery { grid-template-columns: 1fr; } }
/* case study tables */
.table-wrap { overflow-x: auto; margin: 0 0 14px; }
.case-table { width: 100%; border-collapse: collapse; font-size: 15.5px; font-variant-numeric: tabular-nums; }
.case-table th, .case-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
.case-table th { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.case-table tr.hl td { font-weight: 600; color: var(--forest); }
.case-fig { margin: 8px 0 18px; border-radius: 12px; border: 1px solid var(--line); background: #FFFFFF; padding: 12px; }
.case-fig img { width: 100%; height: auto; }
.case-fig figcaption { font-size: 14px; color: #56634C; margin-top: 8px; }
.next { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--line); padding-block: 28px 40px; }

/* ---------- scroll reveal animations ----------
   main.js adds .reveal to blocks and .in when they enter the viewport.
   Without JavaScript, or with "reduce motion", everything renders normally. */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0ms); }
.reveal.in { opacity: 1; transform: none; }
.project.reveal.in.done { transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .28s ease, border-color .28s ease; transition-delay: 0ms; }
.hero .wrap > div:first-child > * { animation: subir .7s cubic-bezier(.2,.7,.2,1) both; }
.hero .wrap > div:first-child > :nth-child(2) { animation-delay: .08s; }
.hero .wrap > div:first-child > :nth-child(3) { animation-delay: .16s; }
.hero .wrap > div:first-child > :nth-child(4) { animation-delay: .24s; }
@keyframes subir { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Project cards: scale up slightly on hover (kept last so it wins over .reveal) */
@media (hover: hover) {
  .projects .project { transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .28s ease, border-color .28s ease; }
  .projects .project:hover { transform: scale(1.025); box-shadow: 0 18px 40px -22px rgba(21, 32, 14, .45); border-color: var(--forest); }
  .projects .project.wide:hover { transform: scale(1.012); }
}

/* ERP case study gallery */
.gallery { margin: 14px 0 6px; }
.gallery .wide { grid-column: 1 / -1; }
.gallery img { display: block; width: 100%; height: auto; background: #FFFFFF; }
.gallery .phone { display: flex; align-items: center; gap: 28px; }
.gallery .phone a { flex: 0 0 240px; }
.gallery .phone img { border: 0; background: transparent; }
.gallery .phone figcaption { font-size: 16px; margin: 0; }
@media (max-width: 760px) { .gallery .phone { flex-direction: column; align-items: flex-start; } .gallery .phone a { flex-basis: auto; width: 220px; } }
.facts:has(> div:nth-child(5)) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 760px) { .facts:has(> div:nth-child(5)) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.case-note { max-width: 46em; margin: 0 0 28px; padding: 12px 16px; border-left: 3px solid var(--forest, #31521B); border-radius: 8px; background: var(--lime-soft); font-size: 15px; }
.head h2 abbr { text-decoration: none; border: 0; cursor: help; }
.project .visual-link { display: block; width: 100%; height: 100%; }

/* Language button: lime color and globe icon so it is not confused with the CV button */
.lang-btn { background: var(--lime); border-color: var(--lime); color: #15200E; gap: 6px; padding-inline: 12px 14px; }
.lang-btn:hover { background: var(--lime); filter: brightness(1.06); }
.lang-btn svg { width: 16px; height: 16px; flex: none; }
.lang-btn span { letter-spacing: .04em; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lang-btn { background: var(--lime-soft); border-color: var(--lime); color: var(--lime); }
}
:root[data-theme="dark"] .lang-btn { background: var(--lime-soft); border-color: var(--lime); color: var(--lime); }

/* ---------- chat widget (js/chat.js) ---------- */
.chat-launcher { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: inline-flex; align-items: center; gap: 8px; padding: 12px 18px 12px 14px; border: 0; border-radius: 999px; background: var(--forest); color: var(--on-forest); font: 600 14px var(--body); cursor: pointer; box-shadow: 0 8px 24px rgba(21, 32, 14, .22); }
.chat-launcher svg { width: 22px; height: 22px; flex: none; }
.chat-launcher:hover { opacity: .92; }
.chat-launcher.is-open .chat-launcher-label { display: none; }
.chat-launcher.is-open { padding: 12px; }
.chat-panel { position: fixed; right: 20px; bottom: 84px; z-index: 60; width: 370px; max-height: min(580px, calc(100vh - 110px)); display: flex; flex-direction: column; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 48px rgba(21, 32, 14, .24); overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 14px 18px; border-bottom: 1px solid var(--line); background: var(--lime-soft); }
.chat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--lime); flex: none; }
.chat-title { margin: 0; font: 700 15px var(--body); flex: 1; }
.chat-close { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; }
.chat-close:hover { background: var(--surface); }
.chat-close svg { width: 18px; height: 18px; }
.chat-log { flex: 1 1 auto; min-height: 120px; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { flex-shrink: 0; }
/* Only the message log shrinks and scrolls; header, chips, input and note keep their size */
.chat-head, .chat-chips, .chat-form, .chat-note { flex-shrink: 0; }
.chat-msg { max-width: 86%; padding: 10px 13px; border-radius: 14px; font: 400 14.5px/1.45 var(--body); }
.chat-msg p { margin: 0; white-space: pre-line; }
.chat-bot { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-user { align-self: flex-end; background: var(--forest); color: var(--on-forest); border-bottom-right-radius: 4px; }
.chat-label { display: block; margin-bottom: 4px; font: 500 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--forest); }
.chat-typing { display: flex; gap: 5px; padding: 14px; }
.chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: chat-blink 1.2s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes chat-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px; border-top: 1px solid var(--line); scrollbar-width: none; }
.chat-chips::-webkit-scrollbar { display: none; }
.chat-chip { flex: none; padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: 500 13px var(--body); cursor: pointer; white-space: nowrap; }
.chat-chip:hover { border-color: var(--forest); }
.chat-chip-fact { background: var(--lime); border-color: var(--lime); color: #15200E; font-weight: 600; }
.chat-chip:disabled, .chat-send:disabled { opacity: .55; cursor: default; }
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chat-input { flex: 1; min-width: 0; padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink); font: 400 15px var(--body); }
.chat-input:focus { outline: none; border-color: var(--forest); }
.chat-send { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--forest); color: var(--on-forest); cursor: pointer; }
.chat-send svg { width: 20px; height: 20px; }
.chat-note { margin: 0; padding: 0 16px 10px; font: 400 11.5px var(--body); color: var(--muted); }
@media (max-width: 560px) {
  .chat-launcher { right: 14px; bottom: 14px; padding: 14px; }
  .chat-launcher-label { display: none; }
  .chat-panel { left: 10px; right: 10px; bottom: 80px; width: auto; max-height: calc(100vh - 100px); }
}
@media (prefers-reduced-motion: reduce) { .chat-typing span { animation: none; opacity: .6; } }
@media print { .chat-launcher, .chat-panel { display: none !important; } }
