/* ========================================
   視覺模型基礎 — 簡報樣式
   延續 index.html 的手繪筆記本風格,簡報化
======================================== */

:root {
  --paper: #f5ecd9;
  --paper-light: #faf3e0;
  --paper-dark: #e8dcb9;
  --ink: #3d2f1f;
  --ink-soft: #6b5942;
  --ink-faint: #a89878;
  --red: #c8553d;
  --orange: #e89c50;
  --yellow: #e8c547;
  --green: #6a9b5e;
  --blue: #4a87a8;
  --purple: #8b6db5;
  --pink: #d68fa8;
  --line: #c4b289;
  --line-soft: #d8c8a3;
  --cream: #fff8e7;
}

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

html, body {
  background: #1a1410;
  font-family: 'Noto Serif TC', 'Shippori Mincho', serif;
  color: var(--ink);
  overflow: hidden;
}

deck-stage { background: #1a1410; }

/* Every slide gets paper bg + texture */
deck-stage > section {
  background: var(--paper);
  color: var(--ink);
  position: relative;
  overflow: hidden;
  padding: 80px 120px;
  display: flex;
  flex-direction: column;
  font-size: 28px;
  line-height: 1.5;
}

/* paper texture — applied via ::before */
deck-stage > section::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(232, 197, 71, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(200, 85, 61, 0.05), transparent 50%),
    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.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.24 0 0 0 0 0.18 0 0 0 0 0.12 0 0 0 0.08 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.5'/></svg>");
  pointer-events: none;
  z-index: 0;
}

deck-stage > section::after {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    transparent 0,
    transparent 47px,
    rgba(180, 150, 90, 0.06) 48px
  );
  pointer-events: none;
  z-index: 0;
}

deck-stage > section > * {
  position: relative;
  z-index: 1;
}

/* ============= TYPOGRAPHY ============= */

.kicker {
  font-family: 'Caveat', cursive;
  font-size: 32px;
  color: var(--red);
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.kicker::before {
  content: '★';
  color: var(--orange);
}

.kicker.no-star::before { display: none; }

h1.slide-title {
  font-family: 'Shippori Mincho', 'Noto Serif TC', serif;
  font-weight: 800;
  font-size: 92px;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 28px;
}

h1.slide-title.giant {
  font-size: 140px;
  line-height: 1;
}

h1.slide-title .hl {
  background: linear-gradient(180deg, transparent 60%, var(--yellow) 60%, var(--yellow) 92%, transparent 92%);
  padding: 0 8px;
}

h1.slide-title .scribble {
  font-family: 'Caveat', cursive;
  color: var(--red);
  font-weight: 700;
  font-size: 0.78em;
  transform: rotate(-2deg);
  display: inline-block;
}

h2.slide-title {
  font-family: 'Shippori Mincho', serif;
  font-weight: 700;
  font-size: 64px;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 24px;
  position: relative;
  display: inline-block;
}

h2.slide-title.underline::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 0; right: 0;
  height: 6px;
  background: var(--yellow);
  z-index: -1;
  border-radius: 3px;
}

h3.subhead {
  font-family: 'Shippori Mincho', serif;
  font-weight: 700;
  font-size: 40px;
  color: var(--ink);
  margin: 16px 0 20px;
}

.lead {
  font-size: 36px;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 400;
  max-width: 1500px;
}

.lead.serif { font-family: 'Shippori Mincho', serif; }
.lead.handwriting {
  font-family: 'Patrick Hand', cursive;
  font-size: 42px;
}

.subline {
  font-family: 'Patrick Hand', cursive;
  font-size: 28px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.caveat {
  font-family: 'Caveat', cursive;
  color: var(--red);
  font-weight: 700;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
}

.tag-stamp {
  display: inline-block;
  padding: 6px 14px;
  border: 2.5px dashed var(--red);
  color: var(--red);
  font-weight: 700;
  transform: rotate(-2deg);
  font-family: 'Caveat', cursive;
  font-size: 24px;
}

/* ============= COMMON LAYOUTS ============= */

.slide-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 36px;
}

.slide-num {
  font-family: 'Caveat', cursive;
  color: var(--ink-faint);
  font-size: 22px;
  letter-spacing: 0.05em;
}

.section-marker {
  position: absolute;
  top: 36px;
  right: 60px;
  font-family: 'Caveat', cursive;
  color: var(--ink-faint);
  font-size: 22px;
  z-index: 5;
  text-align: right;
  line-height: 1.3;
}

.section-marker .num {
  color: var(--red);
  font-size: 28px;
  margin-right: 6px;
}

.cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  flex: 1;
  align-items: start;
}

.timeline {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 24px;
  margin-top: 24px;
}

.timeline-item {
  background: var(--cream, #f6efe1);
  border: 2px dashed var(--ink, #2b2823);
  border-radius: 12px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.08);
  position: relative;
  min-height: 0;
}

.timeline-item .year {
  font-family: var(--hand, "Caveat"), cursive;
  font-size: 32px;
  color: var(--red, #c44d3f);
  font-weight: 700;
  line-height: 1;
}

.timeline-item .name {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink, #2b2823);
  line-height: 1.2;
}

.timeline-item .desc {
  font-size: 16px;
  color: var(--ink-soft, #5b554b);
  line-height: 1.45;
  margin-top: auto;
}

.cols-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  flex: 1;
  align-items: start;
}

.cols-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  flex: 1;
  align-items: stretch;
}

.fill { flex: 1; }
.center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  flex: 1;
}

/* ============= CARDS / NOTES ============= */

.card {
  background: var(--cream);
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 6px 6px 0 var(--ink);
  padding: 28px 32px;
  position: relative;
}

.card.tilt-l { transform: rotate(-0.6deg); }
.card.tilt-r { transform: rotate(0.5deg); }

.card-pin {
  position: absolute;
  top: -10px; left: 22px;
  width: 22px; height: 22px;
  background: var(--red);
  border: 2.5px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset -3px -3px 4px rgba(0,0,0,0.2);
}

.card-pin.orange { background: var(--orange); }
.card-pin.green { background: var(--green); }
.card-pin.blue { background: var(--blue); }
.card-pin.yellow { background: var(--yellow); }
.card-pin.purple { background: var(--purple); }

.card-title {
  font-family: 'Caveat', cursive;
  font-size: 34px;
  color: var(--red);
  margin-bottom: 12px;
  font-weight: 700;
  margin-left: 30px;
}

.card-body {
  font-size: 22px;
  color: var(--ink);
  line-height: 1.55;
}

.card-body.handwriting {
  font-family: 'Patrick Hand', cursive;
  font-size: 26px;
}

.note-callout {
  padding: 24px 28px;
  background: rgba(232, 197, 71, 0.18);
  border: 2.5px solid var(--ink);
  border-left: 8px solid var(--orange);
  border-radius: 10px;
  box-shadow: 5px 5px 0 var(--ink);
  font-size: 24px;
  color: var(--ink);
  line-height: 1.65;
}

.note-callout strong {
  background: var(--yellow);
  padding: 0 6px;
  border-radius: 3px;
}

.note-callout .note-title {
  font-family: 'Caveat', cursive;
  font-size: 30px;
  color: var(--red);
  margin-bottom: 8px;
  font-weight: 700;
}

/* ============= TABLES ============= */

table.handwritten {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 22px;
  font-family: 'Noto Serif TC', serif;
}

table.handwritten th {
  background: var(--ink);
  color: var(--paper);
  font-family: 'Caveat', cursive;
  font-size: 26px;
  font-weight: 700;
  padding: 14px 18px;
  text-align: left;
  border: 2px solid var(--ink);
}

table.handwritten td {
  padding: 12px 18px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  vertical-align: top;
}

table.handwritten tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.2);
}

table.handwritten code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 19px;
  color: var(--red);
  background: rgba(232, 197, 71, 0.3);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ============= CHIPS / BADGES ============= */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-family: 'Kalam', cursive;
  font-weight: 700;
  font-size: 18px;
  background: var(--cream);
  color: var(--ink);
}

.chip.red { background: var(--red); color: var(--paper); }
.chip.orange { background: var(--orange); }
.chip.yellow { background: var(--yellow); }
.chip.green { background: var(--green); color: var(--paper); }
.chip.blue { background: var(--blue); color: var(--paper); }
.chip.purple { background: var(--purple); color: var(--paper); }
.chip.ink { background: var(--ink); color: var(--paper); }

/* ============= CODE ============= */

pre.code {
  background: #2d2419;
  color: #f5ecd9;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: 5px 5px 0 var(--ink);
  padding: 22px 26px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  line-height: 1.6;
  overflow-x: auto;
}

pre.code .kw { color: #e89c50; }
pre.code .cls { color: #e8c547; }
pre.code .num { color: #6ab7ff; }
pre.code .com { color: #a89878; font-style: italic; }
pre.code .str { color: #b6d075; }
pre.code .hl-line {
  display: block;
  background: rgba(232, 197, 71, 0.18);
  margin: 0 -26px;
  padding: 0 26px;
  border-left: 4px solid var(--yellow);
}

/* ============= ANIMATIONS — entry ============= */

deck-stage > section.is-active .anim-fade {
  animation: fadeIn 0.5s ease both;
}
deck-stage > section.is-active .anim-rise {
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}
deck-stage > section.is-active .anim-rise-1 { animation: rise 0.6s cubic-bezier(.2,.8,.2,1) 0.1s both; }
deck-stage > section.is-active .anim-rise-2 { animation: rise 0.6s cubic-bezier(.2,.8,.2,1) 0.25s both; }
deck-stage > section.is-active .anim-rise-3 { animation: rise 0.6s cubic-bezier(.2,.8,.2,1) 0.4s both; }
deck-stage > section.is-active .anim-rise-4 { animation: rise 0.6s cubic-bezier(.2,.8,.2,1) 0.55s both; }
deck-stage > section.is-active .anim-rise-5 { animation: rise 0.6s cubic-bezier(.2,.8,.2,1) 0.7s both; }

deck-stage > section.is-active .anim-pop {
  animation: pop 0.5s cubic-bezier(.34,1.56,.64,1) both;
}
deck-stage > section.is-active .anim-pop-1 { animation: pop 0.5s cubic-bezier(.34,1.56,.64,1) 0.15s both; }
deck-stage > section.is-active .anim-pop-2 { animation: pop 0.5s cubic-bezier(.34,1.56,.64,1) 0.3s both; }
deck-stage > section.is-active .anim-pop-3 { animation: pop 0.5s cubic-bezier(.34,1.56,.64,1) 0.45s both; }
deck-stage > section.is-active .anim-pop-4 { animation: pop 0.5s cubic-bezier(.34,1.56,.64,1) 0.6s both; }

deck-stage > section.is-active .anim-draw-line {
  animation: drawLine 0.8s ease 0.2s both;
}

deck-stage > section.is-active .anim-spin-in {
  animation: spinIn 0.7s cubic-bezier(.34,1.56,.64,1) both;
}

deck-stage > section.is-active .anim-wobble {
  animation: wobble 2.5s ease-in-out infinite;
}

deck-stage > section.is-active .anim-pulse {
  animation: pulse 2s ease-in-out infinite;
}

deck-stage > section.is-active .anim-bounce {
  animation: bounce 1.5s ease-in-out infinite;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { opacity: 0; transform: scale(0.6) rotate(-3deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes drawLine {
  from { stroke-dashoffset: 1000; }
  to { stroke-dashoffset: 0; }
}
@keyframes spinIn {
  from { opacity: 0; transform: rotate(-180deg) scale(0.4); }
  to { opacity: 1; transform: rotate(0) scale(1); }
}
@keyframes wobble {
  0%, 100% { transform: rotate(-1.2deg); }
  50% { transform: rotate(1.2deg); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes flowDown {
  0% { stroke-dashoffset: 100; opacity: 0; }
  20% { opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}
@keyframes shimmer {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ============= SECTION DIVIDERS ============= */

section.divider {
  background: var(--ink) !important;
  color: var(--paper);
  align-items: center;
  justify-content: center;
  text-align: center;
}
section.divider::before {
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(232, 197, 71, 0.12), transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(200, 85, 61, 0.1), transparent 60%),
    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.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 0.95 0 0 0 0 0.85 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.6'/></svg>");
}
section.divider::after {
  background-image: repeating-linear-gradient(
    transparent 0,
    transparent 47px,
    rgba(255, 248, 231, 0.04) 48px
  );
}
section.divider .kicker {
  color: var(--orange);
  font-size: 42px;
}
section.divider .kicker::before { color: var(--yellow); }
section.divider h1.slide-title { color: var(--paper); }
section.divider .subline { color: var(--paper-dark); }

/* alt color section */
section.cream-bg {
  background: var(--cream) !important;
}

/* ============= UTILITY ============= */

.row { display: flex; align-items: center; gap: 16px; }
.col { display: flex; flex-direction: column; gap: 16px; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }
.gap-32 { gap: 32px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mt-48 { margin-top: 48px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.text-center { text-align: center; }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-blue { color: var(--blue); }
.text-green { color: var(--green); }
.text-soft { color: var(--ink-soft); }
.text-faint { color: var(--ink-faint); }
.bold { font-weight: 700; }

/* arrow scribble for diagrams */
.arrow-text {
  font-family: 'Caveat', cursive;
  color: var(--red);
  font-size: 28px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* big quote */
.big-quote {
  font-family: 'Shippori Mincho', serif;
  font-size: 64px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--ink);
  position: relative;
  padding: 0 64px;
}
.big-quote::before {
  content: '「';
  position: absolute; left: 0; top: -20px;
  font-size: 120px;
  color: var(--orange);
  font-family: 'Shippori Mincho', serif;
}
.big-quote::after {
  content: '」';
  position: absolute; right: 0; bottom: -50px;
  font-size: 120px;
  color: var(--orange);
  font-family: 'Shippori Mincho', serif;
}

/* ============= TWEAKS PANEL OVERRIDE ============= */

.tweaks-trigger { display: none !important; }

/* Theme variants — applied via [data-theme] on <html> */
html[data-theme="dark"] {
  --paper: #1f1a14;
  --paper-light: #2a241c;
  --paper-dark: #15110c;
  --ink: #f5ecd9;
  --ink-soft: #c4b289;
  --ink-faint: #8b7d5f;
  --line: #5a4a35;
  --line-soft: #6b5942;
  --cream: #2d2419;
}
html[data-theme="dark"] body { background: #0a0805; }
html[data-theme="dark"] deck-stage { background: #0a0805; }
html[data-theme="dark"] section.divider { background: #000 !important; }
html[data-theme="dark"] pre.code { background: #0d0a07; }

html[data-theme="bright"] {
  --paper: #ffffff;
  --cream: #fff8e7;
}

/* Density: compact vs comfortable */
html[data-density="compact"] deck-stage > section { padding: 60px 90px; font-size: 24px; }
html[data-density="compact"] h1.slide-title { font-size: 76px; }
html[data-density="compact"] h2.slide-title { font-size: 52px; }
html[data-density="compact"] h3.subhead { font-size: 34px; }
html[data-density="compact"] .lead { font-size: 30px; }

html[data-density="loose"] deck-stage > section { padding: 100px 140px; font-size: 32px; }
html[data-density="loose"] h1.slide-title { font-size: 108px; }
html[data-density="loose"] h2.slide-title { font-size: 72px; }
html[data-density="loose"] .lead { font-size: 40px; }
