:root {
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --bg-page: #F6EFE6;
  --bg-surface: #FBF7F2;
  --bg-subtle: #F2E4DC;
  --ink-primary: #2B1D1B;
  --ink-secondary: #6E524E;
  --border-light: #E4D2C8;
  --accent-sage: #629be4;
  --accent-sage-hover: #354a9e;
  --accent-warm: #D96B64;
  --accent-warm-soft: #F7DFDC;
  --thick-liquid-fill: rgba(81, 129, 225, 0.42);
  --thick-liquid-stroke: rgba(16, 84, 133, 0.34);
}

[data-theme="dark"] {
  --bg-page: #191211;
  --bg-surface: #221817;
  --bg-subtle: #2C1E1D;
  --ink-primary: #F5ECE7;
  --ink-secondary: #C4A9A3;
  --border-light: #3D2B29;
  --accent-sage: #D96B64;
  --accent-sage-hover: #E3817B;
  --accent-warm: #B84A44;
  --accent-warm-soft: #382120;
  --thick-liquid-fill: rgba(184, 74, 68, 0.24);
  --thick-liquid-stroke: rgba(217, 107, 100, 0.32);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
}

body {
  font-family: var(--font-sans);
  font-weight: 500;
  background-color: var(--bg-page);
  background-image: none;
  color: var(--ink-primary);
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

header,
main,
footer {
  position: relative;
  z-index: 1;
}

/* Header & Navbar */
.site-header,
header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background-color: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.site-header .nav-inner,
.site-header nav,
header .nav-inner,
header nav,
header .container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

header a {
  text-decoration: none;
  color: var(--ink-primary);
  font-weight: 600;
  font-size: 0.94rem;
  transition: color 180ms ease;
}

header a:hover {
  color: var(--accent-sage);
}

header a.nav-cta,
header .nav-links li:last-child a,
header ul li:last-child a {
  background-color: var(--accent-sage);
  color: #FFFFFF;
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

header a.nav-cta:hover,
header .nav-links li:last-child a:hover,
header ul li:last-child a:hover {
  background-color: var(--accent-sage-hover);
  color: #FFFFFF;
}

header .brand,
header .logo,
header .site-logo {
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

header .nav-links,
header ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

h1, h2, h3,
#readModalText {
  font-family: var(--font-serif);
  font-variation-settings: "SOFT" 100, "WONK" 0;
  letter-spacing: -0.02em;
}

h1 {
  font-weight: 800;
  line-height: 1.08;
  margin: 0 0 24px;
}

h2 {
  font-weight: 700;
  line-height: 1.15;
}

h3 {
  font-weight: 700;
}

#readModalText {
  font-weight: 600;
  line-height: 1.35;
}

.hero.clean-hero {
  grid-template-columns: 1fr;
  max-width: 68ch;
  margin: clamp(56px, 12vw, 150px) auto !important;
  padding: clamp(24px, 5vw, 40px) clamp(16px, 4vw, 24px) !important;
  text-align: center;
}

.clean-hero .hero-sub {
  font-weight: 500;
  line-height: 1.72;
  margin: 0 auto 42px;
  max-width: 48ch;
}

.clean-hero .hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

#wall {
  padding-top: clamp(24px, 4vh, 48px);
  padding-bottom: clamp(64px, 12vh, 140px);
}

.wall-header {
  margin-bottom: 24px;
}

.wall-toolbar {
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-primary,
.btn-secondary,
.btn-ghost,
.year-tab,
.page-btn,
.square-badge,
.countdown-pill {
  font-family: var(--font-sans);
  font-weight: 700;
  border-radius: 999px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background-color: var(--accent-sage);
  color: #FFFFFF;
  border: none;
  padding: 12px 22px;
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.btn-primary:hover {
  background-color: var(--accent-sage-hover);
}

.canvas-shell,
.modal,
.notice-box {
  border-radius: 24px;
  box-shadow: 0 12px 32px rgba(43, 29, 27, 0.06);
}

.canvas-shell {
  width: 100%;
  max-width: 100%;
  position: relative;
}

.search-input,
.form-control {
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: 16px;
  max-width: 100%;
}

/* Accessible Mobile Wall Grid */
.mobile-wall-grid {
  display: none;
}

.thick-liquid-frame {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.thick-liquid-frame svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes liquidFloatA {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(22px, 18px, 0) scale(1.03);
  }
}

@keyframes liquidFloatB {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(-24px, 20px, 0) scale(1.04);
  }
}

@keyframes liquidFloatC {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(16px, -22px, 0) scale(1.02);
  }
}

.liquid-blob-shape,
.liquid-thick-strand {
  will-change: transform;
  transform-box: fill-box;
  transform-origin: center;
}

.liquid-blob-shape {
  fill: var(--thick-liquid-fill);
  stroke: var(--thick-liquid-stroke);
  stroke-width: 2;
}

.liquid-thick-strand {
  fill: none;
  stroke: var(--thick-liquid-fill);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.thick-liquid-frame path:nth-child(1) {
  animation: liquidFloatA 16s ease-in-out infinite;
}

.thick-liquid-frame path:nth-child(2) {
  animation: liquidFloatC 19s ease-in-out infinite;
}

.thick-liquid-frame path:nth-child(3) {
  animation: liquidFloatB 18s ease-in-out infinite;
}

.thick-liquid-frame path:nth-child(4) {
  animation: liquidFloatA 21s ease-in-out infinite reverse;
}

.thick-liquid-frame path:nth-child(5) {
  animation: liquidFloatC 23s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .thick-liquid-frame path {
    animation: none !important;
  }
}

/* Centered Subpage & House Rules Layout */
.subpage-main,
main.container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 52px) clamp(16px, 4vw, 24px) clamp(56px, 9vw, 84px);
}

.subpage-hero,
.page-hero {
  text-align: center;
  margin: 0 auto 36px;
  max-width: 64ch;
}

.page-hero .eyebrow,
.subpage-hero .eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-sage);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.page-hero p,
.subpage-lead {
  font-size: clamp(0.96rem, 2.2vw, 1.04rem);
  line-height: 1.68;
  color: var(--ink-secondary);
  margin: 0 auto;
}

.panel-card,
.editorial-card {
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-light);
  border-top: 3px solid var(--accent-sage);
  border-radius: 24px;
  padding: clamp(20px, 4.5vw, 36px);
  box-shadow: 0 12px 32px rgba(43, 29, 27, 0.06);
}

.panel-card h2,
.editorial-card h2 {
  margin-top: 0;
  margin-bottom: 18px;
}

.rules-list,
.editorial-rules-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.rules-list li,
.editorial-rules-list li {
  padding: 16px 20px;
  border-radius: 16px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  line-height: 1.6;
}

.editorial-card-footer {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}

footer .footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  border-top: 1px solid var(--border-light);
  color: var(--ink-secondary);
  font-size: 0.9rem;
}

/* Front-Only Envelope Read Modal */
.envelope-modal {
  max-width: min(540px, calc(100vw - 24px));
  padding-top: 28px;
}

.envelope-stage {
  --envelope-accent: var(--accent-sage);
  position: relative;
  width: 100%;
  height: 410px;
  margin: 12px 0 22px;
}

.envelope-front-only {
  position: relative;
  width: 100%;
  height: 100%;
}

.envelope-back {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 215px;
  border-radius: 20px;
  background-color: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  box-shadow: 0 10px 24px rgba(43, 29, 27, 0.08);
  z-index: 1;
}

.envelope-top-band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 118px;
  height: 97px;
  border-radius: 20px 20px 0 0;
  background-color: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  border-bottom: 1.5px dashed var(--border-light);
  transform-origin: center top;
  transform: scaleY(1);
  opacity: 1;
  transition:
    transform 950ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 700ms ease;
  z-index: 7;
}

.envelope-wax-seal {
  position: absolute;
  left: 50%;
  bottom: 132px;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  border-radius: 999px;
  background-color: var(--envelope-accent);
  color: #FFFFFF;
  border: 3px solid var(--bg-surface);
  box-shadow: 0 6px 16px rgba(43, 29, 27, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transform: scale(1) rotate(0deg);
  opacity: 1;
  transition:
    transform 850ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 600ms ease 150ms;
  z-index: 7;
  pointer-events: none;
}

.envelope-stage.is-flap-open .envelope-wax-seal {
  transform: scale(1.45) rotate(28deg);
  opacity: 0;
}

.envelope-stage.is-flap-open .envelope-top-band {
  transform: scaleY(0.14);
  opacity: 0.35;
  z-index: 2;
}

.envelope-paper {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 18px;
  height: 175px;
  padding: 20px 22px 24px;
  border-radius: 16px;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-light);
  box-shadow: 0 8px 20px rgba(43, 29, 27, 0.08);
  transform: translateY(10px);
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  transition:
    transform 1050ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 250ms ease,
    visibility 0s linear 0s,
    height 1050ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 4;
}

.envelope-stage.is-paper-out .envelope-paper {
  height: auto;
  min-height: 195px;
  max-height: 255px;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 1;
  visibility: visible;
  transform: translateY(-136px);
  z-index: 8;
}

.envelope-pocket {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 124px;
  border-radius: 0 0 20px 20px;
  background-color: var(--bg-surface);
  border: 1.5px solid var(--border-light);
  border-top: 2px solid var(--envelope-accent);
  box-shadow: 0 -4px 16px rgba(43, 29, 27, 0.04);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 4px;
  z-index: 9;
  pointer-events: none;
}

.envelope-address-line {
  font-family: var(--font-serif);
  font-size: clamp(1.05rem, 3.2vw, 1.25rem);
  font-weight: 700;
  color: var(--ink-primary);
  margin: 2px 0 0;
}

.envelope-address-sub {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin: 0;
}

.envelope-paper-heading {
  margin-top: 4px;
  font-size: 1.15rem;
}

.envelope-paper-text {
  font-family: var(--font-serif);
  font-size: clamp(1.02rem, 2.6vw, 1.3rem);
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink-primary);
  margin: 10px 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

.envelope-paper-meta {
  font-size: 0.86rem;
  color: var(--ink-secondary);
  margin: 0;
}

.envelope-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--border-light);
  padding-top: 16px;
}

/* Warm Beige Footer */
.site-footer {
  position: relative;
  z-index: 2;
  background-color: var(--bg-surface);
  border-top: 1.5px solid var(--border-light);
  color: var(--ink-secondary);
  margin-top: 48px;
}

.footer-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 44px 24px 28px;
}

.footer-top {
  display: grid;
  grid-template-columns: minmax(240px, 1.5fr) repeat(2, minmax(150px, 1fr));
  gap: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-light);
}

.footer-logo {
  display: inline-block;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  text-decoration: none;
  margin-bottom: 10px;
}

.footer-tagline {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--ink-secondary);
  max-width: 38ch;
  margin: 0 0 12px;
}

.footer-contact {
  font-size: 0.9rem;
  color: var(--ink-secondary);
  margin: 0;
}

.footer-contact a {
  color: var(--ink-primary);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--border-light);
  transition: color 180ms ease, border-color 180ms ease;
}

.footer-contact a:hover {
  color: var(--accent-sage);
  border-color: var(--accent-sage);
}

.footer-heading {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-primary);
  margin: 0 0 14px;
}

.footer-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.footer-links a {
  color: var(--ink-secondary);
  font-size: 0.92rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 180ms ease;
}

.footer-links a:hover {
  color: var(--accent-sage);
}

.footer-bottom {
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

/* Tablet & Mobile Responsive Breakpoints */
@media (max-width: 768px) {
  .site-header .nav-inner,
  .site-header nav,
  header .nav-inner,
  header nav,
  header .container {
    padding: 12px 16px;
    gap: 10px;
  }

  header .nav-links,
  header ul {
    gap: 8px 12px;
    width: 100%;
    justify-content: flex-start;
  }

  header a,
  .btn-primary,
  .btn-secondary,
  .btn-ghost,
  .year-tab,
  .page-btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .hero.clean-hero {
    margin: 36px auto 28px !important;
    padding: 20px 16px !important;
  }

  .hero.clean-hero h1 {
    font-size: clamp(2rem, 8.5vw, 2.75rem);
    margin-bottom: 14px;
  }

  .clean-hero .hero-sub {
    font-size: 0.96rem;
    margin-bottom: 24px;
  }

  #wall {
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: 48px !important;
  }

  .wall-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .canvas-shell {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 14px;
    margin-bottom: 24px;
  }

  .mobile-wall-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
  }

  .mobile-sq-btn {
    min-width: 0;
    width: 100%;
    min-height: 62px;
    padding: 10px 8px;
    border-radius: 14px;
    border: 1.5px solid var(--border-light);
    background-color: var(--bg-subtle);
    color: var(--ink-primary);
    font-family: var(--font-sans);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 120ms ease, border-color 120ms ease;
  }

  .mobile-sq-btn:active {
    transform: scale(0.97);
  }

  .mobile-sq-btn.is-highlighted {
    outline: 2.5px solid var(--ink-primary);
    outline-offset: 2px;
  }

  .mobile-sq-num {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.1;
  }

  .mobile-sq-state {
    font-size: 0.76rem;
    font-weight: 600;
    opacity: 0.9;
    line-height: 1.1;
  }

  .envelope-modal {
    padding: 22px 16px 18px;
  }

  .envelope-stage {
    height: 365px;
    margin: 8px 0 16px;
  }

  .envelope-stage.is-paper-out .envelope-paper {
    transform: translateY(-118px);
    padding: 16px 16px 18px;
  }

  .site-footer {
    margin-top: 32px;
  }

  .footer-top {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .footer-container {
    padding: 36px 20px 24px;
  }
}

@media (max-width: 640px) {
  .panel-card,
  .editorial-card {
    padding: 22px 18px;
    border-radius: 20px;
  }

  .rules-list li,
  .editorial-rules-list li {
    padding: 14px 16px;
  }

  .editorial-card-footer {
    justify-content: stretch;
  }

  .editorial-card-footer .btn-primary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .envelope-top-band,
  .envelope-wax-seal,
  .envelope-paper {
    transition: none !important;
  }
}