/* The Book of Brian — refreshed layout
   Goals: better readability, mobile-first, accessible, tasteful fun. */

:root{
  --bg: #0b1020;
  --bg2: #090c16;
  --surface: rgba(255,255,255,.06);
  --surface2: rgba(255,255,255,.08);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.72);
  --border: rgba(255,255,255,.12);
  --accent: #ffd479;
  --accent2: #8fe1ff;

  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;

  --serif: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

:root[data-theme="light"]{
  --bg: #fbfbfe;
  --bg2: #f1f3f8;
  --surface: rgba(0,0,0,.04);
  --surface2: rgba(0,0,0,.06);
  --text: rgba(0,0,0,.86);
  --muted: rgba(0,0,0,.62);
  --border: rgba(0,0,0,.12);
  --accent: #b35c00;
  --accent2: #006a8f;
  --shadow: 0 12px 30px rgba(0,0,0,.12);
}

*{ box-sizing: border-box; }

html, body{
  height: 100%;
}

body{
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  /* Single, continuous background with soft transitions (no seams). */
  background:
    radial-gradient(1200px 620px at 18% -12%, rgba(255,212,121,.18), transparent 62%),
    radial-gradient(1100px 560px at 86% 8%, rgba(143,225,255,.14), transparent 64%),
    radial-gradient(900px 520px at 50% 105%, rgba(255,255,255,.06), transparent 62%),
    linear-gradient(180deg, var(--bg) 0%, color-mix(in oklab, var(--bg) 45%, var(--bg2)) 55%, var(--bg2) 100%);
  background-attachment: fixed;
  line-height: 1.65;
  font-size: 18px;
  position: relative;
}

/* Granular noise overlay to avoid banding and remove any "hard" transitions. */
body::before{
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/></svg>");
  mix-blend-mode: overlay;
}

/* Ensure content sits above the noise overlay. */
.site-header,
.layout{
  position: relative;
  z-index: 1;
}

.container{
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

.skip-link{
  position: absolute;
  left: 12px;
  top: 12px;
  padding: .5rem .75rem;
  border-radius: 10px;
  background: var(--accent);
  color: #1b1b1b;
  font-weight: 700;
  transform: translateY(-140%);
  transition: transform .15s ease;
  z-index: 9999;
}
.skip-link:focus{
  transform: translateY(0);
  outline: none;
}

.site-header{
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  background: color-mix(in oklab, var(--bg) 75%, transparent);
  border-bottom: 1px solid var(--border);
}

.header-inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 0;
}

.brand{
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.logo{
  width: 64px;
  height: auto;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: var(--surface);
}

.brand-text h1{
  font-family: var(--serif);
  font-size: 1.55rem;
  line-height: 1.1;
  margin: 0;
  letter-spacing: .2px;
}

.tagline{
  margin: .25rem 0 0;
  color: var(--muted);
  font-size: .95rem;
  max-width: 60ch;
}

.header-actions{
  display: flex;
  gap: .5rem;
}

.btn{
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-weight: 650;
  box-shadow: none;
}
.btn:hover{
  background: var(--surface2);
}
.btn:focus{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn .icon{ font-size: 1rem; }
.btn .btn-label{ font-size: .9rem; }

.site-nav{
  border-top: 1px solid var(--border);
}
.nav-inner{
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  padding: .5rem 0 .7rem;
}
.site-nav a{
  text-decoration: none;
  color: var(--muted);
  font-weight: 650;
  padding: .35rem .55rem;
  border-radius: 999px;
  border: 1px solid transparent;
}
.site-nav a:hover{
  color: var(--text);
  border-color: var(--border);
  background: var(--surface);
}
.site-nav a:focus{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.layout{
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
  padding: 1.25rem 0 3rem;
}

.toc{
  position: sticky;
  top: 120px;
  align-self: start;
}

.toc-card{
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.toc-title{
  margin: 0 0 .6rem;
  font-weight: 800;
  letter-spacing: .2px;
}

.toc ol{
  margin: 0;
  padding-left: 1.1rem;
}

.toc a{
  color: var(--muted);
  text-decoration: none;
}
.toc a:hover{ color: var(--text); text-decoration: underline; }
.toc-note{
  margin: .9rem 0 0;
  font-size: .9rem;
  color: var(--muted);
}

.content{
  display: grid;
  gap: 1rem;
}

.card{
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow);
}

.intro .lede{
  font-size: 1.12rem;
  margin: 0 0 .75rem;
}

h2{
  font-family: var(--serif);
  font-size: 1.65rem;
  margin: 0 0 .65rem;
  line-height: 1.2;
  letter-spacing: .2px;
  scroll-margin-top: 130px;
  cursor: pointer;
}
h2:hover{
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--accent) 70%, transparent);
  text-underline-offset: .22em;
}

p{ margin: 0 0 .9rem; }
p:last-child{ margin-bottom: 0; }

.small{
  font-size: .95rem;
  color: var(--muted);
}

.muted{ color: var(--muted); font-weight: 650; }

.big-list{
  font-size: 1.05rem;
  line-height: 1.7;
  margin: .4rem 0 0;
  padding-left: 1.25rem;
}

.big-list li{ margin-bottom: .5rem; }
.big-list li:last-child{ margin-bottom: 0; }

.proverbs{
  margin: 0;
}
.proverbs dt{
  margin-top: 1rem;
}
.proverbs dt:first-child{
  margin-top: 0;
}
.proverbs dd{
  margin: .25rem 0 0;
  padding-left: .75rem;
  border-left: 3px solid color-mix(in oklab, var(--accent2) 55%, transparent);
  color: var(--muted);
}

.proverb-cite{
  margin-top: .35rem;
  font-size: .9em;
  opacity: .85;
}


.quotes{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .75rem;
}
.quote{
  margin: 0;
  padding: .9rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--surface) 65%, transparent);
}
.quote blockquote{
  margin: 0 0 .65rem;
  font-style: italic;
}
.quote figcaption{
  color: var(--muted);
  font-size: .92rem;
}

.faq{
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .75rem .85rem;
  background: color-mix(in oklab, var(--surface) 70%, transparent);
  margin-top: .6rem;
}
.faq summary{
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker{ display: none; }
.faq summary:focus{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 10px;
}
.faq p{
  margin-top: .6rem;
  color: var(--muted);
}

.footer-card{
  text-align: center;
}
.footer-card a{
  color: var(--accent2);
  text-decoration: none;
  font-weight: 700;
}
.footer-card a:hover{
  text-decoration: underline;
}
.dot{
  margin: 0 .5rem;
  color: var(--muted);
}

.mobile-only{ display: none; }

/* Mobile */
@media (max-width: 900px){
  .layout{
    grid-template-columns: 1fr;
  }
  .toc{
    position: static;
  }
  .quotes{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px){
  body{ font-size: 17px; }
  .logo{ width: 54px; }
  .tagline{ display: none; }
  .mobile-only{ display: inline-flex; }

  .site-nav{ display: none; }
  .site-nav.open{ display: block; }

  .nav-inner{
    gap: .35rem;
    padding: .6rem 0 .8rem;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  *{ scroll-behavior: auto !important; transition: none !important; }
}
