:root {
  --ink: #202124;
  --muted: #3c4043;
  --paper: #ffffff;
  --stage: #ffbb25;
  --font: 'Google Sans', 'Google Sans Text', Helvetica, Arial, sans-serif;
  --card-radius: 28px;
  --sheet-radius: 36px;
  --flip-ms: 1000ms;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: var(--stage);
  -webkit-font-smoothing: antialiased;
}

body {
  transition: background-color 320ms ease;
}

button,
a {
  font: inherit;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app.is-open {
  overflow: hidden;
}

.app.theme-dark .top-nav,
.app.theme-dark .site-footer,
.app.theme-dark .nav-title,
.app.theme-dark .nav-link {
  color: #fff;
}

.app.theme-light .top-nav,
.app.theme-light .site-footer,
.app.theme-light .nav-title,
.app.theme-light .nav-link {
  color: var(--ink);
}

.top-nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 22px clamp(18px, 4vw, 40px) 10px;
  position: relative;
  z-index: 5;
}

.nav-link,
.nav-title {
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  padding: 8px 4px;
}

.nav-link {
  font-size: 15px;
  font-weight: 500;
}

.nav-link:first-child {
  justify-self: start;
}

.nav-link:last-child {
  justify-self: end;
}

.nav-title {
  font-size: clamp(18px, 2.4vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
}

.grid-wrap {
  flex: 1;
  padding: 12px clamp(16px, 4vw, 48px) 40px;
  transition: opacity 220ms ease;
}

.grid-wrap.is-dimmed {
  opacity: 0.18;
  pointer-events: none;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 28px);
  align-items: start;
  max-width: 1100px;
  margin: 0 auto;
}

@media (max-width: 860px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
  }
}

.recipe-card {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: pointer;
  border-radius: var(--card-radius);
  overflow: hidden;
  aspect-ratio: 1308 / 2092;
  width: 100%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  transform-origin: center center;
  transition: transform 180ms ease, box-shadow 180ms ease;
  content-visibility: auto;
  contain: layout paint;
}

@media (max-width: 860px) {
  .recipe-card {
    border-radius: 22px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .recipe-card:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.22);
  }
}

.recipe-card:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.recipe-card.is-hidden {
  visibility: hidden;
  pointer-events: none;
}

.recipe-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px clamp(18px, 4vw, 40px) 24px;
  font-size: 13px;
  opacity: 0.9;
}

.site-footer a {
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

/* Detail sheet */
.detail-shell {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: start center;
  padding: clamp(12px, 3vw, 40px);
  overflow: auto;
  pointer-events: none;
}

.detail-shell.is-live {
  pointer-events: auto;
}

.detail-sheet {
  width: min(920px, 100%);
  min-height: min(860px, calc(100vh - 48px));
  background: var(--paper);
  border-radius: var(--sheet-radius);
  position: relative;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform-origin: top left;
}

@media (max-width: 860px) {
  .detail-shell {
    padding: 10px;
  }

  .detail-sheet {
    width: 100%;
    min-height: calc(100vh - 20px);
    border-radius: 28px;
  }
}

.detail-sheet.is-visible {
  opacity: 1;
}

.detail-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 0;
  background: #202124;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.detail-fade {
  padding: clamp(28px, 5vw, 56px);
}

.detail-hero {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(20px, 4vw, 40px);
  align-items: start;
  margin-bottom: clamp(28px, 4vw, 48px);
}

@media (max-width: 760px) {
  .detail-hero {
    grid-template-columns: 1fr;
  }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.detail-hero h1 {
  margin: 0 0 18px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.tldr-label {
  margin: 0 0 6px;
  font-weight: 700;
}

.tldr-text,
.meta-row,
.detail-body p,
.detail-body li {
  color: var(--muted);
}

.meta-row {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  font-size: 14px;
}

.detail-hero-media {
  border-radius: 24px;
  overflow: hidden;
  aspect-ratio: 1308 / 2092;
  max-height: 520px;
  background: #f1f3f4;
}

.detail-hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-body section + section {
  margin-top: 36px;
}

.section-kicker {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.detail-body h2 {
  margin: 0 0 12px;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.02em;
}

.detail-body ul,
.detail-body ol {
  margin: 0;
  padding-left: 1.2em;
}

.detail-body li + li {
  margin-top: 8px;
}

/* CSS 3D stunt double */
.flip-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  perspective: 1600px;
  perspective-origin: 50% 45%;
  pointer-events: none;
}

.flip-root.is-active {
  background: rgba(0, 0, 0, 0.12);
}

.flip-card {
  position: fixed;
  top: 0;
  left: 0;
  transform-style: preserve-3d;
  transform-origin: center center;
  will-change: transform, border-radius;
  contain: layout style;
}

.flip-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-face-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flip-face-back {
  background: var(--paper);
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.flip-card.is-animating {
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.3);
}

/* Dialogs */
.overlay-dialog {
  border: 0;
  padding: 0;
  background: rgba(20, 24, 28, 0.45);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  z-index: 60;
}

.overlay-dialog[open] {
  display: grid;
  place-items: center;
}

.dialog-card {
  width: min(480px, calc(100vw - 32px));
  background: #fff;
  border-radius: 28px;
  padding: 36px 28px 28px;
  position: relative;
}

.dialog-card h2 {
  margin: 0 0 10px;
  font-size: 28px;
}

.dialog-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.share-action {
  margin-top: 18px;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: #1a73e8;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .recipe-card,
  .grid-wrap,
  body {
    transition: none !important;
  }
}
