/* docs.albertobarradas.com — cohesive with the Academic Pages theme at albertobarradas.com.
   Palette + masthead + heading rules copied from the live site (light #fff/#494e52/#2f7f93/#52adc8;
   the theme's own dark mode #474747/#fff/#0ea1c5). Project cards: image with text over a dark scrim. */
:root {
  --sans: -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI",
          "Helvetica Neue", "Lucida Grande", Arial, sans-serif;
  --maxw: 925px;
  --mast-h: 52px;
  /* light (default) — from the live site */
  --bg: #ffffff;
  --surface-2: #f2f3f3;
  --text: #494e52;
  --muted: #7a8288;
  --border: #dadada;
  --border-strong: #bdc1c4;
  --accent: #2f7f93;      /* --global-base-color */
  --link: #2f7f93;
  --mast-link: #494e52;
  --mast-hover: #2f7f93;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #474747; --surface-2: #565656; --text: #ffffff; --muted: #d3d6d7;
    --border: #6d6d6d; --border-strong: #8a8a8a; --accent: #0ea1c5; --link: #4bc7e6;
    --mast-link: #ffffff; --mast-hover: #0ea1c5;
  }
}
:root[data-theme="dark"] {
  --bg: #474747; --surface-2: #565656; --text: #ffffff; --muted: #d3d6d7;
  --border: #6d6d6d; --border-strong: #8a8a8a; --accent: #0ea1c5; --link: #4bc7e6;
  --mast-link: #ffffff; --mast-hover: #0ea1c5;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; padding-top: var(--mast-h); font-family: var(--sans); color: var(--text);
  background: var(--bg); line-height: 1.6; font-size: 16px; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1em; }

/* Masthead — Academic Pages greedy-nav, fixed at top */
.masthead { position: fixed; top: 0; left: 0; width: 100%; z-index: 20;
  background: var(--bg); border-bottom: 1px solid var(--border); }
.masthead__inner-wrap { max-width: var(--maxw); margin: 0 auto; padding: 0.5em 1em; }
.site-nav .visible-links { display: flex; align-items: center; flex-wrap: wrap;
  list-style: none; margin: 0; padding: 0; }
.masthead__item a { display: block; margin: 0 1rem; padding: 0.4rem 0; color: var(--mast-link); font-size: .95rem; }
.masthead__item a:hover { color: var(--mast-hover); text-decoration: none; }
.masthead__item--lg { margin-right: auto; }
.masthead__item--lg a { margin-left: 0; font-weight: 700; font-size: 1.1rem; }
.masthead__item.selected a { color: var(--accent); font-weight: 600; }
.masthead__toggle { margin-left: .25rem; }
.theme-toggle { display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--border); background: transparent; color: var(--mast-link); border-radius: 6px; cursor: pointer; }
.theme-toggle:hover { color: var(--mast-hover); border-color: var(--accent); }
.theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) .theme-toggle .moon { display: none; }
  :root:not([data-theme]) .theme-toggle .sun { display: block; } }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="light"] .theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: block; }

/* Intro (page title) */
.intro .wrap { padding-top: 1.6em; padding-bottom: 1.1em; }
.intro h1 { margin: 0 0 .2em; font-size: 1.8rem; font-weight: 700; letter-spacing: -.01em; }
.intro .lead { margin: 0; color: var(--muted); }
.intro .counts { margin: .4em 0 0; color: var(--accent); font-weight: 600; font-size: .92rem; }

/* Filter */
.filter { position: sticky; top: var(--mast-h); z-index: 15;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.3) blur(8px);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.filter .wrap { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; padding-top: 9px; padding-bottom: 9px; }
.filter .lbl { font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-right: 4px; }
.chip { font: inherit; font-size: .78rem; cursor: pointer; color: var(--muted); background: var(--bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; line-height: 1.4; }
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.reset { font-weight: 600; }
.filter-note { font-size: .78rem; color: var(--muted); margin-left: auto; }

/* Sections — h2 gets the theme's underline rule */
main { padding-top: 26px; padding-bottom: 8px; }
.sec { margin: 0 0 40px; }
.sec.hidden { display: none; }
.sec-head { margin: 0 0 16px; }
.sec-head h2 { margin: 0; padding-bottom: .5em; border-bottom: 1px solid var(--border);
  font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: baseline; gap: 10px; }
.count { font-size: .72rem; font-weight: 600; color: var(--muted); }
.sec-blurb { margin: 8px 0 0; color: var(--muted); font-size: .92rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }

/* Card = image with text over a dark scrim */
.card { position: relative; min-height: 224px; display: flex; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--border); background: #10201f; isolation: isolate;
  transition: transform .18s ease, box-shadow .18s ease; }
.card.hidden { display: none; }
.card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(20,28,30,.26); }
.card-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; transition: transform .3s ease; }
.card:hover .card-img { transform: scale(1.045); }
.card.noimg { background: linear-gradient(150deg, #17565c, #08333b 72%); }
.card .wm { position: absolute; top: 8px; right: 14px; z-index: 0; font-size: 3.4rem; font-weight: 800;
  color: rgba(255,255,255,.13); letter-spacing: .02em; }
.overlay { position: relative; z-index: 1; margin-top: auto; width: 100%; padding: 13px 15px 14px;
  display: flex; flex-direction: column; gap: 7px; color: #fff; background: rgba(9,15,17,.9); }
.overlay::before { content: ""; position: absolute; left: 0; right: 0; top: -36px; height: 36px;
  pointer-events: none; background: linear-gradient(to top, rgba(9,15,17,.9), rgba(9,15,17,0)); }
.kind { font-size: .64rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; color: #6fe0d3; }
.card h3 { margin: 0; font-size: 1.06rem; font-weight: 700; line-height: 1.25; }
.card h3 a.stretched { color: #fff; }
.card h3 a.stretched::after { content: ""; position: absolute; inset: 0; z-index: 2; }
.card h3 a.stretched:hover { text-decoration: none; }
.blurb { margin: 0; font-size: .85rem; line-height: 1.45; color: rgba(255,255,255,.86);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.note { margin: 0; font-size: .74rem; font-style: italic; color: #9fe6dc; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; position: relative; z-index: 3; }
.tag { font: inherit; font-size: .69rem; cursor: pointer; color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-radius: 5px; padding: 1px 7px; line-height: 1.5; }
.tag:hover { background: rgba(255,255,255,.22); }
.links { display: flex; gap: 12px; margin-top: 1px; position: relative; z-index: 3; }
.lnk { display: inline-flex; align-items: center; gap: 4px; font-size: .82rem; font-weight: 600; }
.lnk.code { color: rgba(255,255,255,.82); }
.lnk.code:hover { color: #fff; }
.lnk.read { color: #7fe0d4; }
.arr { flex: none; }
.card.featured { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* Copy-link buttons + deep-link scroll offset (clears the fixed masthead) */
.card, .sec-head h2, .archive { scroll-margin-top: calc(var(--mast-h) + 14px); }
.copy { position: relative; display: inline-grid; place-items: center; cursor: pointer; border: 0;
  background: none; color: inherit; padding: 4px; border-radius: 6px; line-height: 0; }
.card .copy { position: absolute; top: 8px; right: 8px; z-index: 3; width: 30px; height: 30px; padding: 0;
  color: #fff; background: rgba(9,15,17,.55); opacity: 0; transition: opacity .15s ease, background .15s ease; }
.card:hover .copy, .card .copy:focus-visible { opacity: 1; }
.card .copy:hover { background: rgba(9,15,17,.82); }
.sec-copy { color: var(--muted); vertical-align: middle; }
.sec-copy:hover { color: var(--accent); }
.copy.copied::after { content: "Copied"; position: absolute; top: 50%; right: calc(100% + 6px);
  transform: translateY(-50%); background: var(--text); color: var(--bg); font-size: .68rem; font-weight: 600;
  padding: 2px 7px; border-radius: 4px; white-space: nowrap; z-index: 5; }

/* Archive */
.archive { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.archive > summary { cursor: pointer; padding: 13px 16px; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 10px; color: var(--text); }
.archive > summary::-webkit-details-marker { display: none; }
.archive > summary::before { content: "▸"; color: var(--muted); }
.archive[open] > summary::before { content: "▾"; }
.archive .grid { padding: 6px 16px 16px; }

.empty-state { display: none; text-align: center; color: var(--muted); padding: 48px 16px; }
.empty-state.show { display: block; }
.empty-state button { font: inherit; margin-top: 10px; cursor: pointer; color: var(--accent);
  background: none; border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px; }
.empty-state button:hover { border-color: var(--accent); }

.foot { border-top: 1px solid var(--border); margin-top: 26px; padding: 22px 0; color: var(--muted); font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  .card, .card-img { transition: none; }
  .card:hover { transform: none; } .card:hover .card-img { transform: none; }
}
@media (max-width: 540px) {
  .grid { grid-template-columns: 1fr; }
  .filter-note { display: none; }
  .masthead__item a { margin: 0 .55rem; }
  .chip { padding: 7px 13px; }              /* larger touch target on mobile */
  .filter .wrap { gap: 8px; }
  .card .copy { opacity: .82; }             /* no hover on touch — keep it visible */
}
