/* ---------- Reset ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --lilac-100: #efe3f7;
  --lilac-300: #c9aee2;
  --lilac-400: #b89dd9;
  --lilac-500: #9d7fc7;
  --lilac-600: #7a5ba8;
  --lilac-700: #4a2d7a;
  --paper:      #fffdf5;
  --rule-pink:  #f0a8a8;
  --rule-lilac: #d4c4e8;
  --ink:        #2d1f4a;
  --ink-soft:   #5a3d8c;
  --ink-faint:  #8a7fa6;
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: 'Lora', Georgia, serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(ellipse 80% 60% at 18% 12%, rgba(255,255,255,0.95), transparent 60%),
    radial-gradient(ellipse 60% 40% at 82% 78%, rgba(220,200,240,0.45), transparent 55%),
    linear-gradient(135deg, #faf6fc 0%, #efe6f5 45%, #e3d6ee 100%);
  background-attachment: fixed;
}

/* Marble grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  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.65' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.55  0 0 0 0 0.45  0 0 0 0 0.65  0 0 0 0.04 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------- Stage ---------- */
.stage {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.signoff {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: var(--lilac-700);
  opacity: 0.5;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 2;
}

/* ---------- Diary ---------- */
.diary {
  position: relative;
  width: min(88vw, 360px);
  aspect-ratio: 5 / 7;
  transform: rotate(-1.5deg);
  filter:
    drop-shadow(0 22px 48px rgba(74, 45, 122, 0.32))
    drop-shadow(0 6px 14px rgba(74, 45, 122, 0.18));
  animation: diary-in 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes diary-in {
  from { opacity: 0; transform: rotate(-1.5deg) translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: rotate(-1.5deg) translateY(0)    scale(1);    }
}

/* ---------- Clip container ---------- */
.diary-book {
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden; /* clips panel so it never bleeds outside the diary */
}

/* ---------- Cover ---------- */
.diary-cover {
  position: absolute;
  inset: 0;
  border-radius: 3px 8px 8px 3px;
  background: linear-gradient(148deg, #d4b3eb 0%, #b89dd9 45%, #8a60be 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 32px 26px 34px 30px;
  overflow: hidden;
  /* Spine depth + edge highlights */
  box-shadow:
    inset 14px 0 22px -10px rgba(60, 30, 100, 0.45),
    inset  0   1px  0    rgba(255, 255, 255, 0.22),
    inset  0  -1px  0    rgba(60, 30, 100, 0.18);
}

/* Stitched border */
.diary-cover::before {
  content: '';
  position: absolute;
  inset: 10px 10px 10px 16px;
  border: 1.5px dashed rgba(255, 255, 255, 0.22);
  border-radius: 2px 6px 6px 2px;
  pointer-events: none;
  z-index: 0;
}

/* Linen texture */
.diary-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.2;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.18 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* Lift content above pseudo-elements */
.cover-head,
.cover-body,
.cover-foot { position: relative; z-index: 1; }

.cover-eyebrow {
  font-size: 10px;
  letter-spacing: 2.8px;
  text-transform: uppercase;
  font-style: italic;
  color: rgba(255, 253, 245, 0.68);
  margin-bottom: 12px;
}

.cover-title {
  font-family: 'Caveat', cursive;
  font-weight: 700;
  font-size: clamp(46px, 13vw, 66px);
  color: #fffdf5;
  line-height: 0.95;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 14px rgba(60, 30, 100, 0.28);
}

.cover-rule {
  width: 36px;
  height: 1.5px;
  background: rgba(255, 253, 245, 0.4);
  border-radius: 1px;
  margin-bottom: 12px;
}

.cover-sub {
  font-size: 13px;
  line-height: 1.65;
  color: rgba(255, 253, 245, 0.78);
  font-style: italic;
}

.try-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 253, 245, 0.14);
  color: #fffdf5;
  text-decoration: none;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 253, 245, 0.38);
  font-family: 'Lora', serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.4px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.22s, border-color 0.22s;
}
.try-btn:hover {
  background: rgba(255, 253, 245, 0.24);
  border-color: rgba(255, 253, 245, 0.6);
}

/* The main button with a quieter text link beside it: Log in or Log out. */
.cover-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
}

.cover-actions[hidden] { display: none; }

.cover-link {
  background: none;
  border: none;
  padding: 0;
  color: rgba(255, 253, 245, 0.85);
  font-family: 'Lora', serif;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.cover-link:hover { color: #fffdf5; }

/* ---------- Side tabs ---------- */
.diary-tabs {
  position: absolute;
  top: 44px;
  right: 0;
  transform: translateX(100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20;
}

.diary-tab {
  appearance: none;
  border: none;
  display: block;
  text-decoration: none;
  background: linear-gradient(160deg, var(--lilac-300) 0%, var(--lilac-500) 100%);
  color: #fffdf5;
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0.5px;
  padding: 12px 16px 12px 13px;
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
  box-shadow: 4px 3px 12px rgba(74, 45, 122, 0.22);
  transition: background 0.2s, transform 0.2s;
}
.diary-tab:hover {
  background: linear-gradient(160deg, var(--lilac-400) 0%, var(--lilac-600) 100%);
  transform: translateX(4px);
}
.diary-tab.is-active {
  background: linear-gradient(160deg, var(--lilac-500) 0%, var(--lilac-700) 100%);
  transform: translateX(8px);
  font-style: normal;
  font-weight: 500;
}

/* ---------- Panel ---------- */
.diary-panel {
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: 3px 8px 8px 3px;
  overflow: hidden;
  /* Ruled paper */
  background:
    linear-gradient(to right, transparent 0, transparent 38px, var(--rule-pink) 38px, var(--rule-pink) 40px, transparent 40px),
    repeating-linear-gradient(to bottom, transparent 0, transparent 31px, var(--rule-lilac) 31px, var(--rule-lilac) 32px),
    var(--paper);
  /* Spine depth to match cover */
  box-shadow: inset 14px 0 22px -10px rgba(60, 30, 100, 0.22);
  /* Start off-screen to the right */
  transform: translateX(105%);
  transition: transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.diary-panel.is-open {
  transform: translateX(0);
}

.panel-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 4px 8px;
  z-index: 2;
  transition: color 0.15s;
}
.panel-close:hover { color: var(--lilac-700); }

.panel-inner {
  padding: 42px 24px 24px 56px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.panel-heading {
  font-family: 'Caveat', cursive;
  font-weight: 600;
  font-size: 26px;
  color: var(--lilac-700);
  line-height: 1.1;
}

.panel-rule {
  width: 32px;
  height: 1.5px;
  background: var(--lilac-400);
  opacity: 0.7;
  border-radius: 1px;
}

/* Languages */
.lang-pair {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.lang-pill {
  background: var(--lilac-100);
  color: var(--lilac-700);
  border: 1px solid var(--rule-lilac);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}
.lang-to {
  background: var(--lilac-600);
  color: #fffdf5;
  border-color: var(--lilac-600);
}
.lang-arrow {
  font-size: 16px;
  color: var(--lilac-500);
}
.panel-note {
  font-style: italic;
  font-size: 12px;
  color: var(--ink-faint);
}

/* How it works */
.how-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.how-steps li {
  display: flex;
  gap: 13px;
  align-items: flex-start;
}
.step-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--lilac-400);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(122, 91, 168, 0.28);
}
.step-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.step-body strong {
  color: var(--lilac-700);
  font-size: 13px;
  font-weight: 500;
  display: block;
}
.step-body span {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  html, body { overflow-y: auto; }

  .stage {
    min-height: 100vh;
    height: auto;
    padding: 48px 16px 100px;
  }

  .diary {
    transform: none;
    animation: diary-in-mobile 0.7s ease both;
    width: min(90vw, 320px);
  }
  @keyframes diary-in-mobile {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Tabs move below the diary */
  .diary-tabs {
    top: 100%;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    gap: 8px;
    padding-top: 10px;
  }

  .diary-tab {
    border-radius: 0 0 8px 8px;
    padding: 10px 16px;
    box-shadow: 0 4px 10px rgba(74, 45, 122, 0.2);
  }
  .diary-tab:hover  { transform: translateY(2px); }
  .diary-tab.is-active { transform: translateY(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .diary         { animation: none; }
  .diary-panel   { transition: opacity 0.25s ease; opacity: 0; transform: none; }
  .diary-panel.is-open { opacity: 1; }
  .diary-tab, .try-btn { transition: none; }
}
