.studies {
    --browser-dot: #D4D4D8;
    --browser-bar: #F4F4F5;
    --paper: color-mix(in srgb, var(--panel) 96%, #F2DFB8);
    --ruled: color-mix(in srgb, var(--line) 85%, transparent);
    --margin-line: color-mix(in srgb, var(--accent) 45%, transparent);
    --thread-radius: 8px;
}

:root[data-theme="dark"] .studies {
    --browser-dot: #4B5060;
    --browser-bar: #18181C;
    --paper: color-mix(in srgb, var(--panel) 95%, #4A3C26);
    --ruled: color-mix(in srgb, var(--line) 70%, transparent);
    --margin-line: color-mix(in srgb, var(--accent) 40%, transparent);
}

.studies-stage {
    position: relative;
    overflow-anchor: none;
}

:root:has(.home) .studies-stage {
    z-index: 3;
}

.browser {
    --edge: 1;
    --fill: 1;
    position: relative;
    box-sizing: border-box;
    padding-top: var(--bar);
    overflow: clip;
    overflow-clip-margin: 1px;
    border: 1px solid color-mix(in srgb, var(--line) calc(var(--edge) * 100%), transparent);
    border-radius: 10px;
    background: color-mix(in srgb, var(--panel) calc(var(--fill) * 100%), transparent) content-box;
    box-shadow: 0 16px 32px -16px color-mix(in srgb, var(--shade) calc(var(--edge) * 100%), transparent);
    visibility: hidden;
    opacity: 0;
}

.browser-bar {
    position: absolute;
    z-index: 2;
    top: 0;
    right: 0;
    left: 0;
    height: var(--bar);
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 70px 10px 10px;
    border-bottom: 1px solid var(--line);
    background: var(--browser-bar);
}

.browser-bar i {
    flex: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--browser-dot);
}

.browser-bar i:first-child {
    background: var(--accent);
}

.browser-address {
    flex: 0 1 520px;
    min-width: 0;
    margin: 0 auto;
    padding: 2px 12px;
    border-radius: 6px;
    background: var(--panel);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 16px;
    color: var(--muted);
}

.browser-loading {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(0);
}

.browser-page {
    position: relative;
    min-height: calc(var(--view) - var(--bar) - 2px);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    justify-content: safe center;
    gap: 16px;
    padding: 24px 15px 8px;
}

.browser-page .station-title {
    --thread-inset: 20px;
}

.pages {
    width: 100%;
    max-width: var(--column);
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 16px;
}

.studies-board {
    --thread-turn: 24px;
    --thread-tie: 16px;
    --lift-x: -5;
    --lift-y: -7;
    --lift-rotate: -6;
    margin-top: auto;
}

.page-sheet {
    --thread-pass: down;
    --thread-inset: 20px;
    --lines: 5;
    --rule: 22px;
    --top: 9px;
    --bottom: 11px;
    position: relative;
    isolation: isolate;
    display: grid;
    padding: var(--top) 14px var(--bottom) 34px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--paper);
}

.page-sheet:has(.page-note:nth-child(4)) {
    --lines: 6;
}

.page-sheet::after {
    content: "";
    position: absolute;
    z-index: -1;
    top: var(--top);
    right: 0;
    bottom: var(--bottom);
    left: 0;
    background: repeating-linear-gradient(to bottom, transparent 0 calc(var(--rule) - 1px), var(--ruled) 0 var(--rule));
}

.page-line {
    --ink: clamp(0, var(--passing) * var(--lines) - var(--nth), 1);
    display: block;
    min-width: 0;
    line-height: var(--rule);
    clip-path: inset(0 calc(100% - var(--ink) * 100%) 0 0);
}

.page-head {
    --nth: 0;
    height: var(--rule);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.page-stage {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 15px;
}

.page-date {
    flex: none;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}

.page-school {
    --nth: 1;
    font-size: 13px;
    color: var(--fg);
}

.page-notes {
    margin: 0;
    padding: 0;
    list-style: none;
}

.page-note {
    --nth: 2;
    padding-left: 1em;
    text-indent: -1em;
    font-size: 13px;
    color: var(--body);
}

.page-note:nth-child(2) {
    --nth: 3;
}

.page-note:nth-child(3) {
    --nth: 4;
}

.page-note:nth-child(4) {
    --nth: 5;
}

.page-note::before {
    content: "\2013";
    display: inline-block;
    width: 1em;
    text-indent: 0;
    color: var(--accent-ink);
}

@media (max-height: 700px) {
    .browser-page {
        gap: 12px;
        padding-top: 16px;
        padding-bottom: 0;
    }

    .pages {
        gap: 12px;
    }

    .page-sheet {
        --rule: 20px;
        --top: 6px;
        --bottom: 8px;
    }
}

@media (min-width: 1200px) {
    .studies {
        --thread-radius: 16px;
        --thread-axis: center;
    }

    .browser-bar {
        padding: 12px 80px 12px 20px;
    }

    .browser-address {
        font-size: 12px;
    }

    .browser-page {
        display: grid;
        grid-template-columns: 1fr var(--board) 1fr;
        grid-template-rows: 1fr auto 1fr auto;
        align-items: center;
        gap: 0;
        padding: 32px 47px 20px;
    }

    .browser-page .station-title {
        --thread-lead: 24px;
        grid-row: 1;
        grid-column: 1 / -1;
        align-self: end;
        justify-self: center;
        width: 960px;
        padding: 0;
        text-align: left;
    }

    .pages {
        --thread-right: -24px;
        grid-row: 2;
        grid-column: 1 / -1;
        justify-self: center;
        width: 960px;
        max-width: none;
        margin: 12px 0 76px;
        grid-template-columns: repeat(3, 1fr);
    }

    .page-sheet {
        --thread-pass: across;
        --thread-inset: 14px;
        --rule: 24px;
        --top: 30px;
        --bottom: 14px;
        padding-right: 18px;
        padding-left: 46px;
    }

    .page-sheet::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: 32px;
        width: 1px;
        background: var(--margin-line);
    }

    .page-stage {
        font-size: 16px;
    }

    .page-date {
        font-size: 12px;
    }

    .page-school,
    .page-note {
        font-size: 14px;
    }

    .studies-board {
        --thread-tie: 4px;
        grid-row: 4;
        grid-column: 2;
    }
}

@media (min-width: 1200px) and (max-height: 820px) {
    .pages {
        margin-bottom: 56px;
    }
}
