/* theory.css */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@500;700&family=Quicksand:wght@400;600;700&display=swap');

:root{
  --ink:#2a2230;
  --muted:#6a5b73;

  --pink:#ff5faa;
  --rose:#ff9dcc;
  --blush:#ffd3e8;
  --cream:#fff7fb;

  --line:rgba(80,40,90,.12);
  --shadow: 0 24px 80px rgba(44,18,52,.22);
  --shadow2: 0 12px 26px rgba(44,18,52,.12);

  /* FULL SCREEN BOOK */
  --bookW: 98vw;
  --bookH: 86vh;

  --ease: cubic-bezier(.2,.85,.2,1);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  color:var(--ink);
  font-family:"Quicksand", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow-x:hidden;
}

/* ===== Coquette Background ===== */
.bg{ position:fixed; inset:0; pointer-events:none; z-index:-5; }
.bg--gradient{
  background:
    radial-gradient(1000px 600px at 15% 15%, rgba(255,157,204,.62), transparent 55%),
    radial-gradient(900px 520px at 85% 25%, rgba(255,211,232,.92), transparent 58%),
    radial-gradient(700px 520px at 55% 90%, rgba(255,246,239,.95), transparent 60%),
    linear-gradient(180deg, #fff 0%, #fff6fb 40%, #fff 100%);
}
.bg--lace{
  opacity:.60;
  mix-blend-mode:multiply;
  background:
    radial-gradient(circle at 10px 10px, rgba(255,95,170,.18) 1.2px, transparent 2.2px) 0 0/22px 22px,
    radial-gradient(circle at 10px 10px, rgba(120,60,130,.08) 1.2px, transparent 2.2px) 11px 11px/22px 22px;
}
.bg--bows{
  opacity:.40;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='50%25'%3E%3Cstop offset='0%25' stop-color='%23ff5faa' stop-opacity='.55'/%3E%3Cstop offset='100%25' stop-color='%23ff5faa' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='90' cy='90' r='170' fill='url(%23g)'/%3E%3Cpath d='M120 110c25-35 70-45 100-20 28 23 18 62-10 78-29 17-55-7-70-28-15 21-41 45-70 28-28-16-38-55-10-78 30-25 75-15 100 20z' fill='%23ff9dcc' fill-opacity='.45'/%3E%3Ccircle cx='220' cy='160' r='16' fill='%23fff7fb' fill-opacity='.75'/%3E%3C/svg%3E") -80px -90px/520px 520px no-repeat,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='520'%3E%3Cdefs%3E%3CradialGradient id='g' cx='50%25' cy='50%25'%3E%3Cstop offset='0%25' stop-color='%23ff9dcc' stop-opacity='.55'/%3E%3Cstop offset='100%25' stop-color='%23ff9dcc' stop-opacity='0'/%3E%3C/radialGradient%3E%3C/defs%3E%3Ccircle cx='430' cy='430' r='170' fill='url(%23g)'/%3E%3Cpath d='M330 390c25-35 70-45 100-20 28 23 18 62-10 78-29 17-55-7-70-28-15 21-41 45-70 28-28-16-38-55-10-78 30-25 75-15 100 20z' fill='%23ff5faa' fill-opacity='.25'/%3E%3Ccircle cx='430' cy='440' r='16' fill='%23fff7fb' fill-opacity='.75'/%3E%3C/svg%3E") calc(100% + 80px) calc(100% + 80px)/520px 520px no-repeat;
}
.bg--sparkle{
  opacity:.38;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.75) 1px, transparent 2px) 0 0/120px 120px,
    radial-gradient(circle at 70% 35%, rgba(255,255,255,.70) 1px, transparent 2px) 0 0/160px 160px,
    radial-gradient(circle at 55% 80%, rgba(255,255,255,.60) 1px, transparent 2px) 0 0/140px 140px;
}

/* ===== Topbar ===== */
.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; justify-content:space-between;
  gap:14px; padding:14px 16px;
  backdrop-filter: blur(12px);
  background: rgba(255, 247, 251, .76);
  border-bottom: 1px solid var(--line);
}
.leftbar{ display:flex; align-items:center; gap:12px; min-width:220px; }
.homebtn{
  display:inline-flex; align-items:center; gap:8px;
  text-decoration:none; color: rgba(42,34,48,.92);
  font-weight:900; font-size:12px;
  padding:10px 12px; border-radius:999px;
  border:1px solid rgba(255,95,170,.22);
  background: rgba(255,255,255,.80);
  box-shadow: var(--shadow2);
  transition: transform .12s var(--ease);
}
.homebtn:hover{ transform: translateY(-1px); }
.homebtn__icon{ font-size:14px; }
.homebtn__text{ letter-spacing:.2px; }

.brand{ display:flex; gap:12px; align-items:center; }
.brand__mark{
  width:44px; height:44px; border-radius:16px;
  display:grid; place-items:center;
  background: linear-gradient(135deg, #fff, var(--blush));
  border:1px solid rgba(255,95,170,.25);
  box-shadow: var(--shadow2);
  font-size:20px;
}
.brand__title{
  font-family:"Playfair Display", serif;
  font-weight:700; font-size:16px;
}
.brand__subtitle{ font-size:12px; color:var(--muted); margin-top:2px; }

.controls{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.divider{ width:1px; height:28px; background: var(--line); margin:0 4px; }
.btn{
  border:1px solid var(--line);
  background: rgba(255,255,255,.80);
  color: var(--ink);
  box-shadow: var(--shadow2);
  border-radius: 999px;
  padding: 10px 12px;
  display:flex; gap:8px; align-items:center;
  cursor:pointer; user-select:none;
  transition: transform .12s var(--ease), box-shadow .12s var(--ease);
}
.btn:hover{ transform: translateY(-1px); }
.btn:active{ transform: translateY(0px) scale(.98); box-shadow: 0 8px 18px rgba(44,18,52,.10); }
.btn--primary{ background: linear-gradient(135deg, #fff, var(--blush)); border-color: rgba(255,95,170,.25); }
.btn--ghost{ background: rgba(255,255,255,.62); }
.btn__icon{ font-size:16px; line-height:0; }
.btn__text{ font-weight:900; font-size:12px; letter-spacing:.2px; }

/* ===== Stage ===== */
.stage{ padding:18px 10px 34px; display:grid; place-items:center; }
.book-area{ width: var(--bookW); max-width: var(--bookW); }
.book-shell{ position:relative; padding:10px 8px 22px; }
.book-glow{
  position:absolute; left:50%; top:30px; transform: translateX(-50%);
  width: calc(var(--bookW) * .95);
  height: calc(var(--bookH) * .88);
  border-radius: 34px;
  background: radial-gradient(closest-side, rgba(44,18,52,.22), transparent 70%);
  filter: blur(14px);
  opacity:.38;
  z-index:0;
}
.book{
  position:relative;
  width: var(--bookW);
  height: var(--bookH);
  border-radius: 34px;
  z-index:1;
  perspective: 2400px;
}

/* spine */
.spine{
  position:absolute;
  left:50%; top:0;
  transform: translateX(-50%);
  width: 38px; height: 100%;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,213,232,.60)),
    linear-gradient(90deg, rgba(44,18,52,.30), rgba(44,18,52,0));
  box-shadow: inset 0 0 0 1px rgba(80,40,90,.12),
              0 18px 60px rgba(44,18,52,.16);
  z-index:6;
}

/* spread */
.spread{
  position:absolute; inset:0;
  border-radius: 34px;
  overflow:hidden;
  background: linear-gradient(135deg, rgba(255,255,255,.74), rgba(255,235,246,.70));
  border:1px solid rgba(255,95,170,.18);
  box-shadow: var(--shadow);
  transform-style: preserve-3d;
}

/* edges */
.edge{
  position:absolute; top:10px; bottom:10px; width: 12px;
  z-index:4; opacity:.72;
}
.edge--left{
  left:14px; border-radius: 10px;
  background: linear-gradient(90deg, rgba(44,18,52,.18), rgba(255,255,255,.0));
}
.edge--right{
  right:14px; border-radius: 10px;
  background: linear-gradient(270deg, rgba(44,18,52,.18), rgba(255,255,255,.0));
}

/* ===== Pages (FIX: internal scroll so text never spills) ===== */
.page{
  position:absolute; top:0; bottom:0;
  width: 50%;
  padding: 28px 26px;
  background: linear-gradient(180deg, #fff, #fff4fb);

  overflow-y: auto;
  overflow-x: hidden;

  scrollbar-width: thin;
  scrollbar-color: rgba(255,95,170,.35) transparent;
}
.page::-webkit-scrollbar{ width:6px; }
.page::-webkit-scrollbar-thumb{
  background: rgba(255,95,170,.35);
  border-radius: 10px;
}

.page--left{
  left:0;
  border-right: 1px solid rgba(80,40,90,.08);
  border-top-left-radius: 34px;
  border-bottom-left-radius: 34px;
  box-shadow: inset -14px 0 24px rgba(44,18,52,.06);
}
.page--right{
  right:0;
  border-left: 1px solid rgba(80,40,90,.08);
  border-top-right-radius: 34px;
  border-bottom-right-radius: 34px;
  box-shadow: inset 14px 0 24px rgba(44,18,52,.06);
}

/* tap zones */
.zone{
  position:absolute; top:0; bottom:0;
  width: 36%;
  z-index:12;
  background: transparent;
  border:none;
  cursor:pointer;
}
.zone--left{ left:0; }
.zone--right{ right:0; }
.zone:focus{ outline:none; }

/* drag handles */
.cornerHandle{
  position:absolute;
  width: 120px; height: 120px;
  bottom:0;
  z-index:14;
  border:none;
  background: transparent;
  cursor: grab;
}
.cornerHandle:active{ cursor: grabbing; }
.cornerHandle--br{ right:0; }
.cornerHandle--bl{ left:0; }

.corner{
  position:absolute;
  width: 86px;
  height: 86px;
  z-index:11;
  pointer-events:none;
  opacity:.75;
  filter: drop-shadow(0 10px 18px rgba(44,18,52,.14));
}
.corner--br{
  right: 0; bottom: 0;
  background: radial-gradient(closest-side at 0% 0%, rgba(255,95,170,.18), transparent 70%),
              linear-gradient(135deg, rgba(255,255,255,.0), rgba(255,255,255,.65));
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.corner--bl{
  left: 0; bottom: 0;
  background: radial-gradient(closest-side at 100% 0%, rgba(255,95,170,.18), transparent 70%),
              linear-gradient(225deg, rgba(255,255,255,.0), rgba(255,255,255,.65));
  clip-path: polygon(0 0, 100% 100%, 0 100%);
}

/* ===== Turnsheet (curl overlay) ===== */
.turnsheet{
  position:absolute;
  top:0; bottom:0;
  width:50%;
  transform-style: preserve-3d;
  z-index:13;
  pointer-events:none;
  opacity:0;

  --p: 0;
  --mx: 0.5;
  --my: 0.85;
  --shine: 0.2;
  --shade: 0.2;
}
.turnsheet.is-on{ opacity:1; }

.turnsheet__front, .turnsheet__back{
  position:absolute; inset:0;
  backface-visibility:hidden;
  overflow:hidden;
  background: linear-gradient(180deg, #fff, #fff4fb);
  border: 1px solid rgba(80,40,90,.08);
}

.turnsheet.mode-next{
  right:0; left:auto;
  transform-origin: left center;
}
.turnsheet.mode-next .turnsheet__front{
  border-top-right-radius: 34px;
  border-bottom-right-radius: 34px;
}
.turnsheet.mode-next .turnsheet__back{
  transform: rotateY(180deg);
  border-top-left-radius: 34px;
  border-bottom-left-radius: 34px;
}

.turnsheet.mode-prev{
  left:0; right:auto;
  transform-origin: right center;
}
.turnsheet.mode-prev .turnsheet__front{
  border-top-left-radius: 34px;
  border-bottom-left-radius: 34px;
}
.turnsheet.mode-prev .turnsheet__back{
  transform: rotateY(180deg);
  border-top-right-radius: 34px;
  border-bottom-right-radius: 34px;
}

.turnsheet__curl{
  position:absolute; inset:0;
  transform: translateZ(2px);
  opacity: calc(.22 + var(--shine));
  background:
    radial-gradient(closest-side at calc(var(--mx) * 100%) calc(var(--my) * 100%),
      rgba(255,255,255,.95), rgba(255,255,255,0) 60%),
    linear-gradient(90deg,
      rgba(255,255,255,0) 0%,
      rgba(255,255,255,.55) 48%,
      rgba(255,255,255,0) 72%);
  mix-blend-mode: screen;
}

.turnsheet__shadow{
  position:absolute; inset:-10px;
  transform: translateZ(1px);
  opacity: calc(.14 + var(--shade));
  background:
    radial-gradient(closest-side at calc(var(--mx) * 100%) calc(var(--my) * 100%),
      rgba(44,18,52,.30), rgba(44,18,52,0) 70%),
    linear-gradient(90deg,
      rgba(44,18,52,.30),
      rgba(44,18,52,0) 55%);
  filter: blur(10px);
}

/* ===== Page content ===== */
.sheet{
  display:flex;
  flex-direction:column;
  gap:12px;
  min-height: 100%;
}

.ribbonline{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
.tag{
  font-weight:900; font-size:12px; letter-spacing:.6px; text-transform:uppercase;
  color: rgba(255,95,170,.95);
  background: rgba(255,95,170,.10);
  border: 1px dashed rgba(255,95,170,.40);
  padding: 6px 10px; border-radius: 999px;
}
.pageno{
  font-weight:900; font-size:12px;
  color: rgba(80,40,90,.65);
  background: rgba(80,40,90,.06);
  border: 1px solid rgba(80,40,90,.10);
  padding: 6px 10px; border-radius: 999px;
}
.title{
  font-family:"Playfair Display", serif;
  font-weight:700;
  font-size: 30px;
  line-height:1.06;
  margin:0;
}
.subtitle{
  margin:0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}
.hr{
  height:1px; width:100%;
  background: linear-gradient(90deg, transparent, rgba(255,95,170,.35), transparent);
  margin: 4px 0 2px;
}
.grid{ display:grid; grid-template-columns:1fr; gap:10px; }
.card{
  background: rgba(255,255,255,.84);
  border: 1px solid rgba(80,40,90,.12);
  border-radius: 18px;
  padding: 12px 12px;
  box-shadow: 0 10px 24px rgba(44,18,52,.08);
}
.card h3{
  margin:0 0 8px;
  font-size: 12px;
  text-transform:uppercase;
  letter-spacing:.7px;
  color: rgba(80,40,90,.72);
}
.card p{
  margin:0 0 8px;
  font-size: 12.8px;
  line-height:1.46;
  color: rgba(42,34,48,.92);
}
.card ul{
  margin:0;
  padding-left: 18px;
  font-size: 12.8px;
  line-height:1.46;
  color: rgba(42,34,48,.92);
}
.card li{ margin: 4px 0; }
.badge{
  display:inline-flex; align-items:center; gap:6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,95,170,.22);
  background: rgba(255,95,170,.08);
  color: rgba(80,40,90,.82);
  font-weight: 900;
  font-size: 12px;
}
.footer{
  display:flex; align-items:center; justify-content:space-between;
  gap:10px; margin-top:6px;
}
.footer__note{ color: rgba(80,40,90,.62); font-size:12px; }
.footer__hearts{ color: rgba(255,95,170,.9); letter-spacing:2px; font-size:14px; }

/* HUD */
.hud{ margin-top:12px; display:flex; justify-content:center; gap:10px; flex-wrap:wrap; }
.pill{
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.74);
  border: 1px solid var(--line);
  box-shadow: var(--shadow2);
  font-size: 12px;
  font-weight: 900;
  color: rgba(42,34,48,.88);
}
.pill--muted{ font-weight:700; color: rgba(80,40,90,.70); }

/* Modal */
.modal{ position: fixed; inset:0; z-index:50; display:none; }
.modal.is-open{ display:block; }
.modal__overlay{
  position:absolute; inset:0;
  background: rgba(33, 10, 22, .35);
  backdrop-filter: blur(8px);
}
.modal__panel{
  position:absolute; left:50%; top:50%;
  transform: translate(-50%,-50%);
  width: min(820px, 92vw);
  max-height: min(80vh, 760px);
  overflow:hidden;
  border-radius: 24px;
  background: linear-gradient(180deg, #fff, #fff2f9);
  border: 1px solid rgba(255,95,170,.22);
  box-shadow: 0 30px 90px rgba(44,18,52,.30);
}
.modal__head{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(80,40,90,.10);
}
.modal__title{
  font-family:"Playfair Display", serif;
  font-weight:700;
  font-size: 18px;
}
.iconbtn{
  width: 40px;height: 40px;
  border-radius: 14px;
  border:1px solid rgba(80,40,90,.12);
  background: rgba(255,255,255,.74);
  box-shadow: var(--shadow2);
  cursor:pointer;
}
.modal__body{
  padding: 14px 16px;
  overflow:auto;
  max-height: calc(min(80vh, 760px) - 120px);
}
.modal__foot{
  padding: 12px 16px;
  border-top: 1px solid rgba(80,40,90,.10);
}
.note{ font-size:13px; color: rgba(80,40,90,.70); line-height:1.4; }
.note--small{ font-size:12px; opacity:.9; }

.toc{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.toc__item{
  border:1px solid rgba(80,40,90,.12);
  border-radius: 18px;
  background: rgba(255,255,255,.84);
  box-shadow: 0 10px 26px rgba(44,18,52,.08);
  padding: 12px 12px;
  cursor:pointer;
  transition: transform .12s var(--ease);
}
.toc__item:hover{ transform: translateY(-1px); }
.toc__k{ font-weight: 900; color: rgba(255,95,170,.95); font-size: 12px; letter-spacing:.5px; }
.toc__t{ font-weight: 900; font-size: 13px; margin-top: 4px; }
.toc__s{ font-size: 12px; color: rgba(80,40,90,.70); margin-top: 3px; line-height: 1.35; }
.help{ margin:0; padding-left: 18px; line-height: 1.5; color: rgba(42,34,48,.90); }
.help li{ margin: 7px 0; }

/* Search */
.searchInput{
  width:100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(80,40,90,.14);
  background: rgba(255,255,255,.86);
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.searchInput:focus{
  border-color: rgba(255,95,170,.45);
  box-shadow: 0 0 0 6px rgba(255,95,170,.10);
}
.searchHint{
  margin-top: 10px;
  font-size: 12px;
  color: rgba(80,40,90,.70);
}
.searchResults{
  margin-top: 14px;
  display:grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (max-width: 920px){
  .toc{ grid-template-columns: 1fr; }
  .controls .btn__text{ display:none; }
  .homebtn__text{ display:none; }
  .title{ font-size: 26px; }
}
@media (max-width: 560px){
  .page{ padding: 18px 14px; }
  .title{ font-size: 22px; }
  .subtitle, .card p, .card ul{ font-size: 12.4px; }
  .zone{ width: 42%; }
  .cornerHandle{ width: 100px; height: 100px; }
}
