/* Teacher workbench: shared clay primitives for the home, board and teaching
   views. Scoped to those three view ids on purpose -- the rest of the console
   keeps its own theme. Home loads first, so board.css and teaching.css build
   on the tokens and primitives declared here.

   The visual language is the approved claymorphism one in
   docs/plans/teacher-workbench-ui.html: cream canvas, white cards with a
   3px ink rim and a hard 4px offset shadow, green primary, pastel accents.
   No webfont download: the display face falls back to PingFang SC. */

#view-home.tw-view,
#view-board.tw-view,
#view-teaching.tw-view {
    --tw-bg: #FFF9F5;
    --tw-surface: #FFFFFF;
    --tw-surface-2: #FFF1E8;
    --tw-surface-3: #FFE6D8;
    --tw-ink: #4A4453;
    --tw-ink-2: #6E6579;
    --tw-ink-3: #948C9C;
    --tw-rim: rgba(96, 84, 74, 0.22);
    --tw-line: rgba(96, 84, 74, 0.14);
    --tw-accent: #52A277;
    --tw-accent-hover: #458C66;
    --tw-accent-ink: #FFFFFF;
    --tw-accent-soft: #E3F6EC;
    --tw-urgent: #C2673F;
    --tw-urgent-soft: #FFE8DC;
    --tw-card-a: #DCF3E6;
    --tw-card-b: #FFE4D2;
    --tw-card-c: #EDE6FE;
    --tw-card-d: #E3EFFB;
    --tw-card-e: #FFF2CC;
    --twb-shadow: 0 8px 24px rgba(120, 100, 80, 0.10);
    --twb-shadow-sm: 0 3px 10px rgba(120, 100, 80, 0.08);
    --twb-shadow-hover: 0 14px 32px rgba(120, 100, 80, 0.14);
    --tw-ease: cubic-bezier(0.2, 0.6, 0.2, 1);

    background: var(--tw-bg);
    color: var(--tw-ink);
    font-family: Nunito, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

html.dark #view-home.tw-view,
html.dark #view-board.tw-view,
html.dark #view-teaching.tw-view {
    --tw-bg: #0F1419;
    --tw-surface: #171D24;
    --tw-surface-2: #1E262E;
    --tw-surface-3: #263039;
    --tw-ink: #E6EDF3;
    --tw-ink-2: #AEBAC7;
    --tw-ink-3: #8695A6;
    --tw-rim: #93A4BC;
    --tw-line: rgba(255, 255, 255, 0.14);
    --tw-accent: #4ADE80;
    --tw-accent-hover: #7FCFA8;
    --tw-accent-ink: #0B2415;
    --tw-accent-soft: #16351F;
    --tw-urgent: #E8A87C;
    --tw-urgent-soft: #3A2318;
    --tw-card-a: #1F3A2A;
    --tw-card-b: #3A2622;
    --tw-card-c: #1D1D28;
    --tw-card-d: #17202A;
    --tw-card-e: #3A331C;
}

#view-home .tw-scroll,
#view-board .tw-scroll,
#view-teaching .tw-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 28px 32px 56px;
}

/* Home is one screen at 1440x900: a tighter gutter and section rhythm keep the
   hero, metrics, today's row, quick tools and the board in view together
   instead of leaving a blank half-page below the fold. Declared before the
   mobile rule below, which then keeps the last word on narrow screens. */
#view-home .tw-scroll { padding: 16px 26px 24px; }
#view-home .tw-page { gap: 18px; }

@media (max-width: 767px) {
    #view-home .tw-scroll,
    #view-board .tw-scroll,
    #view-teaching .tw-scroll { padding: 18px 16px 40px; }
}

.tw-page {
    width: 100%;
    max-width: 1360px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* ---------- type ---------- */
.tw-display,
.tw-hero-title,
.tw-page-head h1,
.tw-card-head h2,
.tw-modal-head h2,
.tw-form h2 {
    font-family: "ZCOOL QingKe HuangYou", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--tw-ink);
}

.tw-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- hero ---------- */
.tw-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    background: var(--tw-card-c);
    border: 1px solid var(--tw-rim);
    border-radius: 18px;
    box-shadow: var(--twb-shadow);
    padding: 16px 22px;
}

.tw-hero-copy { max-width: 780px; }

.tw-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--tw-ink-2);
    background: var(--tw-surface);
    border: 1px solid var(--tw-rim);
    border-radius: 999px;
    padding: 4px 10px;
    box-shadow: var(--twb-shadow-sm);
}

.tw-hero-title {
    font-size: clamp(24px, 2.6vw, 32px);
    line-height: 1.25;
    margin: 8px 0 4px;
}

.tw-motto {
    display: block;
    margin-top: 6px;
    max-width: min(100%, 760px);
    font-size: 16px;
    font-weight: 600;
    line-height: 1.55;
    color: var(--tw-ink-2);
    overflow-wrap: anywhere;
}

.tw-hl {
    background: #D6F1E2;
    color: #1F5A3D;
    border-radius: 10px;
    padding: 0 8px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.tw-lede {
    color: var(--tw-ink-2);
    font-size: 13.5px;
    line-height: 1.6;
    max-width: 660px;
}

.tw-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.tw-hero-date {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 140px;
    background: var(--tw-surface);
    border: 1px solid var(--tw-rim);
    border-radius: 14px;
    box-shadow: var(--twb-shadow-sm);
    padding: 10px 14px;
}

.tw-hero-date-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tw-ink-3);
}

.tw-hero-date b { font-size: 15px; }

/* ---------- primitives ---------- */
.tw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 800;
    color: var(--tw-ink);
    background: var(--tw-surface);
    border: 1px solid var(--tw-rim);
    border-radius: 14px;
    box-shadow: var(--twb-shadow);
    cursor: pointer;
    transition: transform 120ms var(--tw-ease), box-shadow 120ms var(--tw-ease), background-color 120ms var(--tw-ease);
}

.tw-btn:hover { transform: translate(-1px, -1px); box-shadow: var(--twb-shadow-hover); }
.tw-btn:active { transform: translate(2px, 2px); box-shadow: var(--twb-shadow-sm); }
.tw-btn:focus-visible { outline: 3px solid var(--tw-accent); outline-offset: 3px; }
.tw-btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: var(--twb-shadow-sm); }

.tw-btn-primary { background: #D6F1E2; color: #1F5A3D; }
.tw-btn-primary:hover { background: #C6EAD8; }

.tw-card {
    background: var(--tw-surface);
    border: 1px solid var(--tw-rim);
    border-radius: 16px;
    box-shadow: var(--twb-shadow);
    padding: 16px 18px;
}

.tw-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.tw-card-head h2 { font-size: 19px; }

.tw-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 800;
    color: var(--tw-ink-2);
    padding: 4px 8px;
    border-radius: 8px;
}

.tw-link:hover { color: var(--tw-accent-hover); text-decoration: underline; }

.tw-status {
    font-size: 12px;
    font-weight: 700;
    color: var(--tw-ink-3);
    min-height: 1em;
    margin: 0;
}

.tw-status.is-error { color: var(--tw-urgent); }

.tw-hint { font-size: 12px; color: var(--tw-ink-3); font-weight: 600; }
.tw-footnote { font-size: 12px; color: var(--tw-ink-3); font-weight: 700; text-align: right; }

.tw-loading { font-size: 13px; color: var(--tw-ink-3); font-weight: 700; padding: 8px 0; }

.tw-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 20px;
    text-align: center;
    background: var(--tw-surface);
    border: 3px dashed var(--tw-rim);
    border-radius: 18px;
    color: var(--tw-ink-2);
    font-weight: 700;
}

.tw-empty i { font-size: 28px; color: var(--tw-ink-3); }

/* ---------- metrics ---------- */
/* Three counters, one row, at every width: they are a summary line, not a
   gallery, and wrapping the third one down leaves a band of empty canvas. */
.tw-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.tw-metric {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--tw-rim);
    border-radius: 14px;
    box-shadow: var(--twb-shadow);
    color: #4A4453;
}

.tw-metric-a { background: #DCF3E6; }
.tw-metric-b { background: #FFE4D2; }
.tw-metric-c { background: #FFF6DA; }

html.dark .tw-metric { color: var(--tw-ink); }
html.dark .tw-metric-a { background: var(--tw-card-a); }
html.dark .tw-metric-b { background: var(--tw-card-b); }
html.dark .tw-metric-c { background: var(--tw-card-e); }

.tw-metric-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #5C554B;
}

html.dark .tw-metric-label { color: var(--tw-ink-2); }

.tw-metric b { font-size: 32px; line-height: 1; font-weight: 800; }

.tw-metric i {
    position: absolute;
    right: 14px;
    top: 14px;
    font-size: 16px;
    opacity: 0.45;
}

@media (max-width: 520px) {
    .tw-metric { padding: 12px 12px; }
    .tw-metric b { font-size: 26px; }
    .tw-metric i { display: none; }
}

/* ---------- section head + quick actions ---------- */
.tw-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.tw-section-head h2 { font-size: 20px; }
.tw-section-head p { font-size: 12.5px; color: var(--tw-ink-2); font-weight: 600; margin-top: 2px; }

/* One row of five: the tools are a shortcut strip under the panels, not a
   second page of cards. Each keeps its icon, name and one line of what it
   makes, so five fit across the page at 1440. */
.tw-tools {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}

.tw-tool {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    min-height: 0;
    border: 1px solid var(--tw-rim);
    border-radius: 14px;
    box-shadow: var(--twb-shadow);
    color: #4A4453;
    transition: transform 120ms var(--tw-ease), box-shadow 120ms var(--tw-ease);
}

.tw-tool:hover { transform: translate(-2px, -2px); box-shadow: var(--twb-shadow-hover); }
.tw-tool:focus-visible { outline: 3px solid var(--tw-accent); outline-offset: 3px; }
.tw-tool b { font-size: 15px; font-weight: 800; }
.tw-tool > span:last-child { font-size: 11.5px; line-height: 1.45; color: var(--tw-ink-2); }

.tw-tool-a { background: #DFF6E8; }
.tw-tool-b { background: #FFE3D3; }
.tw-tool-c { background: #ECE6FB; }
.tw-tool-d { background: #E2F0FA; }
.tw-tool-e { background: #FFF3CF; }

html.dark .tw-tool { color: var(--tw-ink); }
html.dark .tw-tool > span:last-child { color: var(--tw-ink-2); }
html.dark .tw-tool-a { background: var(--tw-card-a); }
html.dark .tw-tool-b { background: var(--tw-card-b); }
html.dark .tw-tool-c { background: var(--tw-card-c); }
html.dark .tw-tool-d { background: var(--tw-card-d); }
html.dark .tw-tool-e { background: var(--tw-card-e); }

.tw-tool-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--tw-rim);
    border-radius: 10px;
    background: var(--tw-surface);
    box-shadow: var(--twb-shadow-sm);
    font-size: 13px;
    color: #4A4453;
}

@media (max-width: 1099px) {
    .tw-tools { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .tw-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- home grid ---------- */
.tw-home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
    align-items: start;
}

.tw-home-board { grid-column: span 1; }

@media (min-width: 1100px) {
    .tw-home-board { grid-column: span 2; }
}

.tw-mini-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 767px) {
    .tw-mini-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.tw-mini-col {
    background: var(--tw-surface-2);
    border: 1px solid var(--tw-rim);
    border-radius: 12px;
    padding: 10px;
    min-width: 0;
}

.tw-mini-col h3 {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tw-ink-2);
    margin-bottom: 8px;
}

.tw-mini-task {
    display: block;
    width: 100%;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    color: var(--tw-ink);
    background: var(--tw-surface);
    border: 1px solid var(--tw-rim);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(120, 100, 80, 0.10);
    padding: 6px 8px;
    margin-bottom: 6px;
    cursor: pointer;
}

.tw-mini-task:hover { background: var(--tw-accent-soft); }
.tw-mini-task.is-overdue { color: var(--tw-urgent); }

.tw-mini-empty { font-size: 11px; color: var(--tw-ink-3); font-weight: 600; }

.tw-list { display: flex; flex-direction: column; gap: 2px; }

.tw-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 8px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: var(--tw-ink);
    font-weight: 700;
    font-size: 13px;
}

.tw-list-item:hover { background: var(--tw-surface-2); }
.tw-list-item i { color: var(--tw-ink-3); width: 16px; text-align: center; }
.tw-list-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tw-list-item small { margin-left: auto; color: var(--tw-ink-3); font-weight: 600; flex-shrink: 0; }

/* ---------- today row ---------- */
/* Today's lessons, the digest and the reminder form are one band: three equal
   columns sharing a height, so the row reads as a strip rather than as three
   cards of different depths with canvas under the short ones. teaching2.css
   sizes this grid for the default page; naming the page and the grid parent
   here keeps this rule in front of it whichever file loads last. */
#view-home .tw-page > .tw-today-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 14px;
}

/* The columns share a height, so what is inside them takes up the slack: the
   digest grows into it instead of leaving a white block under a short card. */
#view-home .tw-page > .tw-today-grid > .tw-card { display: flex; flex-direction: column; }
#view-home .tw-page > .tw-today-grid > .tw-card > .tw-card-head { flex-shrink: 0; }
#view-home .tw-page > .tw-today-grid > .tw-card > .tw-digest { flex: 1 1 auto; }

@media (max-width: 1279px) {
    #view-home .tw-page > .tw-today-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* Inside those columns the reminder form is the tallest thing on the page, so
   it carries the least air: each switch keeps its own time beside it instead
   of on a row of its own, and the preview samples the two messages rather
   than holding a whole digest. */
#view-home .tw-remind-form { gap: 8px; }
#view-home .tw-switch-row { padding: 8px 10px; }
#view-home .tw-remind-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}
#view-home .tw-remind-pair .tw-remind-inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}
#view-home .tw-remind-pair .tw-remind-inline .tw-input { width: 92px; }
#view-home .tw-remind-pair .tw-remind-inline > span { font-size: 11px; }
#view-home .tw-remind-preview .tw-digest { min-height: 44px; max-height: 80px; padding: 8px 10px; }

@media (max-width: 520px) {
    #view-home .tw-remind-pair { grid-template-columns: minmax(0, 1fr); }
    #view-home .tw-remind-pair .tw-remind-inline { flex-direction: row; align-items: center; }
}
