/* ============================================
   Josh Comeau CSS Reset
   ============================================ */

/* 1. Use a more-intuitive box-sizing model */
*, *::before, *::after {
  box-sizing: border-box;
}

/* 2. Remove default margin */
* {
  margin: 0;
}

/* 3. Enable keyword animations */
@media (prefers-reduced-motion: no-preference) {
  html {
    interpolate-size: allow-keywords;
  }
}

body {
  /* 4. Add accessible line-height */
  line-height: 1.5;
  text-rendering: optimizeLegibility;
  /* 5. Improve text rendering */
  -webkit-font-smoothing: antialiased;
}

/* 6. Improve media defaults */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

/* 7. Inherit fonts for form controls */
input, button, textarea, select {
  font: inherit;
}

/* 8. Avoid text overflows */
p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

/* 9. Improve line wrapping */
p {
  text-wrap: pretty;
}
h1, h2, h3, h4, h5, h6 {
  text-wrap: balance;
}

/* ============================================
   Global Design Tokens & Styles
   ============================================ */

:root {
  /* Color Palette - OKLCH for perceptual uniformity */
  --color-headline: oklch(0.36 0.09 246);
  --color-paragraph: oklch(0.53 0.03 252);
  --color-background: oklch(0.995 0.01 106);
  --color-link: oklch(0.46 0.16 246);
  --color-surface: oklch(0.98 0.01 106);

  /* Typography */
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-display: var(--font-sans);
  --font-mono: ui-monospace, 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;

  /* Spacing Scale - Based on 8px grid */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Legacy support */
  --space: var(--space-sm);
  --heading-font: var(--font-display);

  /* Animation & Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  /* Large surfaces: cards, search shell, hero panels. Previously spelled
     out ad hoc (1.45rem / 1.5rem / 2rem) across listing.css and cards.css. */
  --radius-2xl: 1.45rem;
  --radius-3xl: 2rem;
  --radius-pill: 999px;

  /* Keyboard focus ring, shared by every interactive listing surface. */
  --focus-ring-width: 2px;
  --focus-ring-offset: 3px;

  /* Navbar */
  --navbar-height: 4rem;
  --navbar-blur: 16px;

  /* Editorial / Article Fonts */
  --font-serif: 'Georgia', 'Times New Roman', serif;
  --font-display-editorial: 'Cormorant Garamond', 'Georgia', serif;

  /* Astrophotography palette */
  --color-astro-bg: oklch(0.057 0.025 268);
  --color-astro-text: oklch(0.86 0.03 255);
  --color-astro-muted: oklch(0.6 0.06 255);
  --color-astro-accent: oklch(0.68 0.18 213);
  --color-astro-glow: oklch(0.58 0.16 285);

  /* Recipe palette */
  --recipe-headline: oklch(0.3 0.05 45);
  --recipe-accent: oklch(0.62 0.14 50);
  --recipe-accent-light: oklch(0.94 0.04 62);
  --recipe-accent-dark: oklch(0.46 0.13 44);
}

/* Base Styles */
html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-optical-sizing: auto;
  font-weight: 300;
  background-color: var(--color-background);
  color: var(--color-paragraph);
}

/* Self-hosted English font subsets to avoid the Google Fonts stylesheet hop. */
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA,
    U+02BD-02C5,
    U+02C7-02CC,
    U+02CE-02D7,
    U+02DD-02FF,
    U+0304,
    U+0308,
    U+0329,
    U+1D00-1DBF,
    U+1E00-1E9F,
    U+1EF2-1EFF,
    U+2020,
    U+20A0-20AB,
    U+20AD-20C0,
    U+2113,
    U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("/assets/fonts/ibm-plex-sans-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF,
    U+0131,
    U+0152-0153,
    U+02BB-02BC,
    U+02C6,
    U+02DA,
    U+02DC,
    U+0304,
    U+0308,
    U+0329,
    U+2000-206F,
    U+20AC,
    U+2122,
    U+2191,
    U+2193,
    U+2212,
    U+2215,
    U+FEFF,
    U+FFFD;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url("/assets/fonts/cormorant-garamond-italic-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA,
    U+02BD-02C5,
    U+02C7-02CC,
    U+02CE-02D7,
    U+02DD-02FF,
    U+0304,
    U+0308,
    U+0329,
    U+1D00-1DBF,
    U+1E00-1E9F,
    U+1EF2-1EFF,
    U+2020,
    U+20A0-20AB,
    U+20AD-20C0,
    U+2113,
    U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300;
  font-display: swap;
  src: url("/assets/fonts/cormorant-garamond-italic-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF,
    U+0131,
    U+0152-0153,
    U+02BB-02BC,
    U+02C6,
    U+02DA,
    U+02DC,
    U+0304,
    U+0308,
    U+0329,
    U+2000-206F,
    U+20AC,
    U+2122,
    U+2191,
    U+2193,
    U+2212,
    U+2215,
    U+FEFF,
    U+FFFD;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/cormorant-garamond-700-latin-ext.woff2") format("woff2");
  unicode-range:
    U+0100-02BA,
    U+02BD-02C5,
    U+02C7-02CC,
    U+02CE-02D7,
    U+02DD-02FF,
    U+0304,
    U+0308,
    U+0329,
    U+1D00-1DBF,
    U+1E00-1E9F,
    U+1EF2-1EFF,
    U+2020,
    U+20A0-20AB,
    U+20AD-20C0,
    U+2113,
    U+2C60-2C7F,
    U+A720-A7FF;
}

@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/cormorant-garamond-700-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF,
    U+0131,
    U+0152-0153,
    U+02BB-02BC,
    U+02C6,
    U+02DA,
    U+02DC,
    U+0304,
    U+0308,
    U+0329,
    U+2000-206F,
    U+20AC,
    U+2122,
    U+2191,
    U+2193,
    U+2212,
    U+2215,
    U+FEFF,
    U+FFFD;
}

/* Focus Visible Styles */
:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 2px;
}

/* Skip link: the first focusable thing on every page, visually hidden until
   it takes focus. Without it a keyboard user tabs the brand, the menu toggle
   and every nav link before reaching content, on every page. It is clipped
   rather than display:none / visibility:hidden, both of which would take it
   out of the focus order and defeat the point. */
.skip-link {
  position: absolute;
  inset-inline-start: var(--space-md);
  inset-block-start: var(--space-md);
  z-index: 1000;
  padding: 0.75rem 1.15rem;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-link);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(calc(-100% - var(--space-md) - 1rem));
  transition: transform var(--transition-fast);
}

/* :focus, not :focus-visible. A skip link is only ever reached by keyboard,
   so there is no mouse-focus ring to suppress, and :focus-visible's heuristic
   does not match programmatic focus - which would leave the link hidden for
   anything that focuses it directly. */
.skip-link:focus {
  transform: translateY(0);
  /* Only while shown: parked above the viewport, the shadow's blur still
     reached down into the top of the page as a grey smudge by the brand. */
  box-shadow: 0 10px 30px oklch(0 0 0 / 0.16);
}

/* The skip target itself should never draw a focus ring: focus lands there
   programmatically via the link, not by tabbing. */
#main-content:focus {
  outline: none;
}

/* Selection Styles */
::selection {
  background-color: oklch(0.71 0.16 246 / 0.2);
  color: var(--color-headline);
}

/* Shared shape for the pill-style CTA links/buttons defined independently
   in home.css and recipe-print.css; each keeps its own
   padding, gap, colors, transitions, and hover treatment. */
.home-hero__action,
.recipe-print-toolbar__back,
.recipe-print-toolbar__button,
.recipe-print-card__link {
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-decoration: none;
}

/* When they prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Navbar
   ============================================ */

.site-header {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: var(--navbar-height);
  z-index: 100;
  background: oklch(0.995 0.01 106.42 / 0.95);
}

.navbar {
  position: relative;
  block-size: 100%;
}

.navbar__glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(to bottom, oklch(0.995 0.01 106.42), transparent 55%),
    oklch(1 0 106.42 / .55);
}

@supports (backdrop-filter: blur(var(--navbar-blur))) {
  .site-header {
    background: transparent;
  }

  .navbar__glass {
    -webkit-backdrop-filter: blur(var(--navbar-blur));
    backdrop-filter: blur(var(--navbar-blur));
    background: linear-gradient(to bottom,
        oklch(0.995 0.01 106.42),
        transparent 50%);
  }
}

@supports (mask-image: linear-gradient(black, transparent)) {
  .navbar__glass {
    block-size: 200%;
    -webkit-mask-image: linear-gradient(to bottom,
        black 0% 50%,
        transparent 50% 100%);
    mask-image: linear-gradient(to bottom,
        black 0% 50%,
        transparent 50% 100%);
  }
}

.navbar__content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  block-size: var(--navbar-height);
  padding-inline: max(1rem, 3vw);
  gap: 1rem;
}

.navbar__brand {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  color: var(--color-headline);
  text-decoration: none;
  transition: color 0.2s ease;
}

.navbar__brand:hover,
.navbar__brand:focus-visible {
  color: var(--color-link);
}

.navbar__links {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin-inline-start: auto;
  padding: 0;
}

.navbar__item {
  display: contents;
}

.navbar__link {
  display: block;
  padding: 0.625rem 1rem;
  color: oklch(0.28 0.07 255);
  font-weight: 500;
  font-size: 0.9375rem;
  line-height: 1;
  letter-spacing: 0.01em;
  text-decoration: none;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
}

.navbar__link:hover,
.navbar__link:focus-visible {
  background-color: oklch(0.95 0.02 255 / 0.5);
  color: oklch(0.25 0.08 255);
}

.navbar__toggle {
  display: none;
  place-items: center;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0.5rem;
  color: var(--color-headline);
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.navbar__toggle:hover,
.navbar__toggle:focus-visible {
  background-color: oklch(0.95 0.02 255 / 0.3);
}

.navbar__toggle svg {
  fill: currentColor;
  display: block;
}

@media (max-width: 48rem) {
  :root {
    --navbar-height: 4.5rem;
  }

  .navbar__brand {
    font-size: 1.125rem;
    letter-spacing: 0.03em;
  }

  .navbar__links {
    display: none;
  }

  .navbar__toggle {
    display: inline-grid;
  }

  .navbar__links--open {
    position: absolute;
    inset-inline: 1rem;
    inset-block-start: calc(100% + 0.5rem);
    z-index: 1000;
    display: grid;
    gap: 0.25rem;
    padding: 0.5rem;
    border: 1px solid oklch(0 0 0 / 0.08);
    border-radius: 1rem;
    background: oklch(1 0 106.42 / 0.55);
    -webkit-backdrop-filter: blur(var(--navbar-blur));
    backdrop-filter: blur(var(--navbar-blur));
    animation: slideDown 200ms cubic-bezier(0.16, 1, 0.3, 1);
  }

  .navbar__links--open .navbar__item {
    display: block;
  }

  .navbar__links--open .navbar__link {
    inline-size: 100%;
    padding: 0.875rem 1rem;
    letter-spacing: 0.005em;
    color: var(--color-headline);
  }

  .navbar__links--open .navbar__link:hover,
  .navbar__links--open .navbar__link:focus-visible {
    background-color: oklch(0.95 0.02 255 / 0.5);
    color: oklch(0.25 0.08 255);
  }
}

@media (max-width: 30rem) {
  .navbar__brand {
    font-size: 1rem;
    letter-spacing: 0.02em;
  }

  .navbar__links--open {
    inset-inline: 0.75rem;
    inset-block-start: calc(100% + 0.35rem);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-0.5rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-transparency: reduce) {
  .navbar__glass,
  .navbar__links--open {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: oklch(0.995 0.01 106.42);
  }
}

/* ============================================
   Footer
   ============================================ */

/* The footer sits at the bottom of the viewport on short pages and after the
   content on long ones: body is a column, and the page in between grows to
   fill whatever height the navbar padding and footer leave over. That's why
   the page shells (.home-shell, .posts-page, .post-page) no longer set their
   own min-height: 100svh, which pushed the footer a full screen down. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

#main-content {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
}

#main-content > * {
  flex: 1 0 auto;
}

.site-footer {
  border-block-start: 1px solid oklch(0.9 0.01 106);
  background: oklch(0.985 0.008 106);
  color: var(--color-paragraph);
  font-size: 0.875rem;
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-lg) var(--space-2xl);
  /* Same column as the home and listing pages above it. */
  max-width: 64rem;
  margin-inline: auto;
  padding: var(--space-2xl) max(1.25rem, 5vw);
}

.site-footer__about {
  display: grid;
  gap: 0.35rem;
  max-width: 34rem;
}

.site-footer__brand {
  justify-self: start;
  color: var(--color-headline);
  font-family: var(--font-display-editorial);
  font-size: 1.35rem;
  font-style: italic;
  font-weight: 700;
  text-decoration: none;
}

.site-footer__tagline {
  line-height: 1.6;
}

.site-footer__profiles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
  margin-block-start: var(--space-xs);
  padding: 0;
  list-style: none;
}

.site-footer__profile {
  color: var(--color-link);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.site-footer__profile:hover,
.site-footer__profile:focus-visible {
  color: var(--color-headline);
}

.site-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-inline-start: -0.75rem;
}

.site-footer__link {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  color: oklch(0.28 0.07 255);
  font-weight: 500;
  text-decoration: none;
  transition: background-color var(--transition-base), color var(--transition-base);
}

.site-footer__brand:hover,
.site-footer__brand:focus-visible,
.site-footer__link:hover,
.site-footer__link:focus-visible {
  color: var(--color-link);
}

.site-footer__link:hover,
.site-footer__link:focus-visible {
  background-color: oklch(0.95 0.02 255 / 0.5);
}

/* Astrophotography posts are dark top to bottom; a light footer under them
   would read as a different site. */
body:has(.post-page--astrophotography) .site-footer {
  border-block-start-color: oklch(1 0 0 / 0.08);
  background: var(--color-astro-bg);
  color: var(--color-astro-muted);
}

body:has(.post-page--astrophotography) :is(.site-footer__brand, .site-footer__link, .site-footer__profile) {
  color: var(--color-astro-text);
}

body:has(.post-page--astrophotography) .site-footer__link:hover,
body:has(.post-page--astrophotography) .site-footer__link:focus-visible {
  background-color: oklch(1 0 0 / 0.06);
  color: var(--color-astro-accent);
}

@media (min-width: 48rem) {
  .site-footer__nav {
    margin-inline-start: 0;
    margin-inline-end: -0.75rem;
  }
}

