/* ============================================
   THE STACK - SCHOOL EDITION
   Whiteboard aesthetic with sticker-style highlights
   ============================================ */

:root {
  /* Whiteboard background */
  --bg: #fefdf7;
  --bg-grid: #ececdc;
  --bg-card: #ffffff;
  --bg-card-soft: #fafaf3;

  /* Marker / pen colours */
  --ink-black: #1f2937;
  --ink-blue: #2563eb;
  --ink-red: #dc2626;
  --ink-green: #16a34a;
  --ink-orange: #ea580c;
  --ink-purple: #9333ea;

  /* Sticker / highlighter pastels */
  --sticker-yellow: #fef08a;
  --sticker-pink: #fbcfe8;
  --sticker-green: #bbf7d0;
  --sticker-blue: #bfdbfe;
  --sticker-orange: #fed7aa;
  --sticker-purple: #e9d5ff;

  /* Text */
  --text: #1f2937;
  --text-dim: #4b5563;
  --text-faint: #9ca3af;

  /* Borders */
  --border: #d1d5db;
  --border-dark: #374151;

  /* Fonts */
  --display: 'Patrick Hand', 'Comic Neue', cursive;
  --hand: 'Caveat', cursive;
  --body: 'Nunito', sans-serif;
}

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

html, body {
  background: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

body { display: flex; }

/* === SIDEBAR === */
.sidebar {
  width: 280px;
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 3px solid var(--ink-black);
  padding: 24px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.logo {
  font-family: var(--display);
  font-weight: 700;
  font-size: 32px;
  line-height: 1;
  color: var(--ink-black);
  margin-bottom: 4px;
}

.logo .accent {
  color: var(--ink-red);
  display: inline-block;
  transform: rotate(-5deg);
}

.tagline {
  font-family: var(--hand);
  font-size: 22px;
  color: var(--ink-blue);
  margin-bottom: 32px;
  font-weight: 700;
}

.nav-section { margin-bottom: 28px; }

.nav-label {
  font-family: var(--display);
  font-size: 18px;
  color: var(--ink-black);
  margin-bottom: 8px;
  padding-left: 8px;
  font-weight: 700;
  position: relative;
}

.nav-label::after {
  content: '';
  display: block;
  width: 60px;
  height: 4px;
  background: var(--sticker-yellow);
  margin-top: 2px;
  margin-left: 8px;
  border-radius: 2px;
}

.nav-link {
  display: block;
  padding: 8px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.15s ease;
  margin-bottom: 4px;
  border-radius: 8px;
  border: 2px solid transparent;
}

.nav-link:hover {
  background: var(--sticker-yellow);
  transform: translateX(4px);
}

.nav-link.active {
  background: var(--sticker-blue);
  border-color: var(--ink-blue);
  color: var(--ink-black);
}

.nav-link .num {
  display: inline-block;
  background: var(--sticker-orange);
  color: var(--ink-black);
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  padding: 0 7px;
  border-radius: 50%;
  margin-right: 8px;
  width: 24px;
  height: 24px;
  text-align: center;
  line-height: 24px;
}

/* === MAIN === */
.main {
  flex: 1;
  padding: 40px 56px 80px;
  max-width: 1100px;
  width: 100%;
}

/* === PAGE HEADER === */
.page-header {
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 3px dashed var(--border);
}

.eyebrow {
  font-family: var(--hand);
  font-size: 24px;
  color: var(--ink-purple);
  margin-bottom: 4px;
  font-weight: 700;
  transform: rotate(-1deg);
  display: inline-block;
}

h1 {
  font-family: var(--display);
  font-size: 56px;
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 16px;
  color: var(--ink-black);
}

h1 .highlight {
  background: var(--sticker-yellow);
  padding: 2px 10px;
  border-radius: 6px;
  display: inline-block;
  transform: rotate(-2deg);
}

h1 .scribble {
  color: var(--ink-red);
  text-decoration: underline wavy var(--ink-red);
  text-underline-offset: 6px;
}

.lead {
  font-size: 18px;
  color: var(--text-dim);
  max-width: 720px;
  line-height: 1.65;
}

.lead strong { color: var(--ink-black); font-weight: 700; }

/* === HEADINGS === */
h2 {
  font-family: var(--display);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.15;
  margin-top: 48px;
  margin-bottom: 16px;
  color: var(--ink-black);
}

h2::before {
  content: '✏️ ';
  margin-right: 4px;
}

h3 {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  margin-top: 28px;
  margin-bottom: 10px;
  color: var(--ink-blue);
}

h4 {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-orange);
  margin-top: 20px;
  margin-bottom: 8px;
}

p {
  margin-bottom: 14px;
  color: var(--text);
  font-size: 16px;
}

strong { color: var(--ink-black); font-weight: 700; }
em { color: var(--ink-purple); font-style: normal; font-weight: 600; }

a {
  color: var(--ink-blue);
  text-decoration: none;
  border-bottom: 2px solid var(--ink-blue);
}

a:hover { background: var(--sticker-yellow); }

ul, ol { margin-bottom: 16px; padding-left: 28px; }
ul li, ol li { margin-bottom: 8px; color: var(--text); }
ul li::marker { color: var(--ink-red); font-size: 18px; }
ol li::marker { color: var(--ink-blue); font-weight: 700; font-family: var(--display); font-size: 18px; }

/* === STICKER CALLOUT BOXES === */
.sticker {
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  padding: 20px 24px;
  margin: 24px 0;
  border-radius: 16px;
  position: relative;
  box-shadow: 4px 4px 0 var(--ink-black);
}

.sticker.yellow { background: var(--sticker-yellow); }
.sticker.pink { background: var(--sticker-pink); }
.sticker.green { background: var(--sticker-green); }
.sticker.blue { background: var(--sticker-blue); }
.sticker.orange { background: var(--sticker-orange); }
.sticker.purple { background: var(--sticker-purple); }

.sticker .sticker-label {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  color: var(--ink-black);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sticker h3 { margin-top: 0; color: var(--ink-black); }
.sticker p:last-child { margin-bottom: 0; }

/* Activity box (parent activities) */
.activity-box {
  background: var(--sticker-purple);
  border: 3px solid var(--ink-purple);
  padding: 22px 26px;
  margin: 24px 0;
  border-radius: 16px;
  box-shadow: 5px 5px 0 var(--ink-purple);
}

.activity-box .activity-label {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  color: var(--ink-purple);
  margin-bottom: 12px;
}

.activity-box h3 {
  color: var(--ink-purple);
  margin-top: 0;
}

/* === BLOCKQUOTES === */
blockquote {
  border-left: 6px solid var(--ink-red);
  background: var(--bg-card);
  padding: 16px 24px;
  margin: 20px 0;
  font-size: 18px;
  font-family: var(--hand);
  color: var(--ink-black);
  border-radius: 0 8px 8px 0;
  font-weight: 700;
}

/* === TABLES === */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 15px;
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  border-radius: 12px;
  overflow: hidden;
}

th {
  background: var(--sticker-yellow);
  color: var(--ink-black);
  text-align: left;
  padding: 14px 16px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  border-bottom: 3px solid var(--ink-black);
}

td {
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  color: var(--text);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card-soft); }

hr {
  border: none;
  border-top: 3px dashed var(--border);
  margin: 40px 0;
}

/* === BUTTONS === */
.btn {
  display: inline-block;
  background: var(--ink-blue);
  color: white;
  border: 3px solid var(--ink-black);
  padding: 12px 22px;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  border-radius: 12px;
  margin-right: 8px;
  margin-bottom: 8px;
  box-shadow: 4px 4px 0 var(--ink-black);
}

.btn:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink-black);
  background: var(--sticker-yellow);
  color: var(--ink-black);
}

.btn-secondary { background: var(--bg-card); color: var(--ink-black); }
.btn-success { background: var(--ink-green); }
.btn-danger { background: var(--ink-red); }

/* === METHOD CARDS GRID === */
.method-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.method-card {
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: all 0.2s ease;
  position: relative;
  border-radius: 16px;
  box-shadow: 5px 5px 0 var(--ink-black);
}

.method-card:nth-child(3n+1) { transform: rotate(-1deg); }
.method-card:nth-child(3n+2) { transform: rotate(0.5deg); }
.method-card:nth-child(3n+3) { transform: rotate(-0.5deg); }

.method-card:hover {
  transform: translate(-3px, -3px) rotate(0deg);
  box-shadow: 8px 8px 0 var(--ink-black);
  background: var(--sticker-yellow);
}

.method-card .method-num {
  display: inline-block;
  background: var(--ink-red);
  color: white;
  font-family: var(--display);
  font-size: 13px;
  padding: 3px 12px;
  border-radius: 12px;
  margin-bottom: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.method-card .method-name {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ink-black);
}

.method-card .method-desc {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.55;
}

.method-card .method-arrow {
  position: absolute;
  top: 24px;
  right: 24px;
  font-size: 28px;
  color: var(--ink-blue);
  font-family: var(--display);
}

/* === FORM ELEMENTS === */
input[type="text"], input[type="number"], input[type="date"], textarea, select {
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  padding: 12px 16px;
  width: 100%;
  border-radius: 10px;
  transition: all 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--ink-blue);
  background: var(--sticker-blue);
}

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: hue-rotate(180deg);
}

textarea { resize: vertical; min-height: 80px; }

label {
  display: block;
  font-family: var(--display);
  font-size: 18px;
  color: var(--ink-black);
  margin-bottom: 6px;
  font-weight: 700;
}

.form-group { margin-bottom: 20px; }

.form-row, .form-row-3 {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.form-row { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}

.checkbox-group input[type="checkbox"] {
  width: 22px;
  height: 22px;
  accent-color: var(--ink-blue);
  cursor: pointer;
}

.checkbox-group label {
  margin-bottom: 0;
  font-family: var(--body);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* === STAT CARDS === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--ink-black);
  position: relative;
}

.stat-card .stat-label {
  font-family: var(--display);
  font-size: 16px;
  color: var(--ink-black);
  margin-bottom: 6px;
  font-weight: 700;
}

.stat-card .stat-value {
  font-family: var(--display);
  font-size: 48px;
  font-weight: 700;
  color: var(--ink-red);
  line-height: 1;
}

.stat-card .stat-meta {
  font-family: var(--hand);
  font-size: 16px;
  color: var(--ink-blue);
  margin-top: 4px;
}

/* === BADGES === */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.badge {
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  padding: 20px 12px;
  text-align: center;
  border-radius: 50%;
  aspect-ratio: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  transition: all 0.2s ease;
}

.badge.earned {
  background: var(--sticker-yellow);
  transform: rotate(-3deg);
  box-shadow: 4px 4px 0 var(--ink-black);
}

.badge.earned:nth-child(even) { transform: rotate(3deg); }

.badge:not(.earned) {
  opacity: 0.3;
  filter: grayscale(1);
}

.badge .badge-icon {
  font-size: 36px;
  margin-bottom: 4px;
}

.badge .badge-name {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink-black);
}

/* === ACHIEVEMENT BANNER === */
.achievement-banner {
  background: var(--sticker-green);
  border: 3px solid var(--ink-black);
  padding: 16px 20px;
  margin-bottom: 24px;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink-black);
  text-align: center;
  box-shadow: 4px 4px 0 var(--ink-black);
}

/* === TABS === */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 3px solid var(--ink-black);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab {
  padding: 12px 18px;
  background: transparent;
  border: none;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: all 0.15s ease;
}

.tab:hover { background: var(--sticker-yellow); color: var(--ink-black); }
.tab.active { background: var(--ink-blue); color: white; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* === COLLAPSIBLE === */
details {
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  margin-bottom: 12px;
  border-radius: 12px;
  padding: 0;
  box-shadow: 3px 3px 0 var(--ink-black);
}

details summary {
  padding: 14px 18px;
  cursor: pointer;
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink-black);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

details summary::-webkit-details-marker { display: none; }
details summary::after {
  content: '+';
  font-family: var(--display);
  font-size: 28px;
  color: var(--ink-red);
  font-weight: 700;
}

details[open] summary::after { content: '−'; }

details .details-body {
  padding: 0 18px 18px;
  border-top: 2px dashed var(--border);
  padding-top: 16px;
}

/* === HISTORY / WRONG ANSWER LIST === */
.history-item {
  background: var(--bg-card);
  border: 3px solid var(--ink-black);
  padding: 16px 20px;
  margin-bottom: 12px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  box-shadow: 3px 3px 0 var(--ink-black);
}

.history-item .h-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-black);
}

.history-item .h-meta {
  font-family: var(--hand);
  font-size: 16px;
  color: var(--ink-blue);
}

.history-item .h-score {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
  color: var(--ink-red);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  border: 3px dashed var(--border-dark);
  margin: 20px 0;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 18px;
}

/* === TOAST NOTIFICATION === */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--sticker-green);
  border: 3px solid var(--ink-black);
  padding: 14px 20px;
  border-radius: 12px;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-black);
  box-shadow: 5px 5px 0 var(--ink-black);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 100;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* === MOBILE === */
@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; min-height: auto; padding: 20px; }
  .main { padding: 32px 24px 60px; }
  h1 { font-size: 38px; }
  h2 { font-size: 28px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .badges-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg-grid); }
::-webkit-scrollbar-thumb { background: var(--ink-black); border-radius: 6px; }

/* ============================================
   FLOATING SAVE WIDGET (kids)
   ============================================ */
#save-widget { position: fixed; bottom: 24px; right: 24px; z-index: 1000; font-family: var(--body); }

#skw-fab {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--ink-blue); border: 3px solid var(--ink-black);
  color: #fff; font-size: 26px; cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink-black);
  transition: all 0.2s ease;
  display: flex; align-items: center; justify-content: center;
}
#skw-fab:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--ink-black); background: var(--ink-purple); }
#skw-fab.open { transform: rotate(10deg); }

#skw-panel {
  position: absolute; bottom: 74px; right: 0; width: 290px;
  background: var(--bg-card); border: 3px solid var(--ink-black);
  border-radius: 16px; padding: 18px; box-shadow: 6px 6px 0 var(--ink-black);
}
.skw-head { font-family: var(--display); font-size: 22px; font-weight: 700; color: var(--ink-black); margin-bottom: 12px; }
.skw-stats { display: flex; justify-content: space-between; margin-bottom: 14px; }
.skw-stats span { font-size: 12px; color: var(--text-dim); text-align: center; font-weight: 600; }
.skw-stats strong { display: block; font-family: var(--display); font-size: 24px; color: var(--ink-red); }

.skw-btn {
  display: block; width: 100%; text-align: center;
  padding: 11px; margin-bottom: 8px; border-radius: 10px;
  border: 3px solid var(--ink-black); background: var(--bg-card);
  color: var(--ink-black); font-family: var(--display); font-size: 16px; font-weight: 700;
  cursor: pointer; text-decoration: none; transition: all 0.15s ease;
}
.skw-btn:hover { background: var(--sticker-yellow); }
.skw-primary { background: var(--ink-green); color: #fff; }
.skw-primary:hover { background: var(--sticker-yellow); color: var(--ink-black); }
.skw-link { font-size: 14px; }

.skw-hint { font-size: 12px; color: var(--text-dim); margin-top: 8px; line-height: 1.4; font-family: var(--body); }

.skw-toast {
  position: fixed; bottom: 96px; right: 24px;
  background: var(--sticker-green); border: 3px solid var(--ink-black);
  color: var(--ink-black); padding: 12px 18px; border-radius: 12px;
  font-family: var(--display); font-size: 18px; font-weight: 700;
  box-shadow: 4px 4px 0 var(--ink-black);
  z-index: 1001; opacity: 0; transform: translateY(12px);
  transition: all 0.3s ease; pointer-events: none;
}
.skw-toast.show { opacity: 1; transform: translateY(0); }
.skw-toast.danger { background: var(--sticker-pink); }

@media (max-width: 900px) { #save-widget { bottom: 16px; right: 16px; } #skw-panel { width: 270px; } }

/* === Embedded reflection box === */
.reflect-box { margin: 20px 0 40px; }
.reflect-box .form-group:last-of-type { margin-bottom: 16px; }
.rf-saved {
  margin-left: 12px;
  color: var(--ink-green, #16a34a);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
}

/* === Essay Helper 5W grid === */
.essay-5w {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
}
@media (max-width: 700px) { .essay-5w { grid-template-columns: 1fr; } }
