/* Courtyard portals: shared paper surfaces and the homepage's original friends. */
.storybook-page {
    --portal-tint: #f4e2cc;
    --portal-line: #ddc4a2;
    --book-accent: #b34032;
    background: #fff4df;
    background-image: none;
    background-size: 5px 5px;
}
.storybook-page.portal-teacher { --book-accent: #22755c; --portal-tint: #e4ebd9; --portal-line: #c3d0b6; }
.storybook-page.student-school { --book-accent: #b54d72; --portal-tint: #f5e2e7; --portal-line: #e0c5cd; }
.storybook-page.portal-resources { --book-accent: #b97720; --portal-tint: #f5e6c4; --portal-line: #dfcca5; }
.storybook-page .site-header,
.storybook-page .student-header {
    width: calc(100% - 48px); max-width: 1360px; margin: 12px auto 0;
    min-height: 146px; padding: 10px 28px;
    grid-template-columns: 185px minmax(0, 1fr) 230px;
    grid-template-rows: 1fr; gap: 18px;
    border: 1px solid #dfcbaa; border-radius: 22px 22px 9px 9px;
    background: linear-gradient(90deg, #fff8eb 5%, #fff8ebed 42%, #fff8eb45 100%),
        url('../images/home-courtyard-background.png') center 37% / cover no-repeat;
    box-shadow: 0 3px 0 #eadcc4, 0 6px 0 #fffaf0, 0 7px 0 #e1cda9;
    overflow: hidden;
}
.storybook-page .back-link, .storybook-page .home-return {
    grid-column: 1; grid-row: 1; justify-self: start;
    position: static; transform: none; color: #71644f; background: none;
    padding: 0; border: 0; gap: 10px; font-size: 12px;
    font-family: var(--font-en); text-decoration: none; min-height: 40px;
}
.portal-seal { display: block; width: 36px; height: 36px; transform: rotate(-5deg); }
.portal-back-label { display: flex; flex-direction: column; gap: 2px; }
.storybook-page .portal-back-label small { margin: 0; font-size: 9px; letter-spacing: .4px; }
.storybook-page .portal-heading {
    grid-column: 2; grid-row: 1; align-self: center; padding: 4px 0;
    background: none; min-width: 0;
}
.portal-eyebrow {
    display: none; align-items: center; gap: 8px; color: var(--book-accent);
    font-family: var(--font-zh); font-size: 12px; letter-spacing: 2px; margin-bottom: 8px;
}
.portal-eyebrow::before { content: ''; width: 20px; height: 1px; background: currentColor; }
.storybook-page .site-header h1, .storybook-page .student-header h1 {
    font-family: var(--font-zh); font-size: 32px; letter-spacing: 3px;
    line-height: 1.3; color: var(--book-accent); margin: 0; text-align: left;
}
.storybook-page .site-header h1 small, .storybook-page .student-header h1 small {
    display: block; font-family: var(--font-en); font-size: 12px; font-weight: 400;
    color: #8c795c; letter-spacing: .5px; margin-top: 3px; line-height: 1.5;
}
.storybook-page .portal-caption { font-size: 13px; color: #786951; margin-top: 6px; line-height: 1.7; }
.storybook-page .portal-art {
    grid-column: 3; grid-row: 1; justify-self: center; align-self: center;
    position: relative; width: 215px; height: 124px; margin: 0;
    filter: drop-shadow(0 7px 4px #76552b1c);
}
.storybook-page .portal-art svg, .storybook-page .portal-art img {
    display: block; width: 100%; height: 100%; object-fit: contain;
    mask-image: none; -webkit-mask-image: none;
}
.storybook-page .teacher-art { width: 150px; height: 124px; }
.storybook-page .student-art { width: 124px; height: 124px; }
.storybook-page .sharing-art { width: 135px; height: 124px; }
.storybook-page .school-rabbit { animation: none; transform: none; filter: none; }
.storybook-page .sticky-top { position: sticky; top: 0; z-index: 40; }
.storybook-page .tab-nav, .storybook-page .category-nav {
    padding: 10px 0 6px; background: #fff4dff5; border: 0;
    backdrop-filter: blur(12px);
}
.storybook-page .tab-nav-inner, .storybook-page .category-nav-inner {
    width: calc(100% - 64px); max-width: 1328px; gap: 8px; flex-wrap: wrap;
}
.storybook-page .tab-btn, .storybook-page .nav-pill, .storybook-page .subject-tab-btn {
    min-height: 32px; padding: 6px 12px; font-size: 13px;
    background: #fffaf0; color: #77634a; border: 1px solid #dfcbaa;
    border-radius: 10px 10px 4px 4px; box-shadow: 0 2px 0 #e7d8bd;
}
.storybook-page .tab-btn.active, .storybook-page .nav-pill.active,
.storybook-page .subject-tab-btn.active {
    color: #fff9ed; background: var(--book-accent); border-color: var(--book-accent);
    box-shadow: inset 0 0 0 2px #fff9ed25, 0 2px 0 #ddc7a5;
}
.storybook-page .container, .storybook-page .student-main {
    width: calc(100% - 48px); max-width: 1360px; margin: 22px auto 30px;
    padding: 30px 32px 34px; border: 1px solid #dfcbaa; border-radius: 10px 18px 10px 10px;
    background: #fffbf3; box-shadow: 0 3px 0 #eadcc4, 0 6px 0 #fffaf0, 0 7px 0 #e1cda9;
}
.storybook-page .sticky-top + .container { margin-top: 10px; }
.storybook-page .container > section { margin-bottom: 32px; }
.storybook-page .container > section:last-child { margin-bottom: 0; }
.storybook-page .section-title, .storybook-page .section-heading {
    font-size: 23px; border-bottom-color: #e7d9c1; margin-bottom: 20px; padding-bottom: 13px;
}
.storybook-page .section-title::after, .storybook-page .section-heading::after {
    width: 28px; height: 4px; border-radius: 2px;
}
.storybook-page .grid, .storybook-page .grid.tile-grid { gap: 16px; }
.storybook-page .card, .storybook-page .card.tile-card, .storybook-page .card.locked-card {
    min-height: 138px; padding: 20px 18px; gap: 12px;
    border: 1px solid #e0cfb1; border-radius: 13px 9px 13px 9px;
    background: #ffedc8; box-shadow: 0 3px 0 #eadcc4;
    grid-template-columns: 40px minmax(0, 1fr);
}
.storybook-page .card:nth-child(3n+2) { background: #e2f1da; }
.storybook-page .card:nth-child(3n) { background: #ffe0cf; }
.storybook-page .card .card-icon, .storybook-page .card.tile-card .card-icon,
.storybook-page .card-icon .storybook-icon { width: 40px; height: 40px; }
.storybook-page .card .card-title, .storybook-page .card.tile-card .card-title { font-size: 18px; }
.storybook-page .card .card-desc, .storybook-page .card.tile-card .card-desc { font-size: 12px; line-height: 1.6; }
.storybook-page .card-title .sub-title { font-size: 11px; line-height: 1.6; }
.storybook-page.portal-family .card .card-title .zh { font-size: 18px; }
.storybook-page .card:has(.fav-pin), .storybook-page .card.locked-card { padding-top: 40px; min-height: 160px; }
.storybook-page .card:hover { border-color: var(--book-accent); box-shadow: 0 5px 0 #e2d0ae, 0 10px 16px #80643b0d; }
.storybook-page .unit-item { background: #fff8e9; border-radius: 10px; padding: 17px; }
.storybook-page .student-grid { gap: 18px; }
.storybook-page .student-card {
    min-height: 132px; padding: 24px 20px; border-radius: 14px 10px 14px 10px;
    border: 1px solid var(--portal-line); background: #ffe3d4;
    box-shadow: 0 3px 0 #eadcc4; grid-template-columns: 48px minmax(0, 1fr) 12px; gap: 14px;
}
.storybook-page .student-card::before, .storybook-page .student-card::after { display: none; }
.storybook-page .math-section .student-card { background: #e3f2d6; border-color: #d0d9bc; }
.storybook-page .card-picture, .storybook-page .card-picture svg { width: 48px; height: 48px; }
.storybook-page .card-label strong, .storybook-page .math-grid .card-label strong { font-size: 22px; }
.storybook-page .card-label small { font-size: 11px; }
.storybook-page .math-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.storybook-page .section-heading h2 { font-size: 24px; }
.storybook-page .student-card:hover { border-color: var(--book-accent); box-shadow: 0 5px 0 #e2d0ae; }
.storybook-page .portal-footer, .storybook-page > footer { padding: 8px 20px 24px; color: #8b785b; font-size: 11px; }
@media (max-width: 1050px) {
    .storybook-page .site-header, .storybook-page .student-header { grid-template-columns: 155px minmax(0, 1fr) 190px; padding-inline: 20px; }
    .storybook-page .portal-art { width: 185px; }
    .storybook-page .teacher-art { width: 150px; }
    .storybook-page .student-art, .storybook-page .sharing-art { width: 124px; }
}
@media (max-width: 760px) {
    .storybook-page .site-header, .storybook-page .student-header {
        width: calc(100% - 24px); margin-top: 10px; padding: 10px 17px;
        grid-template-columns: minmax(0, 1fr) 130px; grid-template-rows: auto 1fr;
        gap: 4px 8px; min-height: 162px; border-radius: 17px 17px 7px 7px;
        background-position: center, 65% 32%;
    }
    .storybook-page .back-link, .storybook-page .home-return { grid-column: 1 / -1; grid-row: 1; font-size: 11px; min-height: 30px; }
    .storybook-page .portal-heading { grid-column: 1; grid-row: 2; padding: 2px 0; }
    .portal-eyebrow { font-size: 10px; letter-spacing: 1px; margin-bottom: 7px; }
    .storybook-page .site-header h1, .storybook-page .student-header h1 { font-size: 26px; letter-spacing: 2px; }
    .storybook-page .site-header h1 small, .storybook-page .student-header h1 small { font-size: 10px; letter-spacing: 0; }
    .storybook-page .portal-caption { font-size: 12px; margin-top: 4px; }
    .storybook-page .portal-art { grid-column: 2; grid-row: 2; width: 130px; height: 105px; }
    .storybook-page .teacher-art, .storybook-page .student-art, .storybook-page .sharing-art { width: 110px; height: 105px; }
    .storybook-page .container, .storybook-page .student-main { width: calc(100% - 24px); padding: 22px 16px 26px; margin-top: 20px; }
    .storybook-page .tab-nav-inner, .storybook-page .category-nav-inner { width: calc(100% - 28px); gap: 7px; }
    .storybook-page .tab-btn, .storybook-page .nav-pill { min-height: 36px; padding: 7px 10px; font-size: 12px; }
    .storybook-page .grid, .storybook-page .grid.tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .storybook-page .card, .storybook-page .card.tile-card, .storybook-page .card.locked-card {
        grid-template-columns: 29px minmax(0, 1fr); padding: 15px 11px; gap: 9px; min-height: 143px;
    }
    .storybook-page .card .card-icon, .storybook-page .card.tile-card .card-icon, .storybook-page .card-icon .storybook-icon { width: 29px; height: 29px; }
    .storybook-page .card .card-title, .storybook-page .card.tile-card .card-title,
    .storybook-page.portal-family .card .card-title .zh { font-size: 16px; }
    .storybook-page .card .card-desc, .storybook-page .card.tile-card .card-desc { font-size: 11px; }
    .storybook-page .card:has(.fav-pin), .storybook-page .card.locked-card { padding-top: 39px; }
    .storybook-page .section-title, .storybook-page .section-heading { font-size: 21px; }
    .storybook-page .student-grid { gap: 12px; }
    .storybook-page .student-card { grid-template-columns: 1fr; padding: 17px 13px; min-height: 166px; gap: 10px; align-content: start; }
    .storybook-page .card-label strong, .storybook-page .math-grid .card-label strong { font-size: 19px; }
    .storybook-page .card-label small { font-size: 10px; }
    .storybook-page .card-picture, .storybook-page .card-picture svg { width: 42px; height: 42px; }
}
@media (max-width: 380px) {
    .storybook-page .site-header, .storybook-page .student-header { grid-template-columns: minmax(0, 1fr) 100px; padding-inline: 13px; }
    .storybook-page .site-header h1, .storybook-page .student-header h1 { font-size: 24px; }
    .storybook-page .portal-art { width: 113px; }
    .storybook-page .teacher-art, .storybook-page .student-art, .storybook-page .sharing-art { width: 100px; }
    .storybook-page .card, .storybook-page .card.tile-card, .storybook-page .card.locked-card { display: flex; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
    .storybook-page .card:hover, .storybook-page .student-card:hover { transform: none; }
}
@media (min-width: 761px) { .storybook-page.portal-family .container > section:first-child .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

@media (max-width: 760px) { .portal-seal { width: 28px; height: 28px; } .storybook-page .portal-back-label small { font-size: 8px; } }

/* Traditional ornaments stay by the heading; the footer is plain. */
.storybook-page .site-header, .storybook-page .student-header {
    background-image: url('../images/portal-ornaments.svg'),
        linear-gradient(90deg, #fff6df 5%, #fff6dfeb 42%, #fff6df35 100%),
        url('../images/home-courtyard-background.png');
    background-position: center, center, center 37%;
    background-size: 100% 100%, cover, cover;
    background-repeat: no-repeat;
}
.storybook-page.portal-family .site-header {
    background-image: url('../images/portal-ornaments.svg'), linear-gradient(105deg, #fff7e5, #ffe2b5 70%, #f5ce9a);
    background-size: 100% 100%, cover;
}
.storybook-page .portal-art { z-index: 1; }
.storybook-page .section-title, .storybook-page .student-main .section-heading {
    background: url('../images/portal-cloud.svg') right center / 80px 32px no-repeat;
    padding-right: 88px; border-bottom-color: #e7c58e;
}
.storybook-page .section-title::before {
    content: ''; display: block; width: 19px; height: 30px; flex-shrink: 0;
    background: url('../images/portal-lantern.svg') center / contain no-repeat;
}
.storybook-page .card .card-title, .storybook-page .card.tile-card .card-title,
.storybook-page.portal-family .card .card-title .zh { color: #714020; }
.storybook-page .card .card-desc, .storybook-page .card.tile-card .card-desc { color: #735b3f; }
.storybook-page .portal-footer, .storybook-page > footer {
    background: none; background-image: none; border: 0; box-shadow: none; color: #816442;
}
.storybook-page .portal-footer::before, .storybook-page .portal-footer::after,
.storybook-page > footer::before, .storybook-page > footer::after { content: none; }
@media (max-width: 760px) {
    .storybook-page .section-title, .storybook-page .student-main .section-heading {
        background-size: 44px 20px; padding-right: 49px;
    }
    .storybook-page .site-header, .storybook-page .student-header { background-position: center, center, 65% 32%; }
}
/* Real paper-relief clouds and lanterns replace the old outline placeholders. */
.storybook-page .site-header, .storybook-page .student-header,
.storybook-page.portal-family .site-header {
    background-image: linear-gradient(90deg, #fff6df 5%, #fff6dfeb 42%, #fff6df35 100%),
        url('../images/home-courtyard-background.png');
    background-position: center, center 37%; background-size: cover, cover;
}
.storybook-page .site-header::before, .storybook-page .student-header::before {
    content: ''; display: block; position: absolute; top: -5px; right: 248px; bottom: auto; left: auto;
    width: 88px; height: 126px; border: 0; border-radius: 0;
    background: url('../images/courtyard-lantern-paper-v2.png') center / auto 100% no-repeat;
    opacity: .98; pointer-events: none; z-index: 1;
}
.storybook-page .site-header::after, .storybook-page .student-header::after {
    content: ''; display: block; position: absolute; top: auto; bottom: 5px; right: 332px; left: auto;
    width: 156px; height: 53px; border: 0; border-radius: 0;
    background: url('../images/courtyard-cloud-paper-v2.png') center / contain no-repeat;
    opacity: .8; pointer-events: none; z-index: 0;
}
.storybook-page .section-title, .storybook-page .student-main .section-heading {
    background-image: url('../images/courtyard-cloud-paper-v2.png');
    background-size: 104px 36px; padding-right: 110px;
}
.storybook-page .section-title::before {
    width: 24px; height: 34px;
    background: url('../images/courtyard-lantern-paper-v2.png') center / auto 100% no-repeat;
}
@media (max-width: 1050px) { .storybook-page .site-header::before, .storybook-page .student-header::before { right: 192px; width: 70px; height: 108px; } }
@media (max-width: 760px) {
    .storybook-page .site-header::before, .storybook-page .student-header::before,
    .storybook-page .site-header::after, .storybook-page .student-header::after { display: none; }
    .storybook-page .section-title, .storybook-page .student-main .section-heading { background-size: 62px 24px; padding-right: 68px; }
}