/* ===================================================
   THUNDER'S DIARY — styles
   Theme: warm white paper, soft ink colors, quiet motion
   =================================================== */

:root{
  --paper: #fdfcf7;
  --paper-edge: #f1ede2;
  --ink-default: #2b2b3d;
  --accent-purple: #7C3AED;
  --accent-purple-soft: #A78BFA;
  --accent-blue: #60A5FA;
  --line: #e4ddc9;
  --shadow: rgba(60, 45, 20, 0.18);
}

*{ box-sizing: border-box; }

html,body{
  margin:0; padding:0; height:100%;
  font-family: 'Cormorant Garamond', serif;
  background: linear-gradient(160deg, #efe7f9, #eaf2fb 60%, #fdfcf7);
  overflow: hidden;
}

.hidden{ display:none !important; }

/* ================= COVER PAGE ================= */
.cover{
  height:100vh; width:100vw;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:22px; position:relative;
}

.book{
  position:relative;
  width:min(320px, 70vw);
  height:min(440px, 70vh);
  cursor:pointer;
  transform-style:preserve-3d;
  transition: transform .9s cubic-bezier(.6,.1,.2,1);
}

.book-spine{
  position:absolute; left:-10px; top:0; bottom:0; width:20px;
  background:linear-gradient(90deg,#3d2b1f,#5a4230);
  border-radius:6px 0 0 6px;
}

.book-cover-front{
  position:relative;
  height:100%; width:100%;
  border-radius:6px 10px 10px 6px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,0.10), transparent 40%),
    linear-gradient(135deg, #4a3527, #6b4c37 55%, #503926);
  box-shadow: 0 30px 60px var(--shadow), inset 0 0 40px rgba(0,0,0,0.25);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:10px;
  border:1px solid rgba(255,255,255,0.06);
  transition: background 0.4s ease;
}

/* cover color variants, set via body[data-cover="..."] */
body[data-cover="purple"] .book-cover-front{ background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.10), transparent 40%), linear-gradient(135deg,#5b3a8a,#7C3AED 55%,#4c2e73); }
body[data-cover="blue"] .book-cover-front{ background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.10), transparent 40%), linear-gradient(135deg,#2c4a75,#60A5FA 55%,#274064); }
body[data-cover="green"] .book-cover-front{ background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.10), transparent 40%), linear-gradient(135deg,#2f4a38,#4c7a5a 55%,#264030); }

.clasp{ margin-bottom:6px; filter:drop-shadow(0 3px 4px rgba(0,0,0,.4)); }

.book-title{
  font-family:'Cormorant Garamond', serif;
  font-style:italic; font-weight:600;
  color:#f6ecd9;
  text-align:center;
  font-size:clamp(26px, 4.5vw, 36px);
  line-height:1.15;
  margin:0;
  text-shadow:0 2px 6px rgba(0,0,0,.35);
}

.book-sub{
  color:#e4d3b8; opacity:.75; font-style:italic; margin:0; font-size:15px;
}

.book.opening{ transform: rotateY(-18deg) scale(1.05); }
.book.closing{ animation: closeBook .6s ease forwards; }
@keyframes closeBook{
  0%{ transform:scale(1); opacity:1; }
  100%{ transform:scale(.92); opacity:0; }
}

.tap-hint{
  color:#6b5b7a; font-style:italic; font-size:15px; opacity:.8;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse{ 0%,100%{opacity:.5} 50%{opacity:.95} }

.wax-seal{
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%) scale(0);
  z-index:60; transition: transform .5s cubic-bezier(.34,1.56,.64,1);
}
.wax-seal.stamping{ transform:translate(-50%,-50%) scale(1); }

/* ================= ONBOARDING ================= */
.onboarding{
  position:fixed; inset:0; z-index:50;
  display:flex; align-items:center; justify-content:center;
  background: rgba(124,58,237,0.08);
  backdrop-filter: blur(6px);
}

.onboarding-card{
  width:min(420px, 88vw); max-height:88vh; overflow-y:auto;
  background: rgba(255,255,255,0.78);
  border:1px solid rgba(255,255,255,0.6);
  border-radius:24px;
  padding:34px 30px;
  box-shadow: 0 20px 50px rgba(124,58,237,0.18);
  backdrop-filter: blur(14px);
  text-align:center;
}

.onboarding-card h2{ margin:0 0 6px; font-weight:600; color:#4c3575; font-size:26px; }
.onboarding-card p{ margin:0 0 14px; color:#6b5b8a; }

#obName, #obDiaryName{
  width:100%; padding:12px 14px; border-radius:14px;
  border:1px solid var(--accent-purple-soft); font-size:17px;
  font-family:'Cormorant Garamond', serif;
  margin-bottom:16px; outline:none; background:#fff;
}
#obName:focus, #obDiaryName:focus{ border-color:var(--accent-purple); }

.choice-row{ display:flex; flex-direction:column; gap:10px; margin-bottom:16px; }
.cover-color-row{ flex-direction:row; justify-content:center; }

.choice{
  padding:11px 14px; border-radius:14px; border:1.5px solid var(--accent-purple-soft);
  background:#fff; color:#4c3575; font-size:16px; cursor:pointer;
  font-family:'Cormorant Garamond', serif;
  transition:.2s;
}
.choice.selected, .choice:hover{
  background:linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color:#fff; border-color:transparent;
}

.cover-swatch{
  width:40px; height:40px; border-radius:50%; border:2px solid #fff;
  box-shadow:0 0 0 1px rgba(0,0,0,0.15); cursor:pointer;
}
.cover-swatch.selected{ box-shadow:0 0 0 3px var(--accent-purple); }

.btn-next{
  padding:11px 26px; border-radius:16px; border:none; cursor:pointer;
  background:linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
  color:#fff; font-size:16px; font-family:'Cormorant Garamond', serif;
  box-shadow:0 8px 20px rgba(124,58,237,0.3);
}

/* ================= DIARY PAGE ================= */
.diary{ height:100vh; width:100vw; display:flex; flex-direction:column; }

.page-toolbar{
  display:flex; align-items:center; gap:8px; padding:10px 16px;
  background:rgba(255,255,255,0.6); backdrop-filter: blur(10px);
  border-bottom:1px solid var(--line); flex-wrap:wrap;
}

.ink-colors{ display:flex; gap:8px; margin-right:auto; }
.swatch{
  width:24px; height:24px; border-radius:50%; border:2px solid #fff;
  box-shadow:0 0 0 1px rgba(0,0,0,0.15); cursor:pointer;
}
.swatch.active{ box-shadow:0 0 0 2px var(--accent-purple); }

.tool-btn{
  border:none; background:rgba(124,58,237,0.08); color:#5a3d8a;
  padding:7px 12px; border-radius:12px; font-size:13px; cursor:pointer;
  font-family:'Cormorant Garamond', serif;
}
.tool-btn:hover{ background:rgba(124,58,237,0.16); }
.tool-btn.active{ background:var(--accent-purple); color:#fff; }

/* banners */
.recap-banner, .nudge-banner, .offline-banner{
  margin:8px 16px 0; padding:9px 14px; border-radius:12px;
  font-style:italic; font-size:14px; text-align:center;
}
.recap-banner{ background:rgba(167,139,250,0.15); color:#5a3d8a; }
.nudge-banner{ background:rgba(96,165,250,0.15); color:#2c4a75; }
.offline-banner{ background:rgba(178,59,59,0.12); color:#8a3535; }

.page-wrap{
  flex:1; display:flex; justify-content:center; align-items:flex-start;
  overflow-y:auto; padding:26px 16px 60px; gap:8px; position:relative;
}

.nav-arrow{
  border:none; background:rgba(124,58,237,0.08); color:#5a3d8a;
  width:38px; height:38px; border-radius:50%; font-size:20px; cursor:pointer;
  align-self:center; flex-shrink:0;
}
.nav-arrow:hover{ background:rgba(124,58,237,0.18); }
.nav-arrow:disabled{ opacity:.3; cursor:default; }

.page-flip-outer{ perspective:1600px; width:min(720px, 100%); }

.paper{
  width:100%;
  min-height:80vh;
  background: var(--paper);
  border-radius:14px;
  box-shadow:0 20px 50px rgba(80,60,30,0.12), 0 0 0 1px var(--paper-edge);
  padding:36px 34px 30px;
  position:relative;
  background-image: repeating-linear-gradient(
      to bottom, transparent 0 38px, var(--line) 38px 39px
    );
  transform-origin:left center;
  transition: transform .5s ease, opacity .5s ease;
}
.paper.flipping-out{ transform: rotateY(-85deg); opacity:0.2; }
.paper.flipping-in{ animation: flipIn .5s ease; }
@keyframes flipIn{
  from{ transform: rotateY(85deg); opacity:0.2; }
  to{ transform: rotateY(0deg); opacity:1; }
}

.handwriting{ font-family:'Caveat', cursive; }

.entry-line{
  font-family:'Cormorant Garamond', serif; font-style:italic; color:#8b7aa8;
  margin-bottom:2px; font-size:18px; min-height:24px;
}
.streak-line{
  font-family:'Cormorant Garamond', serif; font-style:italic; color:#a08bbd;
  margin-bottom:10px; font-size:13px; min-height:18px;
}

.typed-input{
  width:100%; border:none; outline:none; resize:none;
  background:transparent; font-size:26px; line-height:39px;
  color: var(--ink-default);
  transition: opacity 1.1s ease, filter 1.1s ease;
}
.typed-input.absorbing{ opacity:0.08; filter:blur(1.5px); }

.draw-canvas{
  width:100%; height:260px; touch-action:none; cursor:crosshair;
  transition: opacity 1.1s ease, filter 1.1s ease;
}
.draw-canvas.absorbing{ opacity:0.08; filter:blur(1.5px); }

.reply-area{
  font-family:'Caveat', cursive;
  font-size:29px; line-height:1.5; color: var(--accent-purple);
  min-height:40px; white-space:pre-wrap;
  transition: opacity 2.2s ease 1.5s, color .6s ease;
}
.reply-area.fading{ opacity:0; }

.thinking-dot{
  display:inline-block; width:9px; height:9px; border-radius:50%;
  background: var(--accent-purple-soft); margin-right:5px;
  animation: blot 1.2s ease-in-out infinite;
}
.thinking-dot:nth-child(2){ animation-delay:.2s; }
.thinking-dot:nth-child(3){ animation-delay:.4s; }
@keyframes blot{ 0%,100%{ transform:scale(1); opacity:.5 } 50%{ transform:scale(1.4); opacity:1 } }

.limit-note{
  margin-top:20px; font-family:'Cormorant Garamond', serif; font-style:italic;
  color:#a08bbd; font-size:14px; text-align:right;
}

/* Memory list */
.memory-list{ font-family:'Cormorant Garamond', serif; font-style:italic; color:#6b5b8a; }
.memory-list div{ padding:4px 0; border-bottom:1px dashed var(--line); cursor:pointer; }
.memory-list div:hover{ color: var(--accent-purple); }

/* Insights panel */
.insights-panel{
  position:fixed; bottom:16px; right:16px; z-index:40;
  background:rgba(255,255,255,0.85); backdrop-filter: blur(12px);
  border-radius:16px; padding:16px 20px; box-shadow:0 10px 30px rgba(124,58,237,0.2);
  font-family:'Cormorant Garamond', serif; color:#4c3575; max-width:260px;
}
.insights-panel h3{ margin:0 0 8px; font-size:18px; }
.insights-panel div{ font-size:15px; margin-bottom:4px; }

@media (max-width: 640px){
  .book{ width:78vw; height:60vh; }
  .paper{ padding:26px 20px; }
  .nav-arrow{ position:absolute; top:50%; z-index:5; }
  .nav-prev{ left:4px; } .nav-next{ right:4px; }
}
