/* ==========================================================================
   VeeDee 48 Half Hours planner  ·  plan.css
   --------------------------------------------------------------------------
   Load AFTER site.css on plan.html:
       <link rel="stylesheet" href="/site.css">
       <link rel="stylesheet" href="/plan.css">
   Everything is scoped under .plan so it can't affect the shared nav/footer.
   Colours follow the site theme (html[data-theme]) set by site.js.
   ========================================================================== */

/* ── Planner tokens (map the planner's names onto the site palette) ───────── */
.plan {
    --red:   var(--crimson);
    --plum:  var(--purple);
    --pink:  var(--blush);
    --title:  'Montserrat', system-ui, sans-serif;
    --script: 'Montserrat', 'Air America', cursive;

    /* dark theme (site default) */
    --panel: #2a1238;
    --ink:   #EDEBD7;
    --mute:  #b9a4c2;
    --line:  #46245a;
    --empty: #3b1f4b;
    --sum:   var(--gold);

    color: var(--ink);
    font-size: 14px;
    padding-bottom: 16px;
}
html[data-theme="light"] .plan {
    --panel: #ffffff;
    --ink:   #2b1634;
    --mute:  #6b5a72;
    --line:  #e0d3dc;
    --empty: #e3dccb;
    --sum:   var(--plum);
}

/* Compact hero: this is a tool page, so the board should appear sooner */
.page-hero.compact {
    max-width: none;                    /* line up with the planner's edges instead of the 960px text column */
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: 48px; align-items: center;
    padding: 130px 24px 12px;
}
.page-hero.compact .hero-copy .page-intro { max-width: none; }   /* right column: let the text use its column */
@media (max-width: 900px) { .page-hero.compact { padding-top: 120px; } }
@media (max-width: 820px) { .page-hero.compact { grid-template-columns: minmax(0, 1fr); row-gap: 8px; } }
@media (max-width: 600px) { .page-hero.compact { padding-top: 170px; } }

/* ── Planner rules (scoped copy of the original page CSS) ─────────────────── */
.plan .plan-bar {
            background: var(--plum);
            color: #EDEBD7;
            display: flex;
            flex-wrap: wrap;
            gap: 12px 24px;
            align-items: center;
            padding: 14px 24px
        }

        .plan .nav {
            display: flex;
            gap: 8px;
            align-items: center
        }

        .plan button {
            font: inherit;
            cursor: pointer;
            border: 0;
            border-radius: 999px;
            padding: 8px 16px;
            background: var(--pink);
            color: var(--plum);
            font-weight: 600
        }

            .plan button:hover {
                filter: brightness(1.05)
            }

            .plan button:focus-visible, .plan input:focus-visible, .plan textarea:focus-visible {
                outline: 3px solid var(--teal);
                outline-offset: 2px
            }

            .plan button.on, .plan button.primary {
                background: var(--red);
                color: #fff
            }

        .plan .nav .range {
            font-family: var(--title);
            font-style: italic;
            font-weight: 800;
            font-size: 24px;
            min-width: 170px;
            text-align: center
        }

        .plan .plan-main {
            display: grid;
            grid-template-columns: 290px minmax(0, 1fr);
            grid-template-areas: "side board" "side notes";
            gap: 20px;
            padding: 20px 24px;
            align-items: start
        }

        .plan aside {
            background: var(--panel);
            border: 2px solid var(--line);
            border-radius: 20px;
            padding: 14px;
            position: sticky;
            top: 12px
        }

            .plan aside h2, .plan .sum {
                font-family: var(--title);
                font-style: italic;
                font-weight: 800;
                margin: 0 0 10px;
                font-size: 18px
            }

        .plan .task {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 6px;
            border-radius: 14px;
            border: 2px solid transparent;
            cursor: pointer
        }

            .plan .task:hover {
                background: var(--empty)
            }

            .plan .task.sel {
                border-color: var(--red);
                background: var(--empty)
            }

            .plan .task input[type=color] {
                appearance: none;
                border: 0;
                padding: 0;
                width: 30px;
                height: 30px;
                border-radius: 10px;
                background: none;
                cursor: pointer;
                flex: none
            }

                .plan .task input[type=color]::-webkit-color-swatch-wrapper {
                    padding: 0
                }

                .plan .task input[type=color]::-webkit-color-swatch {
                    border: 0;
                    border-radius: 10px
                }

            .plan .task input[type=text] {
                flex: 1;
                min-width: 0;
                border: 0;
                background: transparent;
                color: inherit;
                font: inherit;
                font-size: 17px;
                font-weight: 600;
                padding: 4px;
                border-radius: 6px
            }

            .plan .task .hrs {
                font-size: 14px;
                color: var(--mute);
                font-weight: 600;
                min-width: 38px;
                text-align: right
            }

            .plan .task .del {
                padding: 2px 8px;
                background: none;
                color: var(--mute);
                font-size: 16px
            }

                .plan .task .del:hover {
                    color: var(--red)
                }

        .plan .side-actions {
            display: flex;
            gap: 8px;
            flex-wrap: wrap;
            margin-top: 10px
        }

        .plan .hint {
            font-family: var(--script);
            font-size: 19px;
            color: var(--mute);
            margin: 12px 4px 0;
            line-height: 1.2
        }

        .plan .sum {
            min-height: 26px;
            margin-bottom: 12px;
            font-size: 20px
        }

            .plan .sum span {
                font-family: var(--script);
                font-style: normal;
                font-weight: 600;
                font-size: 26px;
                color: var(--plum)
            }

        .plan .scroller {
            overflow-x: auto;
            padding-bottom: 6px
        }

        .plan .board {
            min-width: 720px
        }

        .plan .hours, .plan .row {
            display: grid;
            grid-template-columns: 86px 1fr;
            align-items: center;
            gap: 8px
        }

        .plan .hours {
            margin-bottom: 6px;
            color: var(--mute);
            font-size: 11px;
            font-weight: 600
        }

            .plan .hours div:last-child, .plan .cells {
                display: grid;
                grid-template-columns: repeat(48,1fr);
                gap: 2px
            }

            .plan .hours span {
                grid-column: span 2;
                text-align: left;
                padding-left: 1px
            }

        .plan .row {
            margin-bottom: 6px
        }

        .plan .dl {
            font-weight: 600;
            font-size: 13px;
            line-height: 1.1
        }

            .plan .dl small {
                display: block;
                color: var(--mute);
                font-weight: 400;
                font-size: 11px
            }

        .plan .row.today .dl {
            color: var(--red)
        }

        .plan .c {
            height: 34px;
            background: var(--empty);
            position: relative;
            touch-action: pan-y;
            transition: opacity .12s
        }

            .plan .c:nth-of-type(odd) {
                border-radius: 10px 3px 3px 10px
            }

            .plan .c:nth-of-type(even) {
                border-radius: 3px 10px 10px 3px
            }

        .plan .month .c {
            height: 15px
        }

            .plan .month .c:nth-of-type(odd) {
                border-radius: 5px 2px 2px 5px
            }

            .plan .month .c:nth-of-type(even) {
                border-radius: 2px 5px 5px 2px
            }

        .plan .month .row {
            margin-bottom: 3px
        }

        .plan .c.dim {
            opacity: .25
        }

        .plan .c.note::after {
            content: "";
            position: absolute;
            right: 3px;
            top: 3px;
            width: 6px;
            height: 6px;
            border-radius: 50%;
            background: var(--ink);
            opacity: .7
        }

        .plan .month .c.note::after {
            width: 4px;
            height: 4px;
            right: 1px;
            top: 1px
        }

        .plan .painting .c {
            cursor: crosshair
        }

        .plan .pop {
            position: fixed;
            z-index: 20;
            background: var(--panel);
            border: 2px solid var(--plum);
            border-radius: 18px;
            padding: 14px;
            width: 260px;
            box-shadow: 0 10px 30px rgba(26,8,38,.3)
        }

            .plan .pop h3 {
                margin: 0 0 8px;
                font-size: 14px
            }

            .plan .pop textarea {
                width: 100%;
                height: 80px;
                border-radius: 10px;
                border: 2px solid var(--line);
                background: var(--bg);
                color: var(--ink);
                font: inherit;
                padding: 8px;
                resize: none;
                -webkit-user-select: text;
                user-select: text
            }

            .plan .pop .btns {
                display: flex;
                gap: 8px;
                margin-top: 8px
            }

        .plan .toast {
            position: fixed;
            left: 50%;
            bottom: calc(20px + env(safe-area-inset-bottom,0px));
            transform: translateX(-50%);
            background: var(--ink);
            color: var(--bg);
            padding: 10px 18px;
            border-radius: 999px;
            font-weight: 600;
            z-index: 30
        }

        .plan .board.day {
            min-width: 0;
            max-width: 640px
        }

        .plan .day .row {
            grid-template-columns: 56px 1fr;
            margin-bottom: 3px
        }

        .plan .day .hours {
            display: none
        }

        .plan .day .c {
            height: 32px;
            border-radius: 10px !important;
            display: flex;
            align-items: center;
            padding: 0 12px;
            font-weight: 600;
            font-size: 13px;
            overflow: hidden;
            white-space: nowrap
        }

            .plan .day .c i {
                font-style: normal;
                font-weight: 400;
                opacity: .8;
                margin-left: 10px;
                font-family: var(--script);
                font-size: 18px;
                overflow: hidden;
                text-overflow: ellipsis
            }

            .plan .day .c.note::after {
                display: none
            }

        .plan .day .dl {
            color: var(--mute);
            font-size: 12px
        }

        .plan .painting.day .c {
            touch-action: none
        }

        .plan .dl[data-go] {
            cursor: pointer
        }

            .plan .dl[data-go]:hover {
                text-decoration: underline
            }

        .plan .dlg {
            left: 50%;
            top: 50%;
            transform: translate(-50%,-50%);
            width: min(440px,92vw);
            max-height: 90vh;
            overflow: auto
        }

            .plan .dlg p {
                margin: 0;
                color: var(--mute);
                font-size: 13px;
                line-height: 1.4
            }

            .plan .dlg label {
                display: block;
                margin: 12px 0 4px;
                font-weight: 600;
                font-size: 13px
            }

            .plan .dlg .chk {
                display: flex;
                gap: 8px;
                align-items: center
            }

            .plan .dlg input, .plan .dlg textarea {
                -webkit-user-select: text;
                user-select: text
            }

                .plan .dlg input[type=date], .plan .dlg input[type=number] {
                    width: 100%;
                    padding: 8px;
                    border-radius: 10px;
                    border: 2px solid var(--line);
                    background: var(--bg);
                    color: var(--ink);
                    font: inherit
                }

            .plan .dlg textarea {
                height: 130px;
                margin-top: 10px
            }

        .plan .btns.wrap {
            flex-wrap: wrap
        }

        .plan [hidden] {
            display: none !important
        }

        @media (max-width:820px) {
            .plan .plan-main {
                grid-template-columns: minmax(0, 1fr);
                grid-template-areas: "side" "board" "notes";
                padding: 14px
            }

            .plan aside {
                position: static
            }

            .plan .plan-bar {
                padding: 12px 14px
            }

            .plan .hours span:nth-child(even) {
                visibility: hidden
            }
        }

        .plan .task input[type=text] {
            pointer-events: none;
            cursor: pointer
        }

            .plan .task input[type=text].editing {
                pointer-events: auto;
                cursor: text;
                background: var(--bg);
                outline: 2px solid var(--teal)
            }

        @media(max-width:820px) {
        }

        /* compact layouts: l2 = 2 rows of 12h (<=1600px), l3 = 3 rows of 8h (<=1060px), l6 = 6 rows of 4h (<=480px) */
        .plan .board.l2, .plan .board.l3, .plan .board.l6 {
            min-width: 0
        }

        .plan .l2 .hours, .plan .l3 .hours, .plan .l6 .hours {
            display: none
        }

        .plan .l2 .row, .plan .l3 .row, .plan .l6 .row {
            grid-template-columns: minmax(0,1fr);
            gap: 4px;
            margin-bottom: 14px
        }

        .plan .l2 .dl, .plan .l3 .dl, .plan .l6 .dl {
            font-size: 14px;
            padding-left: 2px
        }

            .plan .l2 .dl small, .plan .l3 .dl small, .plan .l6 .dl small {
                display: inline;
                margin-left: 6px;
                font-size: 12px
            }

        .plan .l2 .cells {
            grid-template-columns: 38px repeat(24,minmax(0,1fr))
        }

        .plan .l3 .cells {
            grid-template-columns: 38px repeat(16,minmax(0,1fr))
        }

        .plan .l6 .cells {
            grid-template-columns: 38px repeat(8,minmax(0,1fr))
        }

        .plan .seg {
            color: var(--mute);
            font-size: 11px;
            font-weight: 600;
            align-self: center
        }

        .plan .l2 .c, .plan .l3 .c, .plan .l6 .c {
            height: auto;
            aspect-ratio: 1;
            max-height: 36px;
            align-self: start
        }

        .plan .l3 .c, .plan .l6 .c {
            max-height: 40px
        }

            .plan .l6 .c.note::after {
                width: 5px;
                height: 5px
            }
        /* month: fixed short rows, tight spacing */
        .plan .month.l2 .row, .plan .month.l3 .row, .plan .month.l6 .row {
            gap: 2px;
            margin-bottom: 6px
        }

        .plan .month.l2 .cells, .plan .month.l3 .cells, .plan .month.l6 .cells {
            grid-auto-rows: 16px
        }

        .plan .month.l2 .c, .plan .month.l3 .c, .plan .month.l6 .c {
            aspect-ratio: auto;
            height: 16px;
            max-height: none
        }

        .plan .month.l2 .dl, .plan .month.l3 .dl, .plan .month.l6 .dl {
            font-size: 13px;
            line-height: 1.2
        }

        @media (max-width:450px) {
            .plan .plan-bar {
                gap: 8px 12px
            }

            .plan .nav {
                flex-wrap: wrap;
                justify-content: center
            }

                .plan .nav .range {
                    min-width: 0;
                    font-size: 18px;
                    flex: 1 1 auto
                }

                .plan .nav button {
                    padding: 8px 12px
                }

            .plan .l6 .cells {
                grid-template-columns: 32px repeat(8,minmax(0,1fr));
                gap: 2px
            }

            .plan .seg {
                font-size: 10px
            }
        }

/* ── Shell integration + additions ────────────────────────────────────────── */
.plan .sum span { color: var(--sum); }                       /* was hard-wired plum / gold */
.plan .plan-bar { margin: 0 24px; border-radius: 20px; }     /* toolbar is now a rounded strip, not a page header */
.plan aside { top: 92px; min-width: 0; grid-area: side; }                                    /* sit below the fixed site nav when sticky */
.plan .board, .plan .task { -webkit-user-select: none; user-select: none; }   /* only the board/tasks, so notes stay selectable */
.plan .dlg .btns { margin-top: 10px; }
.plan .dlg .dlg-h { margin: 16px 0 0; font-weight: 700; color: var(--ink); }

/* Notes */
.plan .plan-main > section[aria-label="Planner"] { grid-area: board; min-width: 0; }
.plan .plan-notes { grid-area: notes; min-width: 0; padding: 0; }
.plan .plan-notes h2 { font-family: var(--title); font-style: italic; font-weight: 800; font-size: 18px; margin: 0 0 12px; }
.plan .notes-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.plan .note-card { background: var(--panel); border: 2px solid var(--line); border-radius: 20px; padding: 14px; }
.plan .note-card label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 13px; }
.plan .note-card textarea {
    width: 100%; min-height: 150px; resize: vertical; padding: 10px; border-radius: 12px;
    border: 2px solid var(--line); background: var(--bg); color: var(--ink);
    font: inherit; font-size: 14px; line-height: 1.5;
    -webkit-user-select: text; user-select: text;
}
.plan .note-meta { margin-top: 6px; font-size: 12px; color: var(--mute); }
.plan .note-status { margin: 10px 4px 0; font-size: 12px; color: var(--mute); min-height: 1.2em; }

@media (max-width: 820px) {
    .plan .plan-bar { margin: 0 14px; }
}


/* ── Keyboard access ──────────────────────────────────────────────────────── */
.plan .c:focus-visible { outline: 3px solid var(--teal); outline-offset: 1px; z-index: 2; }
.plan .task:focus-visible,
.plan .dl[data-go]:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 10px; }

.plan .kbd { margin: 10px 4px 0; font-size: 13px; color: var(--mute); }
.plan .kbd summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.plan .kbd ul { list-style: none; margin: 8px 0 0; padding: 0; line-height: 2; }
.plan .kbd kbd {
    font: inherit; font-size: 11px; font-weight: 600; padding: 1px 6px;
    border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
    background: var(--panel); color: var(--ink);
}


/* ── Backup reminder (shows after 7 days with unsaved changes) ────────────── */
.plan .backup-nudge {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    margin: 14px 24px 0; padding: 12px 16px;
    border: 2px solid var(--gold); border-radius: 16px; background: var(--panel);
}
.plan .backup-nudge p { margin: 0; flex: 1 1 280px; font-size: 14px; line-height: 1.45; }
.plan .backup-nudge .btns { display: flex; flex-wrap: wrap; gap: 8px; }
.plan .dlg .dlg-last { margin-top: 8px; font-weight: 600; color: var(--ink); }
@media (max-width: 820px) { .plan .backup-nudge { margin: 12px 14px 0; } }


/* "What to include" checkboxes in the print dialog */
.plan .dlg .chk { display: flex; align-items: flex-start; gap: 10px; margin: 12px 0 0; font-size: 14px; line-height: 1.4; cursor: pointer; }
.plan .dlg .chk input { width: 18px; height: 18px; margin: 1px 0 0; padding: 0; flex: none; accent-color: var(--crimson); }


/* ── Print view: A4, styled like the calculator printout ──────────────────── */
.plan .print-only { display: none; }

@media print {
    html, body { background: #fff !important; color: #1a0826; }
    body > nav, .page-pipeline-bg, .skip-link, footer, .page-hero,
    .plan .plan-bar, .plan aside, .plan .sum, .plan .plan-notes, .plan .backup-nudge,
    .plan .pop, .plan .toast, .plan .dlg { display: none !important; }

    /* always print in light colours, whatever theme is on screen */
    html .plan, html[data-theme="dark"] .plan, html[data-theme="light"] .plan {
        --ink: #1a0826; --mute: #4a3a55; --line: #bbb; --empty: #ececec; --panel: #fff; --bg: #fff; --sum: #1a0826;
        color: #1a0826; padding: 0; font-size: 10.5pt; line-height: 1.4;
    }
    .plan * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .plan .print-only { display: block; }

    /* brand band + title (same as the calculator) */
    .plan .print-brand {
        display: flex; align-items: center; gap: 4mm; margin: 0 0 4mm; padding: 3mm 5mm;
        background: #1a0826; color: #EDEBD7; font: 700 14pt 'Montserrat', sans-serif;
    }
    .plan .print-brand img { height: 9mm; width: auto; }
    .plan .print-brand-fb { display: none; color: #d74352; }
    .plan .print-brand-tag { margin-left: auto; font-size: 9pt; font-weight: 500; letter-spacing: .04em; opacity: .85; }
    .plan .print-head { margin: 0 0 2mm; }
    .plan .print-title { font: 400 17pt 'ST Simple Square', 'Montserrat', sans-serif; line-height: 1.1; color: #6d1559; }
    .plan .print-title em { font-style: normal; color: #d74352; }
    .plan .print-range { margin: 1mm 0 0; font-size: 10.5pt; color: #4a3a55; }

    /* the board */
    .plan .plan-main { display: block; padding: 0; }
    .plan .scroller { overflow: visible; padding: 0; }
    .plan .board, .plan .board.day, .plan .board.month { min-width: 0 !important; max-width: none; }
    .plan .hours span:nth-child(even) { visibility: visible; }
    .plan .row { break-inside: avoid; margin-bottom: 4px; }
    .plan .dl { font-size: 10pt; }
    .plan .row.today .dl { color: #1a0826; }
    .plan .c { height: 22px; border: 1px solid #d0d0d0; }
    .plan .c.dim { opacity: 1; }
    .plan .month .c { height: 8px; }
    .plan .month .row { margin-bottom: 1px; }
    .plan .month .dl { font-size: 8pt; line-height: 1.1; }   /* 31 rows + tasks + footer must fit one A4 landscape page */
    .plan .day .row { grid-template-columns: 44px 1fr; margin-bottom: 1px; }
    .plan .day .c { height: 13px; padding: 0 8px; font-size: 9px; border-radius: 4px !important; }
    .plan .day .c i { font-size: 9px; font-family: inherit; }

    /* tasks, under the plan */
    .plan .print-tasks { margin-top: 3mm; break-inside: avoid; }
    .plan .print-tasks:empty, .plan .print-notes:empty { display: none; }
    .plan .print-tasks .sh, .plan .print-notes .sh { margin: 0 0 2mm; font-size: 11pt; font-weight: 700; color: #6d1559; }
    .plan .print-tasks .sh span { font-weight: 500; color: #4a3a55; }
    .plan .ptasks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 8mm; }
    .plan .print-tasks[data-view="day"] .ptasks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .plan .pt { display: flex; align-items: center; gap: 2mm; padding: 1mm 0; border-bottom: 1px solid #ccc; font-size: 9.5pt; }
    .plan .pt i { flex: none; width: 3mm; height: 3mm; border: 1px solid rgba(0,0,0,.25); border-radius: 1mm; }
    .plan .pt span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
    .plan .pt b { margin-left: auto; font-weight: 700; }

    /* notes the user chose to include */
    .plan .print-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(80mm, 1fr)); gap: 4mm; margin-top: 5mm; }
    .plan .print-notes section { break-inside: avoid; padding: 3mm 4mm; border-radius: 2mm; background: #f6eef3; }
    .plan .print-notes p { margin: 0; font-size: 10pt; line-height: 1.4; white-space: pre-wrap; color: #1a0826; }
    .plan .print-notes ul { margin: 0; padding-left: 4mm; }
    .plan .print-notes li { font-size: 9.5pt; line-height: 1.4; }

    /* footer line (same as the calculator) */
    .plan .print-foot { margin: 4mm 0 0; padding-top: 2mm; border-top: 1px solid #ddd; font-size: 9pt; color: #6d1559; }
}
