@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/cormorant-garamond.woff2") format("woff2");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: "Source Sans 3";
  src: url("../assets/fonts/source-sans-3.woff2") format("woff2");
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #f7f0e4;
  --vellum: #fffaf1;
  --aged-paper: #eee3d1;
  --ink: #29251f;
  --muted: #625647;
  --wine: #702d32;
  --wine-deep: #542127;
  --wine-tint: #f5e5e0;
  --forest: #3e5544;
  --forest-tint: #e7ece0;
  --ochre: #765728;
  --gilt: #c8a572;
  --rule: #dacbb3;
  --strong-rule: #a49070;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Source Sans 3", system-ui, sans-serif;
  --outer: clamp(18px, 5vw, 36px);
  --layout-width: 1136px;
  --study-width: 624px;
  --tap: 44px;
  font-family: var(--sans);
  font-size: 100%;
  font-weight: 400;
  line-height: 1.45;
  background-color: var(--paper);
  color: var(--ink);
}

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

body { margin: 0; min-width: 0; }
h1, h2, h3, p, figure, blockquote, dl, dd, ul { margin: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1; }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid #91682b;
  outline-offset: 3px;
}

h1[tabindex="-1"]:focus, main[tabindex="-1"]:focus { outline: none; }

.app { min-height: 100dvh; }
.app.study { background: var(--vellum); }

.skip-link {
  position: fixed;
  inset: 12px auto auto 12px;
  z-index: 20;
  background: var(--wine);
  color: var(--vellum);
  padding: 12px 16px;
  transform: translateY(-160%);
}

.skip-link:focus { transform: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  display: inline-block;
  flex: none;
  width: 22px;
  height: 22px;
  vertical-align: middle;
}

.eyebrow {
  color: var(--ochre);
  font-family: var(--sans);
  font-size: .73rem;
  font-weight: 750;
  line-height: 1.3;
  letter-spacing: .125em;
  text-transform: uppercase;
}

.page-title {
  font-size: clamp(2.65rem, 9.5vw, 4.1rem);
  letter-spacing: -.037em;
}

.page-subtitle { color: var(--muted); font-size: 1.035rem; line-height: 1.4; }

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 50px;
  min-width: var(--tap);
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 5px;
  text-decoration: none;
  font-size: 1.035rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.primary-button { background: var(--wine); color: var(--vellum); }
.primary-button:active { background: var(--wine-deep); }
.primary-button:disabled { background: #e5d7c6; color: #675a4b; cursor: default; }
.secondary-button { background: transparent; border-color: var(--strong-rule); color: var(--wine); }
.secondary-button:active { background: var(--aged-paper); }
.primary-button .icon, .secondary-button .icon { width: 19px; height: 19px; }

.icon-button {
  display: grid;
  min-width: var(--tap);
  min-height: var(--tap);
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: transparent;
  color: var(--wine);
}

.section-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 6px;
  color: var(--strong-rule);
}

.section-rule::before, .section-rule::after {
  content: "";
  height: 1px;
  flex: 1;
  background-color: var(--rule);
}

.rule-mark { width: 5px; height: 5px; transform: rotate(45deg); background: currentColor; }

.progress-bar {
  display: block;
  appearance: none;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: #e4d7c3;
  color: var(--wine);
  accent-color: var(--wine);
}

.progress-bar::-webkit-progress-bar { background-color: #e4d7c3; }
.progress-bar::-webkit-progress-value { background: var(--wine); border-radius: 6px; }
.progress-bar::-moz-progress-bar { background: var(--wine); border-radius: 6px; }

.masthead {
  background: var(--wine);
  color: var(--vellum);
  border-bottom: 1px solid #a87b50;
  padding-top: env(safe-area-inset-top);
}

.masthead-inner {
  display: flex;
  align-items: center;
  max-width: var(--layout-width);
  min-height: 68px;
  margin-inline: auto;
  padding-inline: max(var(--outer), env(safe-area-inset-left)) max(var(--outer), env(safe-area-inset-right));
  column-gap: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  gap: 11px;
  text-decoration: none;
}

.brand:focus-visible, .install-button:focus-visible { outline-color: #f3cf86; }
.brand-mark { width: 43px; height: 43px; flex: none; }

.brand-name {
  display: grid;
  gap: 2px;
  font-family: var(--serif);
  font-size: 1.78rem;
  font-weight: 700;
  line-height: .9;
  white-space: nowrap;
}

.brand-name span {
  font-family: var(--sans);
  font-size: .66rem;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: .19em;
  text-transform: uppercase;
  color: #f4dbad;
}

.install-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  gap: 7px;
  margin-left: auto;
  padding: 0 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--vellum);
  font-weight: 650;
}

.install-button .icon { width: 19px; height: 19px; }

.tab-bar {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 3px max(var(--outer), env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--outer), env(safe-area-inset-left));
  border-top: 1px solid var(--rule);
  background: var(--vellum);
  color: var(--muted);
}

.tab-link {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 58px;
  min-width: var(--tap);
  max-width: 252px;
  border-radius: 3px;
  text-decoration: none;
  font-size: .84rem;
  font-weight: 650;
}

.tab-link[aria-current="page"] { color: var(--wine); font-weight: 750; }
.tab-link[aria-current="page"]::before {
  position: absolute;
  content: "";
  top: -4px;
  left: calc(50% - 13px);
  width: 26px;
  height: 3px;
  background: var(--wine);
}

.page {
  width: 100%;
  max-width: var(--layout-width);
  margin-inline: auto;
  padding: 20px max(var(--outer), env(safe-area-inset-right)) calc(88px + env(safe-area-inset-bottom)) max(var(--outer), env(safe-area-inset-left));
}

.study-header {
  position: sticky;
  top: 0;
  z-index: 3;
  max-width: var(--study-width);
  margin-inline: auto;
  padding: calc(10px + env(safe-area-inset-top)) max(var(--outer), env(safe-area-inset-right)) 0 max(var(--outer), env(safe-area-inset-left));
  background: var(--vellum);
}

.study-header-row {
  min-height: 53px;
  display: grid;
  grid-template-columns: minmax(var(--tap), 54px) minmax(0, 1fr) minmax(var(--tap), 54px);
  align-items: center;
  gap: 8px;
}

.study-close { justify-self: start; width: var(--tap); height: var(--tap); }
.study-header-title { text-align: center; line-height: 1.2; }

.study-header-title strong {
  display: block;
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 700;
}

.study-header-title span { display: block; font-size: .87rem; color: var(--muted); }
.study-count { color: var(--wine); justify-self: end; font-size: .9rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.study-track { display: flex; gap: 5px; padding-block: 9px 10px; }
.track-segment { height: 4px; background: #e7dac5; border-radius: 4px; flex: 1; }
.track-segment.filled { background: var(--wine); }

.study-page {
  width: 100%;
  max-width: var(--study-width);
  margin-inline: auto;
  padding: 32px max(var(--outer), env(safe-area-inset-right)) calc(103px + env(safe-area-inset-bottom)) max(var(--outer), env(safe-area-inset-left));
}

.study-footer {
  position: fixed;
  inset: auto 0 0;
  z-index: 4;
  background: var(--vellum);
  border-top: 1px solid var(--rule);
}

.study-footer-inner {
  display: flex;
  max-width: var(--study-width);
  gap: 9px;
  padding: 11px max(var(--outer), env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(var(--outer), env(safe-area-inset-left));
  margin-inline: auto;
}

.study-footer .primary-button { flex: 1; }
.initial-loading { margin: 2rem auto; text-align: center; color: var(--muted); }

.app-announcements, .update-notice {
  padding: 8px var(--outer);
  background: var(--aged-paper);
  color: var(--ink);
  text-align: center;
  font-size: .96rem;
}

.update-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.update-notice .secondary-button { min-height: var(--tap); }

@media (min-width: 900px) {
  .masthead-inner { min-height: 78px; }
  .brand { gap: 12px; }
  .brand-mark { width: 48px; height: 48px; }
  .brand-name { font-size: 2rem; }
  .tab-bar {
    position: static;
    align-self: stretch;
    margin-left: auto;
    gap: 8px;
    padding: 0;
    border: 0;
    color: #f3e4cf;
    background: transparent;
  }
  .tab-link {
    flex-direction: row;
    gap: 7px;
    margin: 11px 0;
    padding: 0 15px;
    min-height: var(--tap);
    font-size: .98rem;
  }
  .tab-link .icon { width: 19px; height: 19px; }
  .tab-link[aria-current="page"] { color: var(--vellum); background: #572026; }
  .tab-link[aria-current="page"]::before { display: none; }
  .tab-link:focus-visible { outline-color: #f3cf86; }
  .install-button { margin-left: 0; }
  .page { padding-top: 34px; padding-bottom: 42px; }
  .study { border-top: 4px solid var(--wine); }
  .study-header { padding-top: 16px; }
  .study-footer-inner { padding-block: 13px; }
}

@media (max-width: 370px) {
  .reader-previous span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .reader-previous { padding-inline: 12px; }
  .study-footer .secondary-button .icon:last-child { display: none; }
  .study-footer .reader-previous .icon:first-child { display: inline-block; }
}

@media (hover: hover) {
  .primary-button:not(:disabled):hover { background: var(--wine-deep); }
  .secondary-button:not(:disabled):hover, .icon-button:hover { background: var(--aged-paper); }
  .tab-link:hover { text-decoration: underline; text-underline-offset: 3px; }
}

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

:root[data-text-size="large"] { font-size: 112.5%; }
:root[data-text-size="larger"] { font-size: 125%; }
:root[data-motion="reduced"] { scroll-behavior: auto; }
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after {
  animation-duration: .01ms !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}
@media (max-width: 899px) {
  .tab-bar { padding-right: max(4px, env(safe-area-inset-right)); padding-left: max(4px, env(safe-area-inset-left)); }
  .tab-link span { font-size: clamp(.65rem, 3.65vw, .82rem); }
}
@media (min-width: 900px) and (max-width: 1159px) {
  .tab-link { padding-inline: 8px; }
  .tab-link .icon { display: none; }
}

:root[data-keyboard] { scroll-padding-bottom: calc(var(--keyboard-inset, 0px) + 70px); }
:root[data-keyboard] .tab-bar { visibility: hidden; }
:root[data-keyboard] .study-footer { bottom: var(--keyboard-inset, 0px); }
:root[data-keyboard] .study-page { padding-bottom: calc(103px + var(--keyboard-inset, 0px)); }
.update-notice { padding-top: max(8px, env(safe-area-inset-top)); }
