/* acornaeology.uk */

@font-face {
    font-family: 'Bedstead';
    src: url('../fonts/bedstead.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Bedstead';
    src: url('../fonts/bedstead-bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/IBMPlexSans-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/IBMPlexSans-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Sans';
    src: url('../fonts/IBMPlexSans-Italic.woff2') format('woff2');
    font-weight: normal;
    font-style: italic;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/IBMPlexMono-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/IBMPlexMono-Bold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'IBM Plex Mono';
    src: url('../fonts/IBMPlexMono-Italic.woff2') format('woff2');
    font-weight: normal;
    font-style: italic;
    font-display: swap;
}

/* Light mode — "Retro Manual" */
:root {
    --bg: #F8F8F8;
    --text: #1E2228;
    --red: #C24B4B;
    --green: #4DAA4D;
    --blue: #4A78C2;
    --cyan: #3AA6A6;
    --magenta: #A84DA8;
    --yellow: #C7A645;
    --dim: #666666;
    --faint: #BBBBBB;
    --rule: #D0D0D0;
    --sidebar-bg: #F0F0F0;
    --link: #4A78C2;
    --link-visited: #A84DA8;
    --operand-link: #A84DA8;
}

/* Dark mode — "Soft Phosphor" */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #111214;
        --text: #E6E6E6;
        --red: #D65A5A;
        --green: #5FBF5F;
        --blue: #5F8FD6;
        --cyan: #4FBFBF;
        --magenta: #BF5FBF;
        --yellow: #D6B85A;
        --dim: #6A6A6A;
        --faint: #333338;
        --rule: #2A2A2E;
        --sidebar-bg: #1A1A1E;
        --link: #5F8FD6;
        --link-visited: #BF5FBF;
        --operand-link: #D6B85A;
    }
}

/* --- Reset & base --- */

html {
    font-size: 22px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
}

/* --- Layout --- */

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* No width cap on disassembly pages — use the full viewport */
.page-disassembly .container {
    max-width: none;
}

/* --- Disassembly two-column layout --- */

.disassembly-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.subroutine-nav {
    position: sticky;
    top: 1rem;
    width: 240px;
    flex-shrink: 0;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.4;
    background-color: var(--sidebar-bg);
    padding: 1rem;
    border-radius: 4px;
}

.subroutine-nav h2 {
    font-size: 1.1rem;
    margin-top: 0;
}

.subroutine-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.subroutine-nav li {
    margin-bottom: 0.3em;
}

.subroutine-nav a:visited {
    color: var(--link);
}

.subroutine-nav .sub-title {
    display: block;
    color: var(--dim);
    font-size: 0.8rem;
}

.disassembly-layout .listing {
    flex: 1;
    min-width: 0;
}

@media (max-width: 900px) {
    .disassembly-layout {
        flex-direction: column;
    }

    .subroutine-nav {
        position: static;
        width: auto;
        max-height: none;
    }
}

/* --- Typography --- */

h1, h2, h3 {
    font-family: 'Bedstead', monospace;
    font-weight: bold;
    line-height: 1.2;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.2rem; }

p {
    margin: 0 0 1em 0;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:visited {
    color: var(--link-visited);
}

a:hover {
    text-decoration: underline;
}

.rom-links {
    font-size: 0.85rem;
    color: var(--dim);
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.rom-links li {
    margin: 0.3rem 0;
}

.link-icon {
    width: 1.5em;
    height: 1.5em;
    vertical-align: -0.3em;
    margin-right: 0.3em;
}

hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 2rem 0;
}

/* --- Site header --- */

.site-header {
    border-bottom: 2px solid var(--rule);
    padding: 1rem 1.5rem;
}

.site-header .container {
    padding: 0;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-title {
    font-family: 'Bedstead', monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.site-logo {
    height: 5.5rem;
    width: auto;
}

.site-title:visited {
    color: var(--text);
}

.site-title-text {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.site-tagline {
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.65rem;
    font-weight: normal;
    color: var(--dim);
}

.site-nav {
    display: flex;
    gap: 1.5rem;
}

.site-nav a {
    font-size: 0.9rem;
}

/* --- Footer --- */

.site-footer {
    border-top: 1px solid var(--rule);
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    color: var(--dim);
}

/* --- Disassembly listings --- */

.listing {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 18px;
    line-height: 1.4;
    overflow-x: auto;
    tab-size: 8;
}

.listing table {
    border-collapse: collapse;
    width: 100%;
}

.listing td {
    white-space: pre;
    vertical-align: top;
}

.listing tr:target td {
    background-color: var(--rule);
}

.listing tr[id] {
    scroll-margin-top: 40vh;
}

.listing .addr {
    color: var(--faint);
    user-select: none;
    padding-right: 1.5em;
    white-space: nowrap;
    text-align: right;
    vertical-align: top;
}

.listing .addr a {
    color: var(--faint);
    text-decoration: none;
}

.listing .addr a:hover {
    color: var(--dim);
}

.listing .label {
    color: var(--cyan);
    position: relative;
}

/* --- Come-from reference popups --- */

.listing .ref-badge {
    display: inline-block;
    margin-left: 0.5em;
    padding: 0 0.4em;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 0.7em;
    line-height: 1.6;
    color: var(--dim);
    background: var(--sidebar-bg);
    border: 1px solid var(--rule);
    border-radius: 3px;
    cursor: pointer;
    vertical-align: middle;
}

.listing .ref-popup {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    padding: 0.4em 0;
    min-width: 12em;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    white-space: nowrap;
    background: var(--sidebar-bg);
    border: 1px solid var(--rule);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 20;
}

.listing .ref-popup::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -0.5em;
    height: 0.5em;
}

.listing .ref-popup a {
    display: block;
    padding: 0.15em 0.75em;
    color: var(--text);
    text-decoration: none;
}

.listing .ref-popup a:visited {
    color: var(--text);
}

.listing .ref-popup a:hover {
    background: var(--rule);
}

.listing .label:hover .ref-popup {
    display: block;
}

.listing .opcode {
    color: var(--blue);
}

.listing .operand {
    color: var(--text);
}

.listing .operand a {
    color: var(--operand-link);
    text-decoration: none;
    border-bottom: 1px dotted var(--dim);
}

.listing .operand a:visited {
    color: var(--operand-link);
}

.listing .operand a:hover {
    border-bottom-style: solid;
}

.listing .operand .ext-label {
    color: var(--text);
}

.listing .comment {
    color: var(--green);
}

.listing .directive {
    color: var(--magenta);
}

.listing .string {
    color: var(--yellow);
}

/* --- Tooltips --- */

.listing [data-tip] {
    position: relative;
}

.listing .imm {
    cursor: help;
}

.listing [data-tip]::after {
    content: attr(data-tip);
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    margin-top: 0.3em;
    padding: 0.4em 0.6em;
    font-size: 1rem;
    white-space: nowrap;
    color: var(--text);
    background: var(--sidebar-bg);
    border: 1px solid var(--rule);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    z-index: 10;
    pointer-events: none;
}

.listing [data-tip]:hover::after {
    display: block;
}

.listing .hex {
    color: var(--dim);
    user-select: none;
    padding-left: 2em;
    white-space: nowrap;
    vertical-align: top;
}

/* --- Subroutine headers --- */

.sub-header {
    font-family: 'IBM Plex Sans', sans-serif;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 60ch;
    border-top: 2px solid var(--rule);
    padding: 1.5rem 0 1rem 0;
    margin: 1rem 0 0.5rem 0;
}

.sub-header h3 {
    font-family: 'Bedstead', monospace;
    font-size: 1.2rem;
    margin: 0 0 0.5rem 0;
    color: var(--cyan);
}

.sub-desc {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text);
}

.sub-desc p {
    margin: 0 0 0.5em 0;
}

.sub-desc pre.sub-detail {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--dim);
    margin: 0 0 0.5em 0;
    padding: 0.5em 0.75em;
    background: var(--sidebar-bg);
    border-radius: 3px;
    overflow-x: auto;
    white-space: pre;
}

.sub-registers {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

.sub-registers table {
    border-collapse: collapse;
}

.sub-registers th {
    font-family: 'Bedstead', monospace;
    font-size: 0.85rem;
    font-weight: normal;
    color: var(--dim);
    text-align: left;
    vertical-align: top;
    padding: 0 0.75rem 0 0;
}

.sub-registers td:first-of-type {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: bold;
    color: var(--blue);
    padding-right: 0.75rem;
    white-space: nowrap;
}

.sub-registers td:last-of-type {
    color: var(--dim);
}

/* --- Index cards --- */

.rom-list {
    list-style: none;
    padding: 0;
}

.rom-list li {
    margin-bottom: 1rem;
}

.rom-list a {
    font-size: 1.1rem;
}

.rom-list .version {
    color: var(--dim);
    font-size: 0.9rem;
}
