/* 中大數學系大平台 — "blackboard" theme.
   One loud element (the chalkboard with a chalk-drawn Riemann sum on login and home); everything else quiet:
   white top bar, cool paper background, board-green for actions, chalk yellow only on the board.
   Plain CSS on Filament's fi-* classes, no Tailwind build. */
:root {
    --board: #24453a;
    --board-hi: #2e5747;
    --chalk: #f4f1e6;
    --chalk-yellow: #f0c94a;
    --paper: #f4f5f3;
    --ink: #1c2421;
    --muted: #66706b;
    --rule: #e2e5e1;
    --chalk-font: 'LXGW WenKai TC', 'Noto Sans TC', serif;
}

/* ---------- brand mark (top bar + login) ---------- */
.portal-brand { display: inline-flex; align-items: center; gap: .55rem; white-space: nowrap; color: var(--ink); }
.dark .portal-brand { color: #fff; }
.portal-brand img { width: 1.9rem; height: 1.9rem; }
.portal-brand__title { font-size: 1.02rem; font-weight: 700; letter-spacing: .02em; }
.portal-brand__light { font-weight: 400; color: var(--muted); margin-left: .3rem; }
.dark .portal-brand__light { color: rgb(255 255 255 / .6); }

/* ---------- shell ---------- */
html:not(.dark) .fi-body { background: var(--paper); }
html:not(.dark) .fi-topbar { box-shadow: none; border-bottom: 1px solid var(--rule); }
.fi-sidebar-item-active .fi-sidebar-item-btn { position: relative; }
.fi-sidebar-item-active .fi-sidebar-item-btn::before {
    content: ""; position: absolute; left: -.6rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 3px; background: var(--chalk-yellow);
}

/* ---------- the board ---------- */
.portal-board {
    position: relative; color: var(--chalk); overflow: hidden;
    background:
        radial-gradient(120% 90% at 20% 10%, rgb(255 255 255 / .06), transparent 60%),
        radial-gradient(80% 60% at 85% 90%, rgb(0 0 0 / .18), transparent 70%),
        var(--board);
    box-shadow: inset 0 0 0 10px #5b4a36, inset 0 0 0 12px #3f3325, inset 0 0 40px rgb(0 0 0 / .35);
}
.portal-board__ledge { position: absolute; left: 6%; right: 6%; bottom: 10px; height: 6px; border-radius: 3px; background: #4a3c2c; }
.portal-board__ledge::after { content: ""; position: absolute; right: 12%; top: -4px; width: 26px; height: 6px; border-radius: 3px; background: var(--chalk); opacity: .9; }

.portal-chalk { display: block; width: 100%; height: auto; color: var(--chalk); }
.portal-chalk__axes { stroke: var(--chalk); stroke-width: 2; opacity: .75; }
.portal-chalk__curve { stroke: var(--chalk); stroke-width: 3.2; }
.portal-chalk__sum rect { stroke: var(--chalk-yellow); stroke-width: 1.6; fill: rgb(240 201 74 / .13); }
.portal-chalk__text { font-family: var(--chalk-font); font-size: 20px; fill: var(--chalk); opacity: .85; }

/* the single moment of motion: the curve is drawn once on the login screen */
.portal-chalk--draw .portal-chalk__curve { stroke-dasharray: 1; stroke-dashoffset: 1; animation: portal-draw 1.6s .3s ease-out forwards; }
.portal-chalk--draw .portal-chalk__sum { opacity: 0; animation: portal-fade .8s 1.6s ease-out forwards; }
@keyframes portal-draw { to { stroke-dashoffset: 0; } }
@keyframes portal-fade { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .portal-chalk--draw .portal-chalk__curve { animation: none; stroke-dashoffset: 0; }
    .portal-chalk--draw .portal-chalk__sum { animation: none; opacity: 1; }
}

/* ---------- login: board on the left, form on the right ---------- */
.fi-simple-layout:has(.portal-board) { background: var(--paper); }
.dark .fi-simple-layout:has(.portal-board) { background: rgb(24 24 27); }
.fi-simple-layout > .portal-board { position: fixed; inset: 0 auto 0 0; width: 52vw; display: flex; align-items: center; justify-content: center; }
.fi-simple-layout:has(> .portal-board) .fi-simple-main-ctn { margin-left: 52vw; width: 48vw; max-width: 48vw; }
/* the system-account submit is secondary to the NCU button above it */
.fi-simple-layout:has(> .portal-board) form .fi-ac-btn-action.fi-color-primary {
    background: transparent !important; color: var(--board-hi) !important; box-shadow: inset 0 0 0 1.5px var(--board-hi) !important;
}
.fi-simple-layout:has(> .portal-board) form .fi-ac-btn-action.fi-color-primary:hover { background: rgb(36 69 58 / .06) !important; }
.dark .fi-simple-layout:has(> .portal-board) form .fi-ac-btn-action.fi-color-primary { color: #9fd0b8 !important; box-shadow: inset 0 0 0 1.5px #9fd0b8 !important; }
.portal-board .portal-board__inner { width: min(34rem, 80%); }
.portal-board__title { font-family: var(--chalk-font); font-size: clamp(2rem, 3.4vw, 3rem); line-height: 1.2; letter-spacing: .04em; }
.portal-board__lead { margin: .6rem 0 1.6rem; font-size: 1rem; color: rgb(244 241 230 / .78); }
.portal-board__formula { margin-top: 1rem; font-family: var(--chalk-font); font-size: 1.25rem; color: rgb(244 241 230 / .8); }
.portal-board__formula sub, .portal-board__formula sup { font-size: .7em; }

.fi-simple-layout:has(> .portal-board) .fi-simple-main { box-shadow: none !important; background: transparent !important; --tw-ring-shadow: 0 0 #0000 !important; }
.fi-simple-header .fi-logo { height: auto !important; }
.fi-simple-header .portal-brand img { width: 2.6rem; height: 2.6rem; }
.fi-simple-header .portal-brand__title { font-size: 1.25rem; }
.fi-simple-header-heading { font-size: 1.5rem !important; }

.portal-sso { display: grid; gap: .5rem; margin-bottom: .25rem; }
.portal-sso__main { width: 100%; justify-content: center; }
.portal-sso__hint { font-size: .85rem; color: var(--muted); text-align: center; }
.portal-sso__error { font-size: .875rem; color: rgb(185 28 28); text-align: center; }
.portal-sso__divider { display: flex; align-items: center; gap: .75rem; margin-top: 1.1rem; color: var(--muted); font-size: .85rem; }
.portal-sso__divider::before, .portal-sso__divider::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.dark .portal-sso__divider::before, .dark .portal-sso__divider::after { border-color: rgb(255 255 255 / .12); }
.portal-sso__alt { margin-top: 1.25rem; text-align: center; font-size: .85rem; color: var(--muted); }
.portal-sso__alt a { color: var(--board-hi); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.dark .portal-sso__alt a { color: #9fd0b8; }

.portal-int { display: inline-flex; align-items: center; gap: .1em; }
.portal-int__lims { display: inline-flex; flex-direction: column; font-size: .6em; line-height: 1.05; margin-right: .25em; }

@media (max-width: 900px) {
    .fi-simple-layout > .portal-board { position: relative; inset: auto; width: 100%; padding: 2rem 0 2.5rem; }
    .fi-simple-layout:has(> .portal-board) .fi-simple-main-ctn { margin-left: 0; width: 100%; max-width: none; }
    .portal-board .portal-chalk { display: none; }
    .portal-board__formula { display: none; }
}

/* ---------- home ---------- */
.portal-home { display: grid; gap: 2rem; }
.portal-board--strip { border-radius: .75rem; display: grid; grid-template-columns: 1fr minmax(0, 300px); align-items: center; gap: 1rem; padding: 1.75rem 2rem 2rem; }
.portal-board__greet { font-family: var(--chalk-font); font-size: clamp(1.6rem, 2.6vw, 2.2rem); line-height: 1.3; }
.portal-board__meta { margin-top: .6rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; color: rgb(244 241 230 / .75); font-size: .9rem; }
.portal-tag { font-size: .8rem; padding: .1rem .55rem; border: 1px dashed rgb(244 241 230 / .55); border-radius: .4rem; color: var(--chalk); }
.portal-chalk--small { max-width: 300px; justify-self: end; }
@media (max-width: 720px) { .portal-board--strip { grid-template-columns: 1fr; } .portal-chalk--small { display: none; } }

/* features as a table of contents, not cards */
.portal-index { display: grid; gap: 2rem 3rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); align-items: start; }
.portal-index__title { font-size: .95rem; font-weight: 700; color: var(--ink); padding-bottom: .5rem; border-bottom: 2px solid var(--ink); margin-bottom: .25rem; }
.dark .portal-index__title { color: #fff; border-color: rgb(255 255 255 / .6); }
.portal-index__list { list-style: none; margin: 0; padding: 0; }
.portal-index__list li + li { border-top: 1px solid var(--rule); }
.dark .portal-index__list li + li { border-color: rgb(255 255 255 / .08); }
.portal-index__link { display: flex; gap: .8rem; align-items: flex-start; padding: .75rem .4rem; border-radius: .4rem; }
.portal-index__link:hover { background: rgb(36 69 58 / .06); }
.dark .portal-index__link:hover { background: rgb(255 255 255 / .05); }
.portal-index__link:focus-visible { outline: 2px solid var(--board-hi); outline-offset: 2px; }
.portal-index__icon { width: 1.25rem; height: 1.25rem; margin-top: .1rem; color: var(--board-hi); flex-shrink: 0; }
.dark .portal-index__icon { color: #9fd0b8; }
.portal-index__text { display: grid; gap: .1rem; }
.portal-index__label { font-weight: 600; color: var(--ink); }
.dark .portal-index__label { color: #fff; }
.portal-index__desc { font-size: .82rem; color: var(--muted); line-height: 1.45; }
.dark .portal-index__desc { color: rgb(255 255 255 / .55); }

/* ---------- misc ---------- */
.portal-chart { position: relative; height: 16rem; }
.portal-ckeditor .ck-editor__editable { min-height: 16rem; }
.portal-ckeditor .ck.ck-editor__main > .ck-editor__editable { background: #fff; color: #111827; }
