:root {
  --bg: #f4f4f5;
  --card-bg: #ffffff;
  --text: #1c1c1e;         /* headings */
  --text-body: #3a3a3c;    /* long-form body copy */
  --text-muted: #6b6b72;   /* meta, captions, secondary */
  --border: #e6e6e9;
  --accent: #2f6fed;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07);
  --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.14);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Hero ---------- */

.hero {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 20px 8px;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 300;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

.hero .role {
  font-size: 1.25rem;
  font-weight: 300;
  margin: 0 0 16px;
  color: var(--text-muted);
}

.hero .summary {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-body);
  margin: 0 auto;
  max-width: 60ch;
}

.social {
  margin-top: 22px;
}

.social a {
  display: inline-block;
  margin: 0 8px;
  color: var(--text);
  font-size: 22px;
  transition: color 0.2s ease, transform 0.2s ease;
}

.social a:hover {
  color: var(--accent);
  transform: translateY(-2px);
}

hr.divider {
  border: none;
  border-top: 1px solid var(--border);
  width: min(60%, 480px);
  margin: 28px auto;
}

/* ---------- Filters ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 0 20px 28px;
}

.filters button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 14px;
  background: #e9e9ec;
  color: var(--text-body);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.filters button:hover {
  background: #dedee2;
}

.filters button.active {
  background: var(--text);
  color: #fff;
}

.filters button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Card grid ---------- */

.grid {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
  border-color: #dcdce1;
}

.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #ddd;
}

.card-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ececef, #d6d6db);
  color: #a6a6ad;
  font-size: 44px;
}

.card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 20px 14px;
}

.card-meta {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.card-title {
  font-size: 1.12rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 8px;
  color: var(--text);
}

.card-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-body);
  margin: 0 0 12px;
}

.card-links {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  padding: 7px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  text-decoration: none;
}

.icon-btn:hover {
  background: #f0f0f3;
  color: var(--accent);
}

/* ---------- Dialog ---------- */

dialog {
  width: min(680px, 94vw);
  max-height: 90vh;
  border: none;
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

dialog[open] {
  animation: dialog-in 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}

.dialog-heading h2 {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
  color: var(--text);
}

.dialog-meta {
  margin: 5px 0 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dialog-close {
  flex: none;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.dialog-close:hover {
  background: #ececef;
  color: var(--text);
}

.dialog-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dialog-body {
  padding: 20px 24px 30px;
  overflow-y: auto;
  max-height: calc(90vh - 74px);
}

.dialog-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 10px;
  display: block;
  background: #000;
}

img.dialog-media {
  object-fit: cover;
  background: #ddd;
}

/* ---------- Dialog: YouTube click-to-play facade ---------- */

.yt-facade {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}

.yt-facade .yt-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.yt-facade .yt-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 68px;
  height: 48px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.65);
  transition: background 0.15s ease, transform 0.15s ease;
}

.yt-facade .yt-play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-40%, -50%);
  border-style: solid;
  border-width: 11px 0 11px 19px;
  border-color: transparent transparent transparent #fff;
}

.yt-facade:hover .yt-play,
.yt-facade:focus-visible .yt-play {
  background: #f00;
  transform: scale(1.05);
}

.yt-facade:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ---------- Dialog: link pills ---------- */

.dialog-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fafafb;
  color: var(--text-body);
  text-decoration: none;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.pill i {
  font-size: 12px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #f4f8ff;
}

.pill:hover i {
  color: var(--accent);
}

/* ---------- Dialog: prose ---------- */

.dialog-body p {
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-body);
  margin: 18px 0 0;
}

.dialog-body p.lede {
  font-size: 17.5px;
  line-height: 1.6;
  color: var(--text);
  margin-top: 22px;
}

.list-title {
  font-weight: 600;
  color: var(--text) !important;
  margin: 20px 0 2px !important;
  font-size: 15px !important;
}

.body-list {
  margin: 8px 0 0;
  padding-left: 22px;
}

.body-list li {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-body);
  margin-top: 7px;
}

/* ---------- Dialog: figures ---------- */

figure.fig {
  margin: 22px 0 0;
}

.dialog-body img.inline,
.dialog-body video.inline {
  width: 100%;
  border-radius: 10px;
  display: block;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
}

/* Diagrams on white backgrounds read as framed panels, not floating images. */
.dialog-body img.inline.framed {
  box-shadow: none;
  border: 1px solid var(--border);
  background: #fbfbfc;
  padding: 14px;
}

figure.fig figcaption {
  margin-top: 9px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
}

footer {
  text-align: center;
  padding: 0 20px 36px;
  font-size: 13px;
  color: #9a9aa0;
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .social a,
  dialog[open] {
    transition: none;
    animation: none;
  }
}
