/* ==========================================================================
   Study Lab — handwritten notebook pages.

   Every page is a real A4 sheet (794 × 1123 CSS px = 210 × 297 mm at 96 dpi),
   laid out at that size and only zoomed for the screen, so what a student sees
   is exactly what "PDF download" prints. Nothing here is an image: the
   handwriting is the Kalam font (Latin + Devanagari), and the boxes, tape,
   highlighter and ruling are CSS — so Hindi spelling stays exactly what the
   model wrote, and a page costs nothing to draw.
   ========================================================================== */

.nb-pages {
    --paper: #fffdf6;
    --rule: #c7daee;
    --margin-line: #ef9a9a;
    --ink: #1d2b5e;
    --ink2: #2a4f93;
    --red: #d1322f;
    --green: #1b7d47;
    --purple: #6a3fb5;
    --hl-y: rgba(255, 233, 72, .78);
    --hl-p: rgba(255, 160, 200, .62);
    --hl-g: rgba(150, 236, 165, .7);
    --hl-b: rgba(140, 210, 255, .62);

    --line: 32px;          /* ruling pitch (RULE_PITCH in the renderer) */
    --body-top: 116px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 26px;
    padding: 8px 0 40px;
}

/* ---------- sheet ---------- */
.nb-page {
    position: relative;
    flex: none;
    width: 794px;
    height: 1123px;
    overflow: hidden;
    background-color: var(--paper);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 10px 30px rgba(15, 25, 50, .16);
    border-radius: 3px;
    font-family: 'Kalam', 'Segoe Print', cursive;
    color: var(--ink);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* Ruling and margin are an inline SVG (notesRenderer.js ruling()), not a CSS
   gradient: Chrome rasterises gradients when it prints, and 1px lines came
   out of "Save as PDF" as a few thick grey bars with most lines missing. */
.nb-rule { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.nb-rule line { stroke: var(--rule); stroke-width: 1.1; }
.nb-rule .m { stroke: var(--margin-line); stroke-width: 1.8; }
.nb-rule .g { stroke: rgba(120, 170, 230, .3); stroke-width: 1; }

/* Punched holes down the left edge — the one detail that says "copy". */
.nb-page::before {
    content: "";
    position: absolute;
    left: 0; top: 40px; bottom: 40px;
    width: 46px;
    background: radial-gradient(circle at 24px 50%, #e4ded0 0 8px, rgba(0, 0, 0, .07) 8.5px 9.5px, transparent 10px) 0 0 / 46px 70px repeat-y;
    pointer-events: none;
}

/* Faint brand watermark across the middle. */
.nb-page::after {
    content: "AKASHNITI.IN";
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-48deg);
    font: 700 96px/1 'Kalam', cursive;
    letter-spacing: 8px;
    color: rgba(40, 60, 110, .045);
    white-space: nowrap;
    pointer-events: none;
}

/* Classmate-style "Date / Page" box in the header. */
.nb-head {
    position: absolute;
    top: 30px; right: 40px;
    display: flex;
    gap: 18px;
    font-size: 17px;
    color: var(--ink2);
}
.nb-head span { border-bottom: 1.5px solid var(--ink2); padding: 0 6px 0 2px; min-width: 70px; }
.nb-head b { font-weight: 400; color: #6b7a99; margin-right: 6px; }

.nb-brand {
    position: absolute;
    top: 32px; left: 112px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(42, 79, 147, .55);
}

.nb-foot {
    position: absolute;
    left: 112px; right: 40px; bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 15px;
    color: #7b88a6;
}
.nb-pno {
    display: inline-grid;
    place-items: center;
    width: 36px; height: 36px;
    border: 2px solid var(--red);
    border-radius: 52% 48% 50% 46% / 46% 52% 48% 54%;
    color: var(--red);
    font-weight: 700;
    font-size: 17px;
}

/* ---------- writing area ---------- */
.nb-body {
    position: absolute;
    top: var(--body-top);
    left: 114px; right: 46px; bottom: 64px;
    overflow: hidden;
    font-size: 20px;
    line-height: var(--line);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.nb-body > * { flex: none; }

/* ---------- title (page 1) ---------- */
.nb-title {
    text-align: center;
    padding: 2px 0 8px;
}
.nb-title h1 {
    display: inline-block;
    margin: 0;
    font-size: 40px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--red);
    text-decoration: underline double;
    text-decoration-thickness: 2px;
    text-underline-offset: 9px;
    text-decoration-color: var(--ink2);
}
.nb-title p {
    margin: 8px 0 0;
    font-size: 20px;
    color: var(--ink2);
}

/* ---------- section heading ---------- */
.nb-h {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 14px 0 0;
    font-size: 27px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--h, var(--ink2));
}
.nb-h:first-child { margin-top: 0; }
.nb-h .t {
    text-decoration: underline wavy;
    text-decoration-thickness: 2px;
    text-underline-offset: 7px;
}
.nb-h .n {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 38px; height: 38px;
    font-size: 21px;
    border: 2.5px solid currentColor;
    border-radius: 55% 45% 52% 48% / 48% 55% 45% 52%;
}
.nb-h[data-c="0"] { --h: var(--red); }
.nb-h[data-c="1"] { --h: var(--ink2); }
.nb-h[data-c="2"] { --h: var(--green); }
.nb-h[data-c="3"] { --h: var(--purple); }

/* The quiz's "See this in the notes" jump lands on a heading and pulses it. */
.nb-h.is-flash { animation: nb-flash 1.8s ease-out; border-radius: 10px; }
@keyframes nb-flash {
    0%, 30% { background: rgba(255, 233, 72, .85); box-shadow: 0 0 0 8px rgba(255, 233, 72, .85); }
    100% { background: transparent; box-shadow: 0 0 0 8px transparent; }
}

/* ---------- inline marks ---------- */
.nb-page strong { font-weight: 700; }
.nb-page mark {
    color: inherit;
    padding: 0 4px;
    margin: 0 -2px;
    border-radius: 6px 3px 7px 2px;
    background: linear-gradient(100deg, transparent 0 1%, var(--hl-y) 3% 96%, transparent 99%);
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}
.nb-page .red { color: var(--red); font-weight: 700; }
.nb-page u { text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--red); }

/* ---------- blocks ---------- */
.nb-para { margin: 0; }

.nb-list { list-style: none; margin: 0; padding: 0; }
.nb-list li { position: relative; padding-left: 34px; }
.nb-list li::before {
    content: "➜";
    position: absolute;
    left: 2px; top: 0;
    font-family: 'Segoe UI Symbol', 'DejaVu Sans', sans-serif;
    font-size: 18px;
    color: var(--red);
}
.nb-list li:nth-child(even)::before { color: var(--green); }

/* Hand-drawn box: unequal radii are what make a rectangle look inked. */
.nb-def {
    padding: 8px 18px 10px;
    border: 2.5px solid var(--ink2);
    border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
    background: rgba(140, 210, 255, .13);
}
.nb-def .term { color: var(--red); font-weight: 700; }

.nb-sticky {
    position: relative;
    align-self: flex-start;
    max-width: 82%;
    margin: 16px 0 6px 12px;
    padding: 18px 24px 14px;
    background: #fff39a;
    box-shadow: 2px 5px 10px rgba(80, 60, 0, .18);
    white-space: pre-line;
}
.nb-sticky::before {
    content: "";
    position: absolute;
    top: -13px; left: 50%;
    width: 96px; height: 26px;
    transform: translateX(-50%) rotate(-3deg);
    background: rgba(255, 255, 255, .62);
    border: 1px solid rgba(0, 0, 0, .06);
}
.nb-sticky .lbl {
    display: block;
    font-weight: 700;
    color: var(--red);
    text-decoration: underline;
    text-underline-offset: 5px;
}

.nb-tip { display: flex; gap: 12px; color: #8a2020; }
.nb-tip .star {
    flex: none;
    font-family: 'Segoe UI Symbol', 'DejaVu Sans', sans-serif;
    font-size: 30px;
    line-height: 30px;
    color: var(--red);
}
.nb-tip .lbl {
    display: inline-block;
    margin-right: 6px;
    padding: 0 10px;
    line-height: 28px;
    border: 2px solid var(--red);
    border-radius: 50% 45% 55% 48% / 60% 50% 55% 45%;
    font-weight: 700;
    color: var(--red);
}

.nb-warn {
    padding: 8px 16px 10px;
    border: 2.5px dashed var(--red);
    border-radius: 12px 4px 14px 6px;
    background: rgba(255, 160, 160, .12);
}
.nb-warn .lbl { color: var(--red); font-weight: 700; margin-right: 6px; }

.nb-eg .lbl { color: var(--green); font-weight: 700; margin-right: 8px; }

.nb-trick {
    padding: 6px 16px 8px;
    border-left: 5px solid var(--purple);
    background: rgba(160, 120, 240, .1);
    color: #3d2475;
    border-radius: 0 14px 4px 0;
}
.nb-trick .lbl { color: var(--purple); font-weight: 700; margin-right: 6px; }

.nb-facts { display: grid; grid-template-columns: max-content 1fr; column-gap: 12px; }
.nb-facts .k { color: var(--red); font-weight: 700; white-space: nowrap; }
.nb-facts .k::after { content: " →"; color: var(--ink2); font-weight: 400; }

.nb-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: 19px;
    line-height: 1.45;
    background: rgba(255, 255, 255, .5);
}
.nb-table th, .nb-table td {
    padding: 4px 12px;
    text-align: left;
    vertical-align: top;
    border-right: 1.8px solid var(--ink2);
    border-bottom: 1.8px solid var(--ink2);
}
.nb-table tr > :first-child { border-left: 1.8px solid var(--ink2); }
.nb-table thead th {
    border-top: 1.8px solid var(--ink2);
    font-weight: 700;
    color: var(--red);
    background: linear-gradient(178deg, var(--hl-y), rgba(255, 233, 72, .45));
}
.nb-table thead th:first-child { border-top-left-radius: 10px 4px; }
.nb-table thead th:last-child { border-top-right-radius: 4px 10px; }

.nb-flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 4px; padding: 4px 0; }
.nb-flow .step {
    padding: 4px 14px;
    line-height: 1.35;
    border: 2.2px solid var(--green);
    border-radius: 18px 8px 20px 6px / 8px 20px 6px 18px;
    background: rgba(150, 236, 165, .18);
    text-align: center;
}
.nb-flow .arr {
    font-family: 'Segoe UI Symbol', 'DejaVu Sans', sans-serif;
    font-size: 24px;
    color: var(--red);
}

.nb-compare { display: grid; grid-template-columns: 1fr 1fr; }
.nb-compare > div { padding: 0 14px; }
.nb-compare > div + div { border-left: 2.5px solid var(--ink2); border-image: linear-gradient(transparent 2%, var(--ink2) 6% 94%, transparent 98%) 1; }
.nb-compare h4 { margin: 0 0 2px; font-size: 21px; color: var(--red); }
.nb-compare h4 span { background: linear-gradient(100deg, transparent 1%, var(--hl-p) 3% 96%, transparent 99%); padding: 0 4px; }
.nb-compare .nb-list li { padding-left: 26px; }

/* ---------- quick revision page ---------- */
.nb-page.is-revision { background-color: #fbfdff; }
.nb-rev-head {
    align-self: center;
    margin: 0 0 6px;
    padding: 4px 26px 6px;
    font-size: 34px;
    font-weight: 700;
    color: var(--red);
    border: 3px solid var(--red);
    border-radius: 255px 18px 225px 18px / 18px 225px 18px 255px;
    background: rgba(255, 243, 154, .7);
    transform: rotate(-1.5deg);
}
.nb-check { list-style: none; margin: 0; padding: 0; }
.nb-check li { position: relative; padding-left: 40px; margin-bottom: 4px; cursor: pointer; }
.nb-check li::before {
    content: "";
    position: absolute;
    left: 4px; top: 6px;
    width: 20px; height: 20px;
    border: 2.2px solid var(--ink2);
    border-radius: 4px 2px 5px 3px;
}
/* Ticked by the student as they revise (screen only; it prints as ticked). */
.nb-check li.done::after {
    content: "✓";
    position: absolute;
    left: 8px; top: -6px;
    font-family: 'Segoe UI Symbol', 'DejaVu Sans', sans-serif;
    font-size: 26px;
    color: var(--green);
}

/* ---------- print = PDF download ---------- */
@media print {
    @page { size: A4; margin: 0; }
    html, body { height: auto !important; min-height: 0 !important; }
    .nb-pages { display: block; padding: 0; gap: 0; zoom: 1 !important; }
    /* Breaking *before* every sheet but the first leaves nothing after the
       last one to spill onto a blank page. */
    .nb-page {
        width: 210mm;
        height: 296.5mm;
        box-shadow: none;
        border-radius: 0;
        margin: 0;
    }
    .nb-page + .nb-page { break-before: page; page-break-before: always; }
}
