:root {
  --ui-font: system-ui, "Segoe UI", sans-serif;
  --reading-font: Georgia, "DejaVu Serif", serif;
  font-family: var(--ui-font);
  color: var(--ink);
  background: var(--paper);
}

:root[data-reading-font="sans"] {
  --reading-font: Arial, "Liberation Sans", sans-serif;
}

:root[data-reading-font="rounded"] {
  --reading-font: "Trebuchet MS", Verdana, "DejaVu Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin: 0;
  line-height: 1.55;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2, h3 {
  line-height: 1.15;
}

.container {
  width: min(100% - 3rem, 72rem);
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 2;
  padding: 0.6rem 1rem;
  background: var(--surface);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: none;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--header-surface);
}

.header-inner,
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.header-inner {
  min-height: 4.75rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--heading);
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border-radius: 0.7rem;
  background: var(--brand-bg);
  color: var(--brand-ink);
  font: 700 1.25rem Georgia, serif;
}

.brand-subtitle {
  color: var(--accent);
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem 0.55rem;
}

.main-nav a {
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.main-nav a:hover,
.main-nav a[aria-current="page"] {
  background: var(--surface-hover);
  color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
  color: var(--accent);
  font-weight: 720;
  text-decoration: none;
}

.button:hover,
.button[aria-current="page"] {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.button-small {
  min-height: 2.4rem;
  font-size: 0.9rem;
}

.main-content {
  flex: 1;
  padding-block: clamp(1.5rem, 4vw, 3rem) 4rem;
}

.hero {
  position: relative;
  isolation: isolate;
  display: grid;
  min-height: 25rem;
  align-items: center;
  grid-template-columns: 3fr 2fr;
  gap: 1rem;
  overflow: hidden;
  padding: clamp(1.75rem, 5.5vw, 4.5rem);
  border-radius: 1.5rem;
  background: radial-gradient(ellipse at 90% 40%, var(--hero-glow) 0%, transparent 53%), var(--hero-bg);
  color: var(--hero-ink);
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin-bottom: 0.65rem;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: var(--hero-accent);
}

.hero h1 {
  margin-bottom: 1rem;
  font-size: clamp(2.25rem, 5.7vw, 4.65rem);
  font-weight: 800;
  letter-spacing: -0.065em;
  line-height: 1.02;
}

.hero-copy > p:not(.eyebrow) {
  max-width: 33rem;
  color: var(--hero-muted);
  font-size: clamp(1rem, 1.8vw, 1.16rem);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1.7rem;
}

.hero .button:focus-visible {
  outline-color: var(--hero-accent);
}

.button-accent {
  border-color: var(--hero-action);
  background: var(--hero-action);
  color: var(--hero-on-action);
}

.button-accent:hover {
  border-color: var(--hero-action-hover);
  background: var(--hero-action-hover);
}

.button-outline {
  border-color: var(--hero-outline);
  background: transparent;
  color: var(--hero-ink);
}

.button-outline:hover {
  background: var(--hero-hover);
}

.hero-art {
  position: relative;
  display: grid;
  width: min(100%, 24rem);
  aspect-ratio: 1;
  place-items: center;
  justify-self: end;
  color: var(--hero-accent);
}

.hero-orbit {
  position: absolute;
  inset: 11%;
  border: 1px solid var(--decor-soft);
  border-radius: 50%;
}

.hero-orbit-inner {
  inset: 20%;
  border-style: dashed;
}

.hero-book {
  width: 48%;
  filter: drop-shadow(0 0 1.5rem var(--decor-glow));
}

.hero-spark {
  position: absolute;
  line-height: 1;
}

.hero-spark-top {
  top: 16%;
  right: 16%;
  font-size: clamp(1.5rem, 4vw, 3rem);
}

.hero-spark-bottom {
  bottom: 15%;
  left: 17%;
  font-size: clamp(1.25rem, 3vw, 2rem);
}

.home-sections {
  margin-top: clamp(1.75rem, 4vw, 3rem);
}

.home-sections > h2 {
  margin-bottom: 1rem;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.card-grid-two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}

.card h2,
.card h3 {
  margin-bottom: 0.5rem;
  color: var(--ink);
  font-size: 1.24rem;
}

.card p {
  color: var(--muted);
}

.linked-card {
  position: relative;
  display: block;
  height: 100%;
  padding-right: 3.25rem;
  text-decoration: none;
}

.linked-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-hover);
}

.card-arrow {
  position: absolute;
  top: 1rem;
  right: 1.15rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.page-heading {
  max-width: 48rem;
  margin-bottom: 1.6rem;
}

.page-heading h1 {
  margin-bottom: 0.6rem;
  font-size: clamp(2rem, 6vw, 3.7rem);
  letter-spacing: -0.055em;
  overflow-wrap: anywhere;
}

.page-heading > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.08rem;
}

.article-list {
  display: grid;
  max-width: 48rem;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.empty-state {
  max-width: 48rem;
}

.empty-state .button {
  margin-top: 1rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  text-underline-offset: 0.2em;
}

.reading-page {
  width: min(100%, 76ch);
  margin-inline: auto;
  padding: clamp(1rem, 5vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}

.reading-text {
  color: var(--ink);
  font-family: var(--reading-font);
  font-size: clamp(1.05rem, 2vw, 1.2rem);
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.reading-text p + p {
  margin-top: 1em;
}

.reading-page > .back-link {
  margin-top: 1.4rem;
  margin-bottom: 0;
}

.auth-grid {
  align-items: start;
  max-width: 58rem;
}

.auth-form {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.auth-form label {
  display: grid;
  gap: 0.3rem;
  font-weight: 650;
}

.auth-form input:not([type="hidden"]) {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--input-line);
  border-radius: 0.55rem;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
}

.auth-form button {
  font-family: inherit;
  cursor: pointer;
}

.auth-form button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

.card .auth-error {
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--error-bg);
  color: var(--error-ink);
}

.site-footer {
  padding-block: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 45rem) {
  .header-inner {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding-block: 0.7rem;
  }

  .main-nav {
    order: 1;
    width: 100%;
    justify-content: flex-start;
  }

  .hero {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .hero-art {
    position: absolute;
    top: -1rem;
    right: -1rem;
    z-index: -1;
    width: min(50%, 14rem);
    opacity: 0.32;
  }

  .card-grid,
  .card-grid-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 30rem) {
  .container {
    width: calc(100% - 1.5rem);
  }

  .hero {
    padding: 1.4rem 1rem;
  }

  .main-nav a {
    padding-inline: 0.35rem;
  }
}

.main-content:focus {
  outline: none;
}

.site-header {
  position: relative;
}

.page-loading .site-header::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--accent);
  content: "";
}

@media (prefers-reduced-motion: no-preference) {
  .page-enter {
    animation: page-enter 220ms ease-out;
  }

  .page-loading .site-header::after {
    animation: page-loading 240ms ease-out both;
    transform-origin: left;
  }

  .button,
  .linked-card,
  .main-nav a {
    transition: background-color 160ms ease-out, border-color 160ms ease-out;
  }
}

@keyframes page-enter {
  from {
    opacity: 0.5;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes page-loading {
  from {
    transform: scaleX(0.08);
  }
  to {
    transform: scaleX(0.75);
  }
}

/* Native controls, selection and scrolling follow the same palette as the page. */
:root {
  scrollbar-color: var(--scroll-thumb) var(--paper);
}

* {
  scrollbar-color: var(--scroll-thumb) var(--paper);
}

::selection {
  background: var(--selection-bg);
  color: var(--selection-ink);
}

input::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  caret-color: var(--ink);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--paper);
}

::-webkit-scrollbar-thumb {
  border: 3px solid var(--paper);
  border-radius: 12px;
  background: var(--scroll-thumb);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--line-strong);
}
