/* ==========================================================================
   Draw it up — a study notebook that tells you what to draw
   ========================================================================== */

:root {
  --paper:       #FBF7ED;
  --paper-warm:  #F6F0E1;
  --paper-shade: #E9E1CE;
  --rule:        #C3D7E8;
  --rule-soft:   #DCE8F2;
  --margin-red:  #E39C9C;

  --ink:       #27303D;
  --ink-soft:  #55606F;
  --graphite:  #8A93A0;
  --highlight: #FFE9A0;

  --metal:      #C2C8D0;
  --metal-lt:   #EDF0F4;
  --metal-dk:   #79818D;

  --hand: "Caveat", "Bradley Hand", cursive;
  --body: "Karla", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", Menlo, monospace;

  --line-h: 2.25rem;   /* ruled line spacing — content rhythm follows this */
  --sheet-max: 46rem;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--ink);
  font-size: clamp(1rem, .96rem + .2vw, 1.06rem);
  line-height: 1.6;
  background: #6E6559;
  background-image:
    radial-gradient(ellipse 120% 80% at 50% 0%, #7C7264 0%, #5E564B 70%);
  padding: 0 1rem 4rem;
}

/* ==========================================================================
   THE SHEET — ruled paper with a punched spiral binding
   ========================================================================== */
.sheet {
  position: relative;
  max-width: var(--sheet-max);
  margin: 0 auto;
  padding: 4.6rem clamp(1.2rem, 4vw, 2.6rem) 3rem clamp(2.6rem, 8vw, 4.4rem);
  background-color: var(--paper);
  /* ruled lines + the red margin rule down the left */
  background-image:
    linear-gradient(90deg, transparent calc(clamp(2rem, 6.5vw, 3.6rem) - 1px), var(--margin-red) calc(clamp(2rem, 6.5vw, 3.6rem) - 1px), var(--margin-red) clamp(2rem, 6.5vw, 3.6rem), transparent clamp(2rem, 6.5vw, 3.6rem)),
    repeating-linear-gradient(180deg, transparent 0 calc(var(--line-h) - 1px), var(--rule) calc(var(--line-h) - 1px), var(--rule) var(--line-h));
  background-position: 0 0, 0 4.6rem;
  box-shadow:
    0 1px 0 rgba(255,255,255,.5) inset,
    0 24px 60px rgba(0,0,0,.32),
    0 3px 10px rgba(0,0,0,.2);
  border-radius: 2px;
  min-height: 100vh;
}

/* torn-ish paper grain */
.sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23p)' opacity='0.35'/%3E%3C/svg%3E");
}

/* ---------- spiral binding ---------- */
.binding {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4.6rem;
  display: flex;
  justify-content: space-evenly;
  align-items: flex-start;
  pointer-events: none;
}
.binding__ring {
  position: relative;
  width: 26px;
  height: 40px;
  margin-top: -14px;
}
/* the punched hole in the paper */
.binding__ring::before {
  content: "";
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #5E564B;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.55), 0 1px 0 rgba(255,255,255,.6);
}
/* the metal wire looping over the top edge */
.binding__ring::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%) rotate(-8deg);
  width: 20px;
  height: 34px;
  border-radius: 50% / 46%;
  border: 4px solid transparent;
  border-top-color: var(--metal-lt);
  border-left-color: var(--metal);
  border-right-color: var(--metal-dk);
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.masthead { text-align: left; margin-bottom: 1.4rem; }
.masthead__label {
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--graphite);
  margin: 0 0 .2rem;
}
.masthead__title {
  font-family: var(--hand);
  font-weight: 700;
  font-size: clamp(2.6rem, 1.9rem + 3.4vw, 4rem);
  line-height: 1;
  margin: 0;
  color: var(--ink);
}
.masthead__title span {
  background: linear-gradient(transparent 62%, var(--highlight) 62%, var(--highlight) 94%, transparent 94%);
}
.masthead__sub {
  font-family: var(--hand);
  font-size: clamp(1.15rem, 1.05rem + .35vw, 1.45rem);
  color: var(--ink-soft);
  margin: .2rem 0 0;
}

.tape-rule {
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--graphite) 0 7px, transparent 7px 14px);
  opacity: .45;
  margin: 1.6rem 0 2rem;
}

/* ==========================================================================
   THE NOTE — the thing you click
   ========================================================================== */
.note-zone {
  display: flex;
  justify-content: center;
  padding: .6rem 0 1.4rem;
}

.note {
  position: relative;
  display: block;
  width: min(21rem, 92%);
  padding: 2.5rem 1.5rem 2.2rem;
  border: 0;
  cursor: pointer;
  background: #FFF9C4;
  background-image: linear-gradient(170deg, #FFFBD6 0%, #FDF2A8 100%);
  font-family: var(--hand);
  font-size: clamp(1.5rem, 1.25rem + 1vw, 2rem);
  line-height: 1.15;
  color: #4A4326;
  text-align: center;
  transform: rotate(-1.6deg);
  box-shadow:
    0 1px 0 rgba(255,255,255,.7) inset,
    0 14px 26px rgba(0,0,0,.22),
    0 3px 6px rgba(0,0,0,.14);
  transition: transform .25s cubic-bezier(.2,.8,.3,1), box-shadow .25s ease;
}
.note:hover, .note:focus-visible {
  transform: rotate(-1.6deg) translateY(-4px) scale(1.015);
  box-shadow: 0 1px 0 rgba(255,255,255,.7) inset, 0 20px 34px rgba(0,0,0,.26), 0 4px 8px rgba(0,0,0,.16);
}
.note:focus-visible { outline: 3px dashed #8A7B2E; outline-offset: 6px; }
.note:active { transform: rotate(-1.6deg) translateY(-1px) scale(.995); }

/* strip of tape at the top of the note */
.note::before {
  content: "";
  position: absolute;
  top: -13px;
  left: 50%;
  transform: translateX(-50%) rotate(1.4deg);
  width: 96px;
  height: 26px;
  background: rgba(255,255,255,.42);
  border-left: 1px dashed rgba(0,0,0,.09);
  border-right: 1px dashed rgba(0,0,0,.09);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.note__hint {
  display: block;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #8A7B3E;
  margin-top: .9rem;
}

/* the pencil-scratch state while it "thinks" */
.note.is-thinking { pointer-events: none; }
.note.is-thinking .note__label { opacity: .45; }

/* ==========================================================================
   THE ASSIGNMENT
   ========================================================================== */
.assignment[hidden] { display: none; }

.assignment {
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .55s ease, transform .55s cubic-bezier(.2,.8,.3,1);
}
.assignment.is-shown { opacity: 1; transform: none; }

.block { margin-bottom: 2.4rem; }

.block__head {
  display: flex;
  align-items: baseline;
  gap: .7rem;
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--graphite);
  margin-bottom: .5rem;
}
.block__head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.prompt {
  font-family: var(--hand);
  font-size: clamp(1.9rem, 1.4rem + 2.4vw, 3rem);
  line-height: 1.12;
  color: var(--ink);
  margin: 0;
}
.prompt__twist {
  display: block;
  font-size: .62em;
  color: var(--ink-soft);
  margin-top: .3rem;
}

/* ---------- palette ---------- */
.palette__name {
  font-family: var(--hand);
  font-size: 1.6rem;
  margin: 0 0 .7rem;
  color: var(--ink);
}
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  padding: 0;
  margin: 0;
  list-style: none;
}
.swatch {
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  text-align: center;
  font: inherit;
}
.swatch__blob {
  display: block;
  width: clamp(3.1rem, 10vw, 4.2rem);
  height: clamp(3.1rem, 10vw, 4.2rem);
  /* irregular, like a dab of paint */
  border-radius: 47% 53% 44% 56% / 52% 45% 55% 48%;
  box-shadow: 0 3px 7px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.07) inset;
  transition: transform .2s ease;
}
.swatch:hover .swatch__blob { transform: scale(1.06) rotate(3deg); }
.swatch:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.swatch__hex {
  display: block;
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .04em;
  color: var(--graphite);
  margin-top: .4rem;
}
.copied-note {
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--graphite);
  min-height: 1.2em;
  margin: .7rem 0 0;
}

/* ---------- optional challenges ---------- */
.optional-flag {
  font-family: var(--hand);
  font-size: 1.25rem;
  color: var(--margin-red);
  transform: rotate(-2deg);
  display: inline-block;
  margin-bottom: .6rem;
}
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { margin-bottom: .55rem; }
.checklist label {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  cursor: pointer;
  color: var(--ink-soft);
}
.checklist input {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  margin: .18rem 0 0;
  border: 2px solid var(--graphite);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  position: relative;
}
.checklist input:checked { border-color: var(--ink); }
.checklist input:checked::after {
  content: "✓";
  position: absolute;
  inset: -.35rem 0 0 .05rem;
  font-family: var(--hand);
  font-size: 1.5rem;
  color: var(--ink);
  line-height: 1;
}
.checklist input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.checklist input:checked + span { color: var(--graphite); text-decoration: line-through; }

/* ---------- actions ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
  margin-top: 2.6rem;
  padding-top: 1.4rem;
  border-top: 1px dashed var(--rule);
}
.btn {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  padding: .6rem 1rem;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.btn--ghost { border-style: dashed; color: var(--ink-soft); border-color: var(--graphite); }
.btn--ghost:hover { background: var(--graphite); color: var(--paper); }

/* ==========================================================================
   FOOTER
   ========================================================================== */
.sheet-foot {
  margin-top: 3.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .06em;
  color: var(--graphite);
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.2rem;
  align-items: center;
}
.sheet-foot a { color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--rule); }
.sheet-foot a:hover { color: var(--ink); border-color: var(--ink); }
.sheet-foot__spacer { flex: 1; }

/* ---------- ad slot ---------- */
.ad-slot {
  margin: 2.8rem 0 0;
  text-align: center;
}
.ad-slot__label {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--graphite);
  opacity: .7;
  margin: 0 0 .5rem;
}

/* ==========================================================================
   LEGAL PAGES
   ========================================================================== */
.doc h1 {
  font-family: var(--hand);
  font-size: clamp(2.2rem, 1.7rem + 2.4vw, 3.1rem);
  margin: 0 0 .2rem;
  color: var(--ink);
}
.doc__date {
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--graphite);
  margin: 0 0 2.2rem;
}
.doc h2 {
  font-family: var(--hand);
  font-size: 1.55rem;
  color: var(--ink);
  margin: 2.2rem 0 .4rem;
}
.doc p, .doc li { color: var(--ink-soft); }
.doc a { color: var(--ink); }
.doc ul { padding-left: 1.2rem; }
.doc li { margin-bottom: .45rem; }
.doc__back {
  display: inline-block;
  font-family: var(--mono);
  font-size: .68rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--graphite);
  text-decoration: none;
  margin-bottom: 2rem;
}
.doc__back:hover { color: var(--ink); }
.doc__cross { margin-top: 2.4rem; font-family: var(--mono); font-size: .78rem; }

/* ==========================================================================
   RESPONSIVE / MOTION
   ========================================================================== */
@media (max-width: 30rem) {
  body { padding: 0 .5rem 3rem; }
  .binding__ring { width: 20px; }
  .binding__ring::before { width: 12px; height: 12px; }
  .binding__ring::after { width: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .assignment { transition: opacity .2s linear; transform: none; }
  .note, .swatch__blob { transition: none; }
  .note:hover, .note:focus-visible { transform: rotate(-1.6deg); }
}

@media print {
  body { background: #fff; padding: 0; }
  .sheet { box-shadow: none; background-image: none; }
  .binding, .note-zone, .actions, .ad-slot { display: none; }
}
