/*
 * Skeptic's Annotations — margin note layout
 * Amber/orange palette distinguishes from editor footnotes (blue).
 */

/* Widen #wikitext to accommodate left + right gutters */
#wikitext {
    position: relative;
    max-width: 1540px;
    padding-left: 460px;
    padding-right: 460px;
    box-sizing: border-box;
    /* skin.css sets overflow: auto, which gives #wikitext its own scrollbar
       when margin notes extend past the article; JS grows min-height instead */
    overflow: visible;
    display: flow-root;
}

/* Inline annotated text */
.annotation-target {
    background: rgba(220, 160, 0, 0.12);
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: rgba(200, 130, 0, 0.6);
    cursor: default;
}

/* Superscript marker [A1], [A2], etc. */
sup.annotation-ref {
    line-height: 0;
}
sup.annotation-ref a {
    font-family: 'Proxima Nova', sans-serif;
    font-size: 0.65em;
    color: #b06000;
    text-decoration: none;
    font-weight: 600;
}
sup.annotation-ref a:hover {
    text-decoration: underline;
}

/* Margin notes — positioned absolutely by JS */
.margin-note {
    position: absolute;
    width: 420px;
    font-family: 'Proxima Nova', sans-serif;
    font-size: 0.775em;
    line-height: 1.55;
    color: #444;
    border-left: 2px solid #d4a020;
    padding-left: 0.65em;
}

.margin-note.left {
    left: 20px;
}

.margin-note.right {
    right: 20px;
}

/* Brief highlight when a note is reached from the cited-study list under the title */
.margin-note.annotation-flash {
    animation: annotation-flash 1.6s ease-out;
}
@keyframes annotation-flash {
    0%, 30% { background: rgba(212, 160, 32, 0.22); }
    100% { background: transparent; }
}

.margin-note-number {
    font-weight: 700;
    color: #b06000;
    margin-right: 0.25em;
    white-space: nowrap;
}

.margin-note a {
    color: #6060c0;
}
.margin-note a:hover {
    text-decoration: underline;
}

/* The skin stamps a raised marker after every link (skin.css:
   a:link::after { content: "\FEFF\B0"; }). Suppress it on the links this
   feature injects — the [A1] refs and margin-note citations — so they don't
   sprout stray degree-sign characters. */
sup.annotation-ref a::after,
.margin-note a::after {
    content: none;
}

/* Toggle panel — lets readers pick which annotation set(s) to show */
.annotation-toggle-panel {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 100;
    font-family: 'Proxima Nova', sans-serif;
    font-size: 0.775em;
}

.annotation-toggle-summary {
    background: #fff8ec;
    border: 1px solid #d4a020;
    color: #b06000;
    border-radius: 4px;
    padding: 0.35em 0.6em;
    cursor: pointer;
    font-weight: 600;
}
.annotation-toggle-summary:hover {
    background: #fdefd2;
}

.annotation-toggle-body {
    margin-top: 0.4em;
    background: #fff8ec;
    border: 1px solid #d4a020;
    border-radius: 4px;
    padding: 0.5em 0.75em;
    min-width: 140px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.annotation-toggle-row {
    display: flex;
    align-items: center;
    gap: 0.4em;
    color: #444;
    white-space: nowrap;
    padding: 0.15em 0;
    cursor: pointer;
}
.annotation-toggle-count {
    margin-left: auto;
    padding-left: 0.8em;
    color: #999;
    font-variant-numeric: tabular-nums;
}

/* Note sheet for narrow screens; shown only by the media query below */
.annotation-sheet {
    display: none;
}

/* Narrow screens: collapse to no extra padding; hide margin notes */
@media (max-width: 1000px) {
    #wikitext {
        padding-left: 1em;
        padding-right: 1em;
        max-width: 660px;
    }
    .margin-note {
        display: none;
    }

    /* Tapping annotated text or its marker opens the note in the sheet below */
    .annotation-target {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(220, 160, 0, 0.25);
    }
    .annotation-target.annotation-active {
        background: rgba(220, 160, 0, 0.3);
    }
    sup.annotation-ref a {
        font-size: 0.75em;
        padding: 0.3em 0.15em;
    }

    .annotation-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 101;
        max-height: 60vh;
        display: flex;
        flex-direction: column;
        background: #fff8ec;
        border-top: 2px solid #d4a020;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
        font-family: 'Proxima Nova', sans-serif;
        font-size: 0.9em;
        line-height: 1.55;
        color: #444;
        padding-bottom: env(safe-area-inset-bottom);
        animation: annotation-sheet-in 0.18s ease-out;
    }
    .annotation-sheet[hidden] {
        display: none;
    }
    body.annotation-sheet-open {
        padding-bottom: 60vh;
    }
}

@keyframes annotation-sheet-in {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.annotation-sheet-bar {
    display: flex;
    align-items: center;
    gap: 0.25em;
    padding: 0.25em 0.5em;
    border-bottom: 1px solid rgba(212, 160, 32, 0.4);
    color: #b06000;
    font-weight: 600;
}
.annotation-sheet-bar button {
    background: none;
    border: none;
    color: #b06000;
    font-size: 1.5em;
    line-height: 1;
    min-width: 44px;
    min-height: 40px;
    cursor: pointer;
}
.annotation-sheet-bar button:disabled {
    opacity: 0.3;
    cursor: default;
}
.annotation-sheet-close {
    margin-left: auto;
}

.annotation-sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.5em 1em 1em;
}
.annotation-sheet-note + .annotation-sheet-note {
    margin-top: 0.75em;
    padding-top: 0.75em;
    border-top: 1px solid rgba(212, 160, 32, 0.4);
}
.annotation-sheet-note a {
    color: #6060c0;
}
.annotation-sheet a::after {
    content: none;
}
