/* ============================================================
   alfrednaayem.com — Ace deck system
   Design tokens lifted from the Alcanah Ace deck +
   ace.alcanah.co + ace-access admin dashboard.
   ============================================================ */

:root {
  /* palette */
  --paper: #f7f2e8;
  --paper-deep: #f1eadc;
  --ink: #151515;
  --ink-soft: #2d2b28;
  --blue: #1769ff;
  --blue-soft: #cfe2ff;
  --blue-deep: #0f4ad6;
  --muted: #5e574e;
  --muted-deep: #4d4740;
  --amber: #d97706;
  --amber-deep: #b45309;
  --green: #059669;
  --green-soft: #bde7a4;
  --yellow: #ffe28a;
  --pink: #ffc6da;
  --grid-line: rgba(21, 21, 21, 0.045);
  --line: rgba(21, 21, 21, 0.15);
  --card: rgba(255, 255, 255, 0.62);
  --card-strong: rgba(255, 255, 255, 0.78);

  /* offset shadows — never blurred */
  --shadow-xs: 3px 4px 0 rgba(0, 0, 0, 0.08);
  --shadow-sm: 4px 5px 0 rgba(0, 0, 0, 0.08);
  --shadow: 6px 7px 0 rgba(0, 0, 0, 0.10);
  --shadow-lg: 10px 12px 0 rgba(0, 0, 0, 0.12);

  /* radii — varied to avoid templated feel */
  --r-pill: 999px;
  --r-card: 18px 22px 16px 24px;
  --r-card-tight: 16px;
  --r-card-loose: 28px 22px 34px 24px;

  /* spacing */
  --space-xs: 0.4rem;
  --space-sm: 0.8rem;
  --space-md: 1.4rem;
  --space-lg: 2.4rem;
  --space-xl: 4.2rem;
  --space-2xl: 6.4rem;

  /* type */
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Courier New", ui-monospace, Menlo, Monaco, monospace;
}

/* ============================================================
   reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: hidden; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
}

/* paper grid overlay — the deck's "graph paper" feel */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, #000 0%, #000 70%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 0%, #000 70%, transparent 100%);
}

main { position: relative; z-index: 1; }
img, svg { max-width: 100%; display: block; }

/* ============================================================
   layout
   ============================================================ */
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 clamp(1.2rem, 4vw, 2.4rem);
  position: relative;
}
.wrap-narrow { max-width: 760px; }
.wrap-prose { max-width: 680px; }

.section { padding: clamp(2.4rem, 5vw, 4.2rem) 0; }
.section-tight { padding: clamp(1.6rem, 3vw, 2.4rem) 0; }

/* ============================================================
   header / nav
   ============================================================ */
.site-header {
  position: relative;
  z-index: 5;
  padding: 1.6rem 0 1.2rem;
  border-bottom: 2px solid var(--ink);
  background: var(--paper);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.6rem;
}
.site-header .header-right {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.brand {
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: -0.025em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.brand-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--blue-soft);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.12);
  display: inline-block;
  overflow: hidden;
  flex-shrink: 0;
}
.brand-dot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.brand:hover { color: var(--blue); }

.nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.nav a {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: var(--r-pill);
  border: 1.5px solid transparent;
  transition: all 0.15s ease;
}
.nav a:hover {
  color: var(--ink);
  border-color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
}
.nav a.active {
  color: var(--paper);
  background: var(--ink);
  border-color: var(--ink);
}

/* ============================================================
   typography
   ============================================================ */
.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  display: inline-block;
}
.kicker-blue { color: var(--blue); }

h1, h2, h3, h4 { color: var(--ink); margin: 0; line-height: 1.05; }

.h-display {
  font-size: clamp(2rem, 4.6vw, 3.6rem);
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.06;
  max-width: 18ch;
}
.h-display .accent {
  color: var(--blue);
  font-style: italic;
  font-weight: 850;
}

h1.page-title {
  font-size: clamp(1.8rem, 3.6vw, 2.8rem);
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.08;
  max-width: 22ch;
}
h1.page-title .accent { color: var(--blue); font-style: italic; }

h2.section-title {
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
  font-weight: 850;
  letter-spacing: -0.035em;
}

h3 {
  font-size: clamp(1.1rem, 1.5vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.025em;
}

p { color: var(--ink-soft); }
.lede {
  font-size: clamp(1.05rem, 1.5vw, 1.25rem);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 56ch;
  letter-spacing: -0.012em;
}
.muted { color: var(--muted); }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }

/* ============================================================
   pills / chips / badges
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 2px solid var(--ink);
  background: var(--card-strong);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.pill-blue { background: rgba(23, 105, 255, 0.12); border-color: var(--blue); color: var(--blue-deep); }
.pill-amber { background: rgba(217, 119, 6, 0.14); border-color: var(--amber); color: var(--amber-deep); }
.pill-green { background: rgba(5, 150, 105, 0.14); border-color: var(--green); color: var(--green); }
.pill-soft { border-width: 1.5px; padding: 4px 10px; font-size: 10.5px; }

/* ============================================================
   buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.85rem 1.6rem;
  border-radius: var(--r-pill);
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.012em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 9px 0 rgba(0, 0, 0, 0.14);
  text-decoration: none;
  color: var(--paper);
}
.btn-secondary {
  background: var(--paper);
  color: var(--ink);
}
.btn-secondary:hover {
  background: #fff;
  color: var(--ink);
}
.btn-blue {
  background: var(--blue);
  border-color: var(--ink);
  color: #fff;
}
.btn-blue:hover { color: #fff; }

/* ============================================================
   cards (the workhorse element — every list uses these)
   ============================================================ */
.card {
  position: relative;
  display: block;
  padding: clamp(1.2rem, 2vw, 1.6rem);
  background: var(--card);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 9px 0 rgba(0, 0, 0, 0.14);
  text-decoration: none;
}
.card.tilt-l { transform: rotate(-0.5deg); }
.card.tilt-r { transform: rotate(0.5deg); }
.card.tilt-l:hover { transform: rotate(-0.5deg) translate(-2px, -2px); }
.card.tilt-r:hover { transform: rotate(0.5deg) translate(-2px, -2px); }

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.card-meta time,
.card-meta .read-time {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.card-title {
  font-size: clamp(1.1rem, 1.6vw, 1.4rem);
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--ink);
  margin-bottom: 0.55rem;
}
.card-excerpt {
  font-size: 0.96rem;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 62ch;
}
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.92rem;
}
.card:hover .card-link { text-decoration: underline; text-underline-offset: 3px; }

/* big featured card (rotated, larger) */
.card-feature {
  padding: clamp(1.8rem, 3.2vw, 2.6rem);
  border-radius: var(--r-card-loose);
  border-width: 3px;
  box-shadow: var(--shadow-lg);
  background: var(--card-strong);
}
.card-feature .card-title {
  font-size: clamp(1.6rem, 3.4vw, 2.4rem);
  letter-spacing: -0.04em;
  line-height: 1.05;
}
.card-feature .card-excerpt {
  font-size: 1.08rem;
}

/* ============================================================
   grids
   ============================================================ */
.grid {
  display: grid;
  gap: clamp(1rem, 1.8vw, 1.4rem);
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-stack { grid-template-columns: 1fr; }

@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ============================================================
   repo / GitHub treatments
   ============================================================ */

/* dark strip on top of repo-linked cards */
.card--repo {
  padding: 0;
  overflow: hidden;
}
.card--repo .card-body,
.card--repo .nb-body {
  padding: clamp(1.1rem, 2vw, 1.6rem);
}

.repo-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.55rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 2.5px solid var(--ink);
  font-family: var(--font-mono);
  position: relative;
  overflow: hidden;
}
.repo-strip::before {
  /* faint terminal grain — micro-detail that signals "code" */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 5px 5px;
  pointer-events: none;
  opacity: 0.7;
}
.repo-strip > * { position: relative; z-index: 1; }
.repo-strip .repo-mark {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.repo-strip .repo-mark svg {
  width: 15px;
  height: 15px;
  color: var(--paper);
  flex-shrink: 0;
}
.repo-strip .repo-name {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--blue-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.repo-strip .repo-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--paper);
  background: rgba(255, 226, 138, 0.16);
  border: 1px solid rgba(255, 226, 138, 0.45);
  padding: 2px 8px 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}
.repo-strip .repo-stars svg {
  width: 11px;
  height: 11px;
  color: var(--yellow);
  flex-shrink: 0;
}
.repo-strip .repo-stars[data-loading="true"] {
  opacity: 0.5;
}

/* notebook entry repo variant */
.nb-entry.nb-entry-repo {
  display: block;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--card-strong);
  box-shadow: var(--shadow-sm);
  margin: 0.5rem 0;
  overflow: hidden;
}
.nb-entry.nb-entry-repo:hover {
  padding-left: 0;
  background: var(--card-strong);
  transform: translate(-1px, -1px);
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.10);
}
.nb-entry.nb-entry-repo::before { display: none; }
.nb-entry.nb-entry-repo .nb-body {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 1rem;
  padding: 0.85rem 1rem;
  align-items: baseline;
}
@media (max-width: 760px) {
  .nb-entry.nb-entry-repo .nb-body {
    grid-template-columns: 1fr;
    gap: 0.3rem;
    padding: 0.85rem 0.9rem;
  }
}

/* ============================================================
   GH badge — header pill linking to GitHub
   ============================================================ */
.gh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 5px 11px 5px 9px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
}
.gh-badge::before {
  /* same terminal grain as repo-strip — visual tie */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 5px 5px;
  pointer-events: none;
  opacity: 0.6;
}
.gh-badge > * { position: relative; z-index: 1; }
.gh-badge:hover {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.18);
  text-decoration: none;
  color: var(--paper);
}
.gh-badge svg {
  width: 13px;
  height: 13px;
  color: var(--paper);
}
.gh-badge .gh-handle {
  color: var(--blue-soft);
}
.gh-badge .gh-stars {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding-left: 0.45rem;
  margin-left: 0.1rem;
  border-left: 1px solid rgba(247, 242, 232, 0.25);
  color: var(--yellow);
}
.gh-badge .gh-stars svg {
  width: 11px;
  height: 11px;
  color: var(--yellow);
}
.gh-badge .gh-stars[data-loading="true"] {
  opacity: 0.5;
}

@media (max-width: 760px) {
  .gh-badge { font-size: 10px; padding: 4px 9px 4px 7px; }
  .gh-badge svg { width: 12px; height: 12px; }
}

/* ============================================================
   site footer
   ============================================================ */
.site-footer {
  margin-top: clamp(3rem, 6vw, 5rem);
  border-top: 2px solid var(--ink);
  padding: 2rem 0 2.4rem;
  background: var(--paper-deep);
  position: relative;
  z-index: 1;
}
.site-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.4rem;
  flex-wrap: wrap;
}
.site-footer .foot-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.site-footer .foot-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.site-footer .foot-links a {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink);
  padding: 6px 12px;
  border: 1.5px solid var(--ink);
  border-radius: var(--r-pill);
  text-decoration: none;
  background: var(--card);
}
.site-footer .foot-links a:hover { background: var(--ink); color: var(--paper); }

/* ============================================================
   utility
   ============================================================ */
.row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}
.stack-sm > * + * { margin-top: 0.6rem; }
.stack-md > * + * { margin-top: 1.2rem; }
.stack-lg > * + * { margin-top: 2rem; }

.dot-divider {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}

.eyebrow-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

/* simple SVG signature flourish — used as decoration */
.flourish {
  display: inline-block;
  width: 64px;
  height: 14px;
  background: var(--blue);
  border-radius: 999px;
  transform: rotate(-1.5deg);
  margin-top: 0.6rem;
}

@media (max-width: 760px) {
  .site-header .wrap { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
  .nav { gap: 0.2rem; }
  .nav a { padding: 5px 10px; font-size: 11px; }
}
