/* Shared styles for the blog index and articles: same tokens, background, nav and footer as the rest of the site. */

:root {
  color-scheme: dark;
  --bg: #050506;
  --ink: #f5f5f7;
  --body: rgba(245, 245, 247, 0.8);
  --muted: rgba(245, 245, 247, 0.68);
  --faint: rgba(245, 245, 247, 0.42);
  --line: rgba(255, 255, 255, 0.14);
  --soft-line: rgba(255, 255, 255, 0.08);
  --cyan: #6de9ff;
  --mint: #62f0bd;
  --rose: #f6a4c8;
  --gold: #ffd76a;
  --violet: #a894ff;
  --accent: var(--cyan);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { max-width: 100%; overflow-x: clip; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 52% -12%, color-mix(in srgb, var(--accent) 32%, transparent), transparent 35rem),
    radial-gradient(ellipse at 10% 22%, rgba(246,164,200,0.15), transparent 34rem),
    radial-gradient(ellipse at 92% 18%, rgba(98,240,189,0.16), transparent 32rem),
    linear-gradient(180deg, #0b0c10 0%, #07080c 36rem, var(--bg) 72rem, #08090d 100%);
  background-color: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

nav, main, footer { position: relative; z-index: 1; }
a { color: inherit; }
img, video { display: block; max-width: 100%; }

/* ---- Ambient background (matches landing) ---- */

.site-nebula {
  position: fixed;
  inset: -18% -12%;
  z-index: 0;
  background:
    conic-gradient(from 225deg at 48% 26%, transparent 0deg, rgba(109,233,255,0.2) 42deg, rgba(98,240,189,0.12) 82deg, transparent 132deg, rgba(168,148,255,0.17) 194deg, rgba(246,164,200,0.15) 244deg, transparent 320deg),
    radial-gradient(ellipse at 16% 22%, rgba(109,233,255,0.22), transparent 34rem),
    radial-gradient(ellipse at 84% 18%, rgba(255,215,106,0.14), transparent 32rem),
    radial-gradient(ellipse at 74% 58%, rgba(98,240,189,0.16), transparent 36rem),
    radial-gradient(ellipse at 18% 78%, rgba(246,164,200,0.14), transparent 34rem);
  filter: blur(34px) saturate(1.42);
  opacity: 0.8;
  mix-blend-mode: screen;
  pointer-events: none;
  animation: siteNebulaMove 26s ease-in-out infinite alternate;
}

@keyframes siteNebulaMove {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1.02) rotate(-1deg); opacity: 0.62; }
  to   { transform: translate3d(1.4%, 1.3%, 0) scale(1.08) rotate(1.6deg); opacity: 0.86; }
}

.crab-nebula-bg {
  position: fixed;
  inset: -14%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
  mix-blend-mode: screen;
  mask-image: linear-gradient(180deg, transparent 0%, transparent 30%, rgba(0,0,0,0.7) 48%, black 72%, rgba(0,0,0,0.55) 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, transparent 30%, rgba(0,0,0,0.7) 48%, black 72%, rgba(0,0,0,0.55) 100%);
}

.crab-nebula-bg::before,
.crab-nebula-bg::after {
  content: "";
  position: absolute;
  inset: -8%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: saturate(1.2) contrast(1.04);
}

.crab-nebula-bg::before {
  background-image: url("../assets/nebula/web/crab-nebula-4.jpg");
  transform: scale(1.12);
  animation: crabNebulaBreathe 12s ease-in-out infinite alternate;
}

.crab-nebula-bg::after {
  background-image: url("../assets/nebula/web/crab-nebula-8.jpg");
  opacity: 0.4;
  filter: saturate(1.42) contrast(1.08) blur(6px);
  transform: scale(1.2);
  animation: crabNebulaForeground 16s ease-in-out infinite alternate;
}

@keyframes crabNebulaBreathe {
  from { opacity: 0.4; filter: saturate(1.08) contrast(1.02) blur(2px); }
  to   { opacity: 0.72; filter: saturate(1.34) contrast(1.08) blur(0); }
}

@keyframes crabNebulaForeground {
  from { opacity: 0.24; }
  to   { opacity: 0.5; }
}

/* ---- Layout ---- */

/* Same frame as the homepage so nav, content and footer never shift between pages. */
.wrap { width: min(1280px, calc(100% - 40px)); margin: 0 auto; }
.reading { max-width: 780px; margin: 0 auto; }

/* ---- Nav (same items and look on every page) ---- */

.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  padding: 14px 0;
  background: linear-gradient(180deg, rgba(14, 15, 19, 0.72), rgba(5, 5, 6, 0.52));
  border-bottom: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 18px 70px rgba(0,0,0,0.26);
  backdrop-filter: blur(26px) saturate(1.25);
  -webkit-backdrop-filter: blur(26px) saturate(1.25);
}

.nav-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); font-size: 17px; font-weight: 760; text-decoration: none;
}

.brand img { width: 35px; height: 35px; border-radius: 9px; }

.nav-links {
  display: flex; align-items: center; gap: 24px;
  margin: 0; padding: 0; list-style: none;
  color: var(--muted); font-size: 14px; font-weight: 650;
}

.nav-links a { text-decoration: none; color: var(--muted); transition: color .2s; }
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--ink); }

.nav-cta {
  white-space: nowrap;
  gap: 7px;
  min-height: 38px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 18px; border-radius: 999px; color: #050506 !important; background: var(--ink);
  box-shadow: 0 16px 44px rgba(255,255,255,0.14);
}

.nav-cta svg { width: 14px; height: 14px; flex: none; fill: currentColor; margin-top: -2px; }

/* Below iPhone SE width the full label can't sit beside the logo; keep the Apple mark + "App Store". */
@media (max-width: 374px) { .nav-cta-long { display: none; } }

/* ---- Page header ---- */

.page-head { padding: 132px 0 0; }

.eyebrow {
  display: inline-flex; align-items: center; gap: 9px; width: fit-content;
  padding: 8px 12px; border-radius: 999px;
  color: rgba(245,245,247,0.86); background: rgba(255,255,255,0.07);
  border: 1px solid var(--soft-line); font-size: 13px; font-weight: 760;
  text-decoration: none;
}

a.eyebrow:hover { background: rgba(255,255,255,0.1); }

.eyebrow::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 18px rgba(98,240,189,0.9);
}

.page-head h1 {
  margin: 22px 0 0;
  font-size: clamp(40px, 5.6vw, 66px);
  line-height: 0.96; letter-spacing: -0.5px; font-weight: 800;
  background: linear-gradient(110deg, #fff 0%, #fff 42%, rgba(109,233,255,0.92) 52%, #fff 62%, rgba(245,245,247,0.86) 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 44px rgba(255,255,255,0.12);
  animation: titleSheen 9s ease-in-out infinite;
}

@keyframes titleSheen {
  0%, 42% { background-position: 0% 50%; }
  58%, 100% { background-position: 100% 50%; }
}

.lead { margin: 18px 0 0; font-size: 18px; line-height: 1.62; color: var(--muted); max-width: 640px; }
.byline { margin: 16px 0 0; font-size: 14px; color: var(--faint); letter-spacing: 0.2px; }

/* ---- Glass surfaces ---- */

.glass {
  position: relative;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03)),
    rgba(255,255,255,0.025);
  border: 1px solid var(--line);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    inset 0 -1px 0 rgba(255,255,255,0.03),
    0 30px 90px rgba(0,0,0,0.4);
  backdrop-filter: blur(24px) saturate(1.25);
  -webkit-backdrop-filter: blur(24px) saturate(1.25);
}

/* Specular edge along the top, like light catching the rim of glass. */
.glass::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  width: 46%;
  height: 1px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55) 35%, rgba(255,255,255,0.9) 55%, color-mix(in srgb, var(--tint, var(--accent)) 70%, transparent) 80%, transparent);
  pointer-events: none;
}

/* ---- Blog index: post list ---- */

.posts {
  display: grid;
  gap: 16px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}

.post-card {
  --tint: var(--accent);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 20px;
  align-items: center;
  padding: 26px 26px 26px 30px;
  color: var(--ink);
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.post-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--tint) 46%, transparent);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.035)),
    color-mix(in srgb, var(--tint) 10%, rgba(255,255,255,0.025));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.16),
    0 30px 90px rgba(0,0,0,0.42),
    0 0 44px color-mix(in srgb, var(--tint) 14%, transparent);
}

.post-card:active { transform: translateY(0); }

.post-card h2 {
  margin: 0;
  font-size: clamp(20px, 2.4vw, 24px);
  font-weight: 760;
  line-height: 1.2;
}

.post-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.55;
}

.post-arrow {
  width: 36px;
  height: 36px;
  padding: 9px;
  border-radius: 50%;
  color: color-mix(in srgb, var(--tint) 70%, #fff);
  background: color-mix(in srgb, var(--tint) 12%, rgba(255,255,255,0.05));
  border: 1px solid color-mix(in srgb, var(--tint) 26%, var(--soft-line));
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms ease;
}

.post-card:hover .post-arrow { transform: translate(2px, -2px); }

/* ---- Articles ---- */

.article-body {
  margin-top: 40px;
  padding: clamp(24px, 5vw, 48px);
  font-size: 18px;
  line-height: 1.7;
  color: var(--body);
}

.article-body > :first-child { margin-top: 0; }
.article-body h2 {
  margin: 48px 0 14px;
  color: var(--ink);
  font-size: clamp(23px, 3vw, 28px);
  line-height: 1.2;
  font-weight: 760;
}
.article-body p { margin: 0 0 20px; }
.article-body a { color: var(--cyan); text-decoration: none; }
.article-body a:hover { text-decoration: underline; }
.article-body strong { color: var(--ink); font-weight: 650; }
.article-body ul, .article-body ol { margin: 0 0 22px; padding-left: 22px; }
.article-body li { margin-bottom: 10px; }
.article-body li::marker { color: var(--mint); }
.article-body .closer { margin-bottom: 0; color: var(--ink); font-size: 20px; font-weight: 600; line-height: 1.55; }

.article-body figure { margin: 36px 0; text-align: center; }

.article-body figure img,
.article-body figure video {
  width: 100%;
  max-width: min(360px, 100%);
  margin: 0 auto;
  border-radius: 28px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0,0,0,0.45);
}

.article-body figure.wide img,
.article-body figure.wide video { max-width: 100%; }
.article-body figure video.framed { border: none; border-radius: 40px; background: transparent; }

.article-body figcaption {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14.5px;
  font-style: italic;
  line-height: 1.5;
}

.article-body .pair { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.article-body .pair > * { flex: 1 1 240px; max-width: 320px; }
.article-body .pair img { max-width: 100%; }

.article-body .collage { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.article-body .collage img {
  width: 100%;
  max-width: none;
  aspect-ratio: 1206 / 2622;
  object-fit: cover;
  object-position: top;
  border-radius: 16px;
  box-shadow: none;
}

.article-body .placeholder {
  padding: 40px 24px;
  border: 2px dashed var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}
.article-body .placeholder b { display: block; margin-bottom: 6px; color: var(--ink); font-style: normal; }

.article-body .table-wrap { overflow-x: auto; }
.article-body table { width: 100%; margin: 28px 0; border-collapse: collapse; font-size: 16px; }
.article-body th,
.article-body td { padding: 12px 14px; border-bottom: 1px solid var(--soft-line); text-align: left; }
.article-body th { color: var(--faint); font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.article-body td:first-child { color: var(--muted); }

.back-link {
  display: inline-flex;
  margin-top: 28px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
  text-decoration: none;
}
.back-link:hover { color: var(--ink); }

/* ---- Footer ---- */

footer { padding: 44px 0 56px; margin-top: 40px; color: var(--faint); font-size: 14px; }
.footer-inner { display: flex; justify-content: space-between; gap: 18px; padding-top: 24px; border-top: 1px solid var(--soft-line); }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--ink); }

a:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

/* Eight nav items need ~920px; below that, collapse to logo + App Store button. */
@media (max-width: 940px) {
  .nav-links li:not(:last-child) { display: none; }
}

@media (max-width: 720px) {
  .wrap { width: min(100% - 28px, 1280px); }
  .page-head { padding-top: 108px; }
  .post-card { grid-template-columns: minmax(0, 1fr) 32px; gap: 14px; padding: 22px 18px 22px 22px; }
  .post-arrow { width: 32px; height: 32px; padding: 8px; }
  .article-body { font-size: 17px; }
  .article-body .collage { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-nebula, .crab-nebula-bg::before, .crab-nebula-bg::after, .page-head h1 { animation: none; }
  .post-card, .post-arrow { transition: none; }
}
