/* ==========================================================
   FlipNote settings: panel + every switchable look / motion.
   Variants are keyed off data-* attributes on #flipnote-widget.
   ========================================================== */

/* ---------- Settings panel ---------- */
.settings-panel {
  position: absolute;
  inset: 10px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  background: #101116;
  color: #eceae4;
  border: 1px solid var(--pad-border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  transform-origin: top right;
  animation: settingsIn 0.22s var(--ease-soft, ease-out);
}

.settings-panel[hidden] {
  display: none;
}

@keyframes settingsIn {
  from { opacity: 0; transform: scale(0.94) translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-head h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--btn-cover-color);
}

.settings-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 16px 10px;
  scrollbar-width: thin;
}

.settings-group-title {
  margin: 12px 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.setting-row {
  margin: 0 0 10px;
}

.setting-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 5px;
  color: #d6d3cb;
}

.setting-hint {
  display: block;
  font-size: 11px;
  color: #8d8a82;
  margin: -2px 0 5px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d6d3cb;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.chip:hover {
  background: rgba(255, 255, 255, 0.12);
}

.chip:active {
  transform: scale(0.96);
}

.chip[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
}

.chip:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 1px;
}

.settings-reset {
  margin: 0 16px 14px;
  align-self: flex-start;
  background: transparent;
  border: none;
  color: #8d8a82;
  font-size: 11.5px;
  text-decoration: underline;
  cursor: pointer;
}

.settings-reset:hover {
  color: #eceae4;
}

html:not(.desktop) .setting-row[data-desktop-only] {
  display: none;
}

/* ---------- Float styles ---------- */
.flipnote-pad[data-float="bob"]:not(.minimized) {
  animation: padBob 3.6s ease-in-out infinite;
}

.flipnote-pad[data-float="bob"]:not(.minimized)::after {
  animation: padShadow 3.6s ease-in-out infinite;
}

@keyframes padBob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -8px; }
}

.flipnote-pad[data-float="sway"]:not(.minimized) {
  transform-origin: 50% -30px;
  animation: padSway 5.5s ease-in-out infinite;
}

.flipnote-pad[data-float="sway"]:not(.minimized)::after {
  animation: padSwayShadow 5.5s ease-in-out infinite;
}

@keyframes padSway {
  0%, 100% { rotate: -1.3deg; }
  50% { rotate: 1.3deg; }
}

@keyframes padSwayShadow {
  0%, 100% { translate: -10px 0; }
  50% { translate: 10px 0; }
}

.flipnote-pad[data-float="levitate"]:not(.minimized) {
  animation: padFloat 7.5s ease-in-out infinite;
}

.flipnote-pad[data-float="levitate"]:not(.minimized)::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: calc(var(--pad-radius) + 6px);
  box-shadow: 0 0 26px 2px var(--accent);
  opacity: 0.25;
  pointer-events: none;
  z-index: -1;
  animation: padGlow 7.5s ease-in-out infinite;
}

@keyframes padGlow {
  0%, 100% { opacity: 0.18; }
  50% { opacity: 0.5; }
}

.flipnote-pad[data-float="breathe"]:not(.minimized) {
  animation: padBreathe 6s ease-in-out infinite;
}

@keyframes padBreathe {
  0%, 100% { scale: 1; }
  50% { scale: 1.012; }
}

.flipnote-pad[data-float="off"]:not(.minimized),
.flipnote-pad[data-float="off"]:not(.minimized)::after {
  animation: none;
}

/* ---------- Page-turn styles ---------- */
.flipnote-pad[data-turn="slide"] .turning-leaf.turn-next {
  animation: leafSlideNext 0.42s var(--ease-soft) forwards;
}

.flipnote-pad[data-turn="slide"] .turning-leaf.turn-prev {
  animation: leafSlidePrev 0.42s var(--ease-soft) forwards;
}

@keyframes leafSlideNext {
  from { transform: none; opacity: 1; }
  to { transform: translateX(-60%) rotate(-4deg); opacity: 0; }
}

@keyframes leafSlidePrev {
  from { transform: translateX(-60%) rotate(-4deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.flipnote-pad[data-turn="fade"] .turning-leaf.turn-next {
  animation: leafFadeOut 0.35s ease forwards;
}

.flipnote-pad[data-turn="fade"] .turning-leaf.turn-prev {
  animation: leafFadeIn 0.35s ease forwards;
}

@keyframes leafFadeOut {
  from { opacity: 1; filter: blur(0); }
  to { opacity: 0; filter: blur(2px); }
}

@keyframes leafFadeIn {
  from { opacity: 0; filter: blur(2px); }
  to { opacity: 1; filter: blur(0); }
}

.flipnote-pad[data-turn="tear"] .turning-leaf.turn-next {
  transform-origin: 90% 0;
  animation: leafTear 0.55s cubic-bezier(0.55, 0, 0.8, 0.4) forwards;
}

@keyframes leafTear {
  0% { transform: none; opacity: 1; }
  25% { transform: rotate(-3deg) translateY(-4px); }
  100% { transform: rotate(-24deg) translate(-40px, 160%); opacity: 0; }
}

.flipnote-pad[data-turn="fade"] .turning-leaf::after,
.flipnote-pad[data-turn="slide"] .turning-leaf::after,
.flipnote-pad[data-turn="tear"] .turning-leaf::after {
  animation: none;
}

/* ---------- Pens ---------- */
.pen-rig .pen {
  display: none;
}

.flipnote-pad[data-pen="fountain"] .pen-fountain,
.flipnote-pad[data-pen="pencil"] .pen-pencil,
.flipnote-pad[data-pen="quill"] .pen-quill {
  display: block;
}

.flipnote-pad[data-pen="none"] .pen-rig {
  display: none;
}

/* The quill sways more while resting, like a feather */
.flipnote-pad[data-pen="quill"] .pen-rig:not(.writing) .pen-quill {
  animation-duration: 3.2s;
}

/* ---------- Paper styles ---------- */
.flipnote-pad[data-paper="grid"] .paper-sheet {
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.07), transparent 14px),
    linear-gradient(var(--sheet-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--sheet-line) 1px, transparent 1px);
  background-size: auto, 17px 17px, 17px 17px;
}

.flipnote-pad[data-paper="dots"] .paper-sheet {
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.07), transparent 14px),
    radial-gradient(circle, var(--sheet-line) 1.2px, transparent 1.4px);
  background-size: auto, 16px 16px;
}

.flipnote-pad[data-paper="grid"] .rule-row,
.flipnote-pad[data-paper="dots"] .rule-row,
.flipnote-pad[data-paper="plain"] .rule-row {
  border-bottom-color: transparent;
}

.flipnote-pad[data-paper="legal"] .paper-sheet {
  background-color: #fdf6b2;
  background-image:
    linear-gradient(90deg, transparent 30px, rgba(220, 38, 38, 0.35) 30px 31px, transparent 31px);
}

.flipnote-pad[data-paper="legal"] .rule-row {
  border-bottom-color: rgba(59, 130, 246, 0.35);
}

.flipnote-pad[data-paper="legal"] .rule-text,
.flipnote-pad[data-paper="legal"] .page-title-input {
  color: #1f2937;
}

/* ---------- Handwriting fonts (system fonts only: CSP allows no web fonts) ---------- */
.flipnote-pad[data-font="hand"] .rule-text,
.flipnote-pad[data-font="hand"] .page-title-input {
  font-family: "Ink Free", "Segoe Print", "Bradley Hand", "Comic Sans MS", cursive;
  font-size: 15px;
}

.flipnote-pad[data-font="serif"] .rule-text,
.flipnote-pad[data-font="serif"] .page-title-input {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

.flipnote-pad[data-font="mono"] .rule-text,
.flipnote-pad[data-font="mono"] .page-title-input {
  font-family: "Cascadia Code", Consolas, "SF Mono", monospace;
  font-size: 13px;
}

/* ---------- Ink colours ---------- */
.flipnote-pad[data-ink="blue"] .rule-text { color: #1d4ed8; }
.flipnote-pad[data-ink="green"] .rule-text { color: #166534; }
.flipnote-pad[data-ink="red"] .rule-text { color: #b91c1c; }
.flipnote-pad[data-ink="sepia"] .rule-text { color: #7c4a1e; }

.flipnote-pad[data-ink] .rule-row.done .rule-text {
  color: var(--sheet-muted);
}

/* ---------- Tick effect: a little ink burst when you complete an item ---------- */
.rule-check.tick-pop {
  animation: tickPop 0.4s var(--ease-soft, ease-out);
}

@keyframes tickPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.45) rotate(-8deg); }
  100% { transform: scale(1); }
}

.flipnote-pad[data-tick="plain"] .rule-check.tick-pop {
  animation: none;
}

/* ---------- Desktop: room for the float inside the window ---------- */
html.desktop .hero {
  padding: 22px 6px 12px;
}

html.desktop .flipnote-pad:not(.minimized)::after {
  display: block;
  bottom: -12px;
  height: 12px;
  left: 20%;
  right: 20%;
}

html.desktop .flipnote-pad[data-float="levitate"]:not(.minimized)::before {
  inset: -3px;
  box-shadow: 0 0 10px 1px var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .settings-panel {
    animation: none;
  }
}

/* Whatever the float style: hold still under the mouse, while focused or typing.
   Must come after the variants (same specificity, later wins). */
.flipnote-pad[data-float]:is(:hover, :focus-within, .is-writing),
.flipnote-pad[data-float]:is(:hover, :focus-within, .is-writing)::before,
.flipnote-pad[data-float]:is(:hover, :focus-within, .is-writing)::after {
  animation-play-state: paused;
}

/* ==========================================================
   Research batch 1 (agy, 2026-09-18)
   ========================================================== */

/* ---------- More papers ---------- */
.flipnote-pad[data-paper="parchment"] .paper-sheet {
  background-color: #f3e3bf;
  background-image:
    radial-gradient(circle at 82% 18%, rgba(139, 90, 43, 0.09), transparent 38%),
    radial-gradient(circle at 12% 88%, rgba(139, 90, 43, 0.07), transparent 30%);
  box-shadow: inset 0 0 36px rgba(110, 60, 15, 0.2), 0 10px 24px rgba(0, 0, 0, 0.18);
}

.flipnote-pad[data-paper="parchment"] .rule-row {
  border-bottom-color: rgba(120, 80, 30, 0.18);
}

.flipnote-pad[data-paper="parchment"] .rule-text,
.flipnote-pad[data-paper="parchment"] .page-title-input {
  color: #3b2410;
}

.flipnote-pad[data-paper="kraft"] .paper-sheet {
  background-color: #c9a778;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.25 0 0 0 0 0.17 0 0 0 0 0.08 0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.flipnote-pad[data-paper="kraft"] .rule-row {
  border-bottom-color: rgba(70, 45, 15, 0.22);
}

.flipnote-pad[data-paper="kraft"] .rule-text,
.flipnote-pad[data-paper="kraft"] .page-title-input,
.flipnote-pad[data-paper="kraft"] .rule-check {
  color: #2a1a08;
}

.flipnote-pad[data-paper="blueprint"] .paper-sheet {
  background-color: #0b2545;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.09) 1px, transparent 1px);
  background-size: 18px 18px;
}

.flipnote-pad[data-paper="blueprint"] .rule-row {
  border-bottom-color: rgba(255, 255, 255, 0.16);
}

.flipnote-pad[data-paper="blueprint"] .rule-text,
.flipnote-pad[data-paper="blueprint"] .page-title-input,
.flipnote-pad[data-paper="blueprint"] .rule-check {
  color: #e8f1f5;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.35);
}

.flipnote-pad[data-paper="blueprint"] .sheet-header {
  border-bottom-color: rgba(255, 255, 255, 0.25);
}

.flipnote-pad[data-paper="blueprint"] .rule-row.done .rule-text,
.flipnote-pad[data-paper="blueprint"] .add-rule-btn,
.flipnote-pad[data-paper="blueprint"] .sheet-brand {
  color: #8fb3d9;
}

/* The page-edge stack and turning leaf match the chosen paper */
.flipnote-pad[data-paper="parchment"] .page-stack,
.flipnote-pad[data-paper="parchment"] .turning-leaf { background-color: #f3e3bf; }
.flipnote-pad[data-paper="kraft"] .page-stack,
.flipnote-pad[data-paper="kraft"] .turning-leaf { background-color: #c9a778; }
.flipnote-pad[data-paper="blueprint"] .page-stack,
.flipnote-pad[data-paper="blueprint"] .turning-leaf { background-color: #0b2545; color: #e8f1f5; }
.flipnote-pad[data-paper="legal"] .page-stack,
.flipnote-pad[data-paper="legal"] .turning-leaf { background-color: #fdf6b2; }

/* Ink colours only on light papers; blueprint keeps its chalk */
.flipnote-pad[data-paper="blueprint"][data-ink] .rule-text {
  color: #e8f1f5;
}

/* ---------- Pen lies down when you stop writing ---------- */
.pen-rig.lying:not(.writing) .pen {
  transform: rotate(-84deg);
  animation: none;
}

.pen-rig.lying:not(.writing) .pen-base {
  opacity: 0;
}

/* ---------- Eraser crumbs (spawned and animated by settings.js) ---------- */
.eraser-crumb {
  position: absolute;
  z-index: 35;
  width: 3px;
  height: 2px;
  border-radius: 1px;
  background: #b9b3a6;
  pointer-events: none;
  opacity: 0;
}

.flipnote-pad[data-paper="blueprint"] .eraser-crumb {
  background: #cfe0f0;
}

/* ---------- Sunbeam dust motes ---------- */
.dust-mote {
  display: none;
  position: absolute;
  z-index: 4;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 236, 190, 0.9);
  box-shadow: 0 0 4px rgba(255, 230, 170, 0.8);
  pointer-events: none;
}

.flipnote-pad[data-dust="on"] .dust-mote {
  display: block;
}

.dust-mote-1 { left: 20%; top: 30%; animation: moteDrift1 19s ease-in-out infinite; }
.dust-mote-2 { left: 62%; top: 55%; animation: moteDrift2 23s ease-in-out infinite; }
.dust-mote-3 { left: 40%; top: 75%; animation: moteDrift3 17s ease-in-out infinite; }

@keyframes moteDrift1 {
  0%, 100% { translate: 0 0; opacity: 0.2; }
  30% { translate: 40px -30px; opacity: 0.7; }
  60% { translate: 70px 10px; opacity: 0.35; }
}

@keyframes moteDrift2 {
  0%, 100% { translate: 0 0; opacity: 0.5; }
  40% { translate: -50px -40px; opacity: 0.2; }
  75% { translate: -20px -70px; opacity: 0.65; }
}

@keyframes moteDrift3 {
  0%, 100% { translate: 0 0; opacity: 0.3; }
  50% { translate: 30px -60px; opacity: 0.7; }
}

/* ---------- Evening warmth (--warm set hourly by settings.js, 0..1) ---------- */
.flipnote-pad[data-warm="on"] .paper-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #ffc98a;
  mix-blend-mode: multiply;
  opacity: calc(var(--warm, 0) * 0.35);
  pointer-events: none;
  transition: opacity 2s ease;
}

/* ---------- Cover flips up like a reporter's notepad ---------- */
.flipnote-pad[data-cover="flipup"] .book-cover {
  transform-origin: center top;
  transform: rotateX(178deg);
}

.flipnote-pad[data-cover="flipup"].book-closed .book-cover {
  transform: rotateX(0deg);
}

@media (prefers-reduced-motion: reduce) {
  .dust-mote {
    display: none !important;
  }
}

/* A chosen ink colour beats a paper's default text colour (blueprint excepted) */
.flipnote-pad:not([data-paper="blueprint"])[data-ink="blue"] .rule-row:not(.done) .rule-text { color: #1d4ed8; }
.flipnote-pad:not([data-paper="blueprint"])[data-ink="green"] .rule-row:not(.done) .rule-text { color: #166534; }
.flipnote-pad:not([data-paper="blueprint"])[data-ink="red"] .rule-row:not(.done) .rule-text { color: #b91c1c; }
.flipnote-pad:not([data-paper="blueprint"])[data-ink="sepia"] .rule-row:not(.done) .rule-text { color: #7c4a1e; }

.flipnote-pad[data-paper="blueprint"] mark.fn-highlight {
  color: #0b2545;
  text-shadow: none;
}
