/*
 * Rings theme for the documentation book: the frontend's landing style over mdBook's layout.
 *
 * Loaded after mdBook's own stylesheets (`additional-css` in book.toml), so it only overrides.
 * The palette, type, cards, pills, code blocks, and footer are the ones the frontend defines
 * in `frontend/src/styles/theme` (WARM: page #f3ead8 / #fbf4e6, panel #fffaf0, line #dfd0b7,
 * ink #101828, accent #b42318); `theme/index.hbs` provides the header and footer markup this
 * styles. mdBook sets the root font size to 62.5%, so 1rem is 10px throughout.
 */

:root {
    --sidebar-target-width: 280px;
    --content-max-width: 820px;
    --page-padding: 24px;
    --menu-bar-height: 64px;
    --mono-font: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
    --code-font-size: 0.85em;
    --rings-font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Baskerville, "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", Georgia, serif;
    --rings-radius: 8px;
}

/* Palettes: the frontend's warm light theme; a slate dark under mdBook's preferred dark name
   so the theme picker and prefers-color-scheme both reach it. */

.light,
html:not(.js) {
    --bg: #fbf4e6;
    --fg: #101828;

    --sidebar-bg: #f3ead8;
    --sidebar-fg: #344054;
    --sidebar-non-existant: #a89f8f;
    --sidebar-active: #b42318;
    --sidebar-spacer: #dfd0b7;

    --scrollbar: #b8a98e;

    --icons: #736453;
    --icons-hover: #101828;

    --links: #b42318;

    --inline-code-color: #8a5a12;

    --theme-popup-bg: #fffaf0;
    --theme-popup-border: #d7c6aa;
    --theme-hover: #f3ead8;

    --quote-bg: #fff6e6;
    --quote-border: #dfd0b7;

    --warning-border: #8a5a12;

    --table-border-color: #dfd0b7;
    --table-header-bg: #f3ead8;
    --table-alternate-bg: #fff6e6;

    --searchbar-border-color: #d7c6aa;
    --searchbar-bg: #fffaf0;
    --searchbar-fg: #101828;
    --searchbar-shadow-color: #d7c6aa;
    --searchresults-header-fg: #736453;
    --searchresults-border-color: #d7c6aa;
    --searchresults-li-bg: #fff6e6;
    --search-mark-bg: #fde68a;

    --color-scheme: light;

    --footnote-highlight: #b42318;
    --overlay-bg: rgba(16, 24, 40, 0.35);
    --sidebar-header-border-color: #b42318;

    /* The frontend's surfaces. */
    --rings-page: #f3ead8;
    --rings-panel: #fffaf0;
    --rings-panel-alt: #fff6e6;
    --rings-line: #dfd0b7;
    --rings-line-strong: #d7c6aa;
    --rings-ink: #101828;
    --rings-ink-soft: #344054;
    --rings-muted: #736453;
    --rings-body: #475467;
    --rings-accent: #b42318;
    --rings-dark: #111827;
    --rings-mark-fg: #ffffff;
}

.navy {
    --bg: #0b1220;
    --fg: #d0d5dd;

    --sidebar-bg: #0f172a;
    --sidebar-fg: #98a2b3;
    --sidebar-non-existant: #475467;
    --sidebar-active: #f97066;
    --sidebar-spacer: #1d2939;

    --scrollbar: #475467;

    --icons: #667085;
    --icons-hover: #f2f4f7;

    --links: #f97066;

    --inline-code-color: #fdb022;

    --theme-popup-bg: #101828;
    --theme-popup-border: #344054;
    --theme-hover: #1d2939;

    --quote-bg: #101828;
    --quote-border: #1d2939;

    --warning-border: #fdb022;

    --table-border-color: #1d2939;
    --table-header-bg: #1d2939;
    --table-alternate-bg: #0f172a;

    --searchbar-border-color: #344054;
    --searchbar-bg: #101828;
    --searchbar-fg: #f2f4f7;
    --searchbar-shadow-color: #000000;
    --searchresults-header-fg: #98a2b3;
    --searchresults-border-color: #344054;
    --searchresults-li-bg: #101828;
    --search-mark-bg: #b42318;

    --color-scheme: dark;

    --footnote-highlight: #f97066;
    --overlay-bg: rgba(16, 24, 40, 0.6);
    --sidebar-header-border-color: #f97066;

    --rings-page: #0f172a;
    --rings-panel: #101828;
    --rings-panel-alt: #1d2939;
    --rings-line: #1d2939;
    --rings-line-strong: #344054;
    --rings-ink: #f2f4f7;
    --rings-ink-soft: #d0d5dd;
    --rings-muted: #98a2b3;
    --rings-body: #98a2b3;
    --rings-accent: #f97066;
    --rings-dark: #1f2937;
    --rings-mark-fg: #ffffff;
}

/* Type */

html {
    font-family: var(--rings-font);
}

.content main {
    color: var(--rings-ink-soft);
}

.content h1,
.content h2,
.content h3,
.content h4 {
    font-family: var(--rings-font);
    color: var(--rings-ink);
    letter-spacing: -0.01em;
}

.content h1 {
    margin-block: 0.4em 0.7em;
    font-size: 3.4rem;
    font-weight: 700;
    line-height: 1.08;
}

.content h2 {
    margin-block-start: 2.4em;
    padding-block-end: 0.5em;
    border-block-end: 1px solid var(--rings-line);
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.16;
}

.content h3 {
    font-size: 1.7rem;
    font-weight: 700;
    line-height: 1.25;
}

.content h4 {
    font-size: 1.5rem;
    font-weight: 700;
}

.content p,
.content li {
    line-height: 1.72;
}

.content p {
    color: var(--rings-body);
}

.content strong {
    color: var(--rings-ink);
}

.content a {
    color: var(--links);
    font-weight: 600;
    text-decoration: none;
}

.content a:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* Code: the landing page's dark block on every theme (index.hbs loads the dark highlight
   sheet for the light theme too), the inline form on the panel-alt surface. */

.content :not(pre) > code {
    padding: 0.1em 0.4em;
    border: 1px solid var(--rings-line);
    border-radius: 4px;
    background: var(--rings-panel-alt);
    color: var(--inline-code-color);
}

.content pre {
    border: 1px solid #1f2937;
    border-radius: var(--rings-radius);
    background: #101828;
}

.content pre > code,
.content pre > code.hljs {
    padding: 1.6rem 1.8rem;
    background: #101828;
    color: #f2f4f7;
    line-height: 1.65;
}

.content pre > .buttons button {
    border-color: #344054;
    background: #1d2939;
    color: #d0d5dd;
}

/* Blocks: cards with the landing's line, radius, and panel. */

.content blockquote {
    margin-inline: 0;
    border: 1px solid var(--rings-line);
    border-inline-start: 3px solid var(--rings-accent);
    border-radius: var(--rings-radius);
    background: var(--rings-panel);
}

.content table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border: 1px solid var(--rings-line);
    border-radius: var(--rings-radius);
    background: var(--rings-panel);
}

.content table th,
.content table td {
    padding: 0.9rem 1.2rem;
    border: 0;
    border-block-end: 1px solid var(--rings-line);
    text-align: start;
    vertical-align: top;
}

.content table th {
    background: var(--rings-page);
    color: var(--rings-muted);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.content table tr:last-child td {
    border-block-end: 0;
}

.content table tbody tr:nth-child(2n) {
    background: transparent;
}

.content hr {
    border: 0;
    border-block-start: 1px solid var(--rings-line);
}

/* The brand mark uses its generated dark-background construction colorway. */

.rings-mark {
    display: grid;
    box-sizing: border-box;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: var(--rings-radius);
    background: var(--rings-dark);
}

.rings-mark img {
    display: block;
    width: 23px;
    height: 23px;
    object-fit: contain;
}

.content img.rings-mark {
    box-sizing: border-box;
    width: 56px;
    height: 56px;
    padding: 10px;
    border-radius: 12px;
    background: var(--rings-dark);
}

/* Header: the frontend's landing header. The built-in layout pulls the page up by one
   menu-bar height for a sticky hover placeholder, which this header does not use, so the
   page starts at the top and the placeholder is dropped; the header itself stays sticky. */

.page {
    margin-block-start: 0;
}

#mdbook-menu-bar-hover-placeholder {
    display: none;
}

#mdbook-menu-bar.rings-header,
#mdbook-menu-bar.rings-header.sticky,
html.sidebar-visible #mdbook-menu-bar.rings-header {
    position: sticky;
    top: 0 !important;
    display: flex;
    min-height: var(--menu-bar-height);
    flex-wrap: nowrap;
    align-items: center;
    gap: 16px;
    padding: 0 var(--page-padding);
    border-block-end: 1px solid var(--rings-line);
    background: var(--bg);
    box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
    font-family: var(--rings-font);
}

#mdbook-menu-bar.rings-header.bordered {
    border-block-end-color: var(--rings-line-strong);
}

.rings-header .menu-title {
    display: none;
}

.rings-brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 10px;
    color: var(--rings-ink);
    text-decoration: none;
}

.rings-brand-text {
    display: grid;
    gap: 1px;
    min-width: 0;
}

.rings-brand-text strong {
    overflow: hidden;
    font-size: 1.47rem;
    line-height: 1.1;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rings-brand-text > span {
    color: var(--rings-muted);
    font-size: 1.15rem;
    line-height: 1.1;
}

.rings-nav {
    display: grid;
    margin-inline-start: auto;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    gap: 6px;
}

.rings-nav a {
    display: inline-flex;
    box-sizing: border-box;
    height: 34px;
    align-items: center;
    padding: 0 11px;
    border: 1px solid var(--rings-line-strong);
    border-radius: var(--rings-radius);
    background: var(--rings-panel);
    color: var(--rings-ink-soft);
    font-family: var(--rings-font);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1;
    text-decoration: none;
    text-transform: uppercase;
}

.rings-nav a.active,
.rings-nav a:hover {
    border-color: var(--rings-dark);
    background: var(--rings-dark);
    color: var(--rings-mark-fg);
}

.rings-tools {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 2px;
    margin-inline-start: 8px;
    padding-inline-start: 12px;
    border-inline-start: 1px solid var(--rings-line);
}

.rings-tools .left-buttons,
.rings-tools .right-buttons {
    display: flex;
    align-items: center;
    margin: 0;
}

/* The built-in rules for these are id-qualified (`#mdbook-menu-bar .icon-button`, with a
   line height of one menu bar and side padding), so these are too. */

#mdbook-menu-bar.rings-header .icon-button,
#mdbook-menu-bar.rings-header .right-buttons a {
    display: inline-flex;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border-radius: var(--rings-radius);
    color: var(--icons);
    line-height: 1;
}

#mdbook-menu-bar.rings-header .icon-button:hover,
#mdbook-menu-bar.rings-header .right-buttons a:hover {
    background: var(--rings-panel-alt);
    color: var(--icons-hover);
}

#mdbook-menu-bar.rings-header .fa-svg {
    display: block;
    width: 16px;
    height: 16px;
    padding: 0;
    line-height: 1;
}

/* The popup is positioned against the nearest positioned ancestor; the built-in layout puts
   it at the bar's left edge, where its buttons are, so here the controls group anchors it. */
.rings-tools .left-buttons {
    position: relative;
}

.theme-popup {
    left: 0;
    top: calc(100% + 6px);
    border: 1px solid var(--rings-line-strong);
    border-radius: var(--rings-radius);
    background: var(--rings-panel);
    box-shadow: 0 12px 28px rgba(17, 24, 39, 0.12);
    font-family: var(--rings-font);
}

.theme-popup .theme {
    font-size: 1.3rem;
}

/* Search */

#mdbook-searchbar {
    border: 1px solid var(--rings-line-strong);
    border-radius: var(--rings-radius);
    background: var(--rings-panel);
    color: var(--rings-ink);
    font-family: var(--rings-font);
    box-shadow: none;
}

#mdbook-searchbar:focus,
#mdbook-searchbar.active {
    border-color: var(--rings-dark);
    box-shadow: none;
}

.searchresults-header {
    color: var(--rings-muted);
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

ul#mdbook-searchresults li {
    border-radius: var(--rings-radius);
}

/* Sidebar: the landing's panel, with part titles as the landing's kickers and the current
   chapter as its dark pill. */

.sidebar {
    border-inline-end: 1px solid var(--rings-line);
    background: var(--rings-page);
    font-family: var(--rings-font);
    font-size: 0.875em;
}

.sidebar .sidebar-scrollbox {
    padding: 16px 14px 40px;
}

.chapter {
    line-height: 1.9;
}

.chapter li.part-title {
    margin-block: 1.8em 0.4em;
    padding-inline: 8px;
    color: var(--rings-accent);
    font-size: 0.74em;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.4;
    text-transform: uppercase;
}

.chapter li.part-title:first-child {
    margin-block-start: 0.4em;
}

.chapter li.chapter-item {
    margin-block-start: 0.15em;
}

.chapter li a {
    display: block;
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--rings-ink-soft);
}

.chapter li a:hover {
    background: var(--rings-panel);
    color: var(--rings-ink);
    text-decoration: none;
}

.chapter li a.active {
    background: var(--rings-dark);
    color: var(--rings-mark-fg);
    font-weight: 700;
}

.chapter li > ol {
    margin-inline-start: 8px;
}

.chapter .on-this-page li a {
    padding-block: 1px;
    color: var(--rings-muted);
    font-size: 0.92em;
}

.chapter .on-this-page li a:hover,
.chapter .on-this-page li a.current-header {
    background: transparent;
    color: var(--rings-accent);
}

.sidebar .sidebar-resize-handle .sidebar-resize-indicator {
    background: var(--rings-line);
}

.sidebar .sidebar-resize-handle .sidebar-resize-indicator::before,
.sidebar .sidebar-resize-handle .sidebar-resize-indicator::after {
    border-color: var(--rings-line-strong);
}

/* Chapter navigation arrows */

.nav-chapters {
    color: var(--rings-muted);
}

.nav-chapters:hover {
    background: var(--rings-panel-alt);
    color: var(--rings-ink);
}

.mobile-nav-chapters {
    border: 1px solid var(--rings-line-strong);
    border-radius: var(--rings-radius);
    background: var(--rings-panel);
    color: var(--rings-ink-soft);
}

.mobile-nav-chapters:hover {
    background: var(--rings-dark);
    color: var(--rings-mark-fg);
}

/* Footer: the frontend's site footer, spanning the page like the header. */

.rings-footer {
    display: grid;
    gap: 36px;
    margin: 64px calc(0px - var(--page-padding)) 0;
    padding: 56px var(--page-padding) 36px;
    border-block-start: 1px solid var(--rings-line);
    background: #101828;
    color: #d0d5dd;
    font-family: var(--rings-font);
    font-size: 1.4rem;
}

.rings-footer-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr));
    gap: 32px;
}

.rings-footer-brand {
    display: grid;
    max-width: 380px;
    align-content: start;
    gap: 10px;
}

.rings-footer .rings-mark {
    width: 38px;
    height: 38px;
    background: #1f2937;
}

.rings-footer-brand strong {
    color: #fff;
    font-size: 1.6rem;
}

.rings-footer-brand p {
    margin: 0;
    color: #98a2b3;
    line-height: 1.6;
}

.rings-footer-column {
    display: grid;
    align-content: start;
    gap: 12px;
}

.rings-footer-column h3 {
    margin: 0;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.rings-footer-column ul {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.rings-footer-column a {
    color: #d0d5dd;
    font-weight: 400;
    text-decoration: none;
}

.rings-footer-column a:hover {
    color: #fff;
    text-decoration: underline;
}

.rings-footer-notices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px 28px;
    margin: 0;
    padding-block-start: 28px;
    border-block-start: 1px solid rgba(255, 255, 255, 0.1);
}

.rings-footer-notices > div {
    display: grid;
    gap: 6px;
}

.rings-footer-notices dt {
    color: #fff;
    font-size: 1.22rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.rings-footer-notices dd {
    margin: 0;
    color: #98a2b3;
    font-size: 1.28rem;
    line-height: 1.6;
}

.rings-footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 24px;
    padding-block-start: 20px;
    border-block-start: 1px solid rgba(255, 255, 255, 0.1);
    color: #667085;
    font-size: 1.25rem;
}

/* Narrow viewports: the header keeps the brand and the controls; the page links live on the
   site itself, and the footer folds to two columns, then one. */

@media only screen and (max-width: 1080px) {
    .rings-footer-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media only screen and (max-width: 860px) {
    .rings-nav {
        display: none;
    }

    .rings-tools {
        margin-inline-start: auto;
    }

    .rings-footer-grid {
        grid-template-columns: 1fr;
    }
}

/* Phones: the mark alone stands for the brand, and the controls tighten so the header is one
   row (34px mark, six 30px controls, the paddings: 268px on a 375px viewport). */

@media only screen and (max-width: 520px) {
    :root {
        --page-padding: 16px;
    }

    .rings-brand-text {
        display: none;
    }

    .rings-tools {
        gap: 0;
        margin-inline-start: auto;
        padding-inline-start: 6px;
    }

    #mdbook-menu-bar.rings-header .icon-button,
    #mdbook-menu-bar.rings-header .right-buttons a {
        width: 30px;
    }
}
