:root {
  color-scheme: light;
  --ink: #123f46;
  --paper: #fffdf8;
  --line: rgba(255, 255, 255, .72);
  --shadow: 0 22px 60px rgba(18, 63, 70, .22);
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: #b9dfdf;
  overflow-x: hidden;
}

button, a { -webkit-tap-highlight-color: transparent; }

.storybook-backdrop {
  position: fixed;
  inset: -18px;
  z-index: -3;
  background: url("/assets/site/home-storybook.webp") center / cover no-repeat;
  transform: translate3d(var(--scene-x, 0), var(--scene-y, 0), 0) scale(1.035);
  transition: transform 900ms cubic-bezier(.2,.7,.2,1);
}

.storybook-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(238, 251, 249, .08) 0%, rgba(14, 59, 63, .06) 58%, rgba(12, 48, 49, .24) 100%),
    radial-gradient(circle at 50% 18%, rgba(255, 250, 219, .16), transparent 38%);
}

.ambient-light {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: radial-gradient(circle at var(--light-x, 50%) var(--light-y, 35%), rgba(255,255,225,.20), transparent 13%);
  opacity: .68;
  transition: opacity 700ms ease;
}

.home-shell {
  width: min(1180px, calc(100% - 48px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(34px, env(safe-area-inset-top)) 0 max(34px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 34px;
}

.site-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  width: fit-content;
  max-width: 100%;
}

.site-mark {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  filter: drop-shadow(0 9px 18px rgba(20, 72, 68, .24));
}

.site-heading h1 {
  margin: 0;
  max-width: 820px;
  color: #164a4d;
  font-size: 3rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: 0 2px 0 rgba(255,255,255,.48), 0 12px 34px rgba(255,255,255,.36);
}

.portal-grid {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: 22px;
}

.portal {
  position: relative;
  isolation: isolate;
  min-height: 285px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: white;
  text-decoration: none;
  box-shadow: var(--shadow);
  outline: none;
  transform: translateY(0);
  transition: transform 320ms ease, box-shadow 320ms ease, border-color 320ms ease;
}

.portal::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--portal-image) center / cover no-repeat;
  transform: scale(1.01);
  transition: transform 800ms cubic-bezier(.2,.7,.2,1), filter 500ms ease;
}

.portal::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(4,28,32,.02) 28%, rgba(7,34,36,.78) 100%);
}

.portal:hover,
.portal:focus-visible {
  transform: translateY(-6px);
  border-color: rgba(255,255,255,.96);
  box-shadow: 0 28px 70px rgba(15, 63, 67, .32);
}

.portal:hover::before,
.portal:focus-visible::before { transform: scale(1.055); }

.portal-copy {
  position: absolute;
  inset: auto 0 0;
  padding: 28px 30px 26px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
}

.portal-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: 0;
  text-shadow: 0 3px 18px rgba(0,0,0,.34);
}

.portal-meta {
  display: block;
  margin-top: 7px;
  color: rgba(244, 255, 250, .82);
  font-family: system-ui, sans-serif;
  font-size: .88rem;
  letter-spacing: 0;
}

.portal-arrow {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,.62);
  border-radius: 50%;
  background: rgba(15,65,67,.22);
  font: 1.4rem/1 system-ui, sans-serif;
  backdrop-filter: blur(6px);
}

@media (max-width: 720px) {
  .home-shell {
    width: min(100% - 28px, 580px);
    padding-top: max(24px, env(safe-area-inset-top));
    gap: 22px;
  }

  .site-mark { width: 46px; height: 46px; }
  .site-heading { align-items: flex-start; gap: 12px; }
  .site-heading h1 { font-size: 2.15rem; line-height: 1.25; }
  .portal-grid { align-self: stretch; align-content: end; gap: 14px; }
  .portal { min-height: 205px; }
  .portal-copy { padding: 22px 21px 20px; }
  .portal-title { font-size: 1.55rem; }
  .portal-arrow { width: 38px; height: 38px; }
}

@media (max-height: 690px) and (min-width: 721px) {
  .home-shell { gap: 20px; padding-top: 22px; }
  .site-heading h1 { font-size: 2.35rem; }
  .site-mark { width: 46px; height: 46px; }
  .portal { min-height: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
