@import url("syntax.css");
@import url("postView.css");

:root {
/*  ===============================
    sRGB fallbacks (universal)
    =============================== */
    --primary-color: #8471ff;
    --primary-light-color: #8b7af8;
    --primary-lighter-color: #b6aaff;
    --secondary-color: #4BD84F;
    --secondary-light-color: #99f39c;
    --secondary-lighter-color: #b1f6b4;
    --background-color: #030307;
    --primary-background-color: #8471FF1A;
    --secondary-background-color: #4BD84F1A;
    --text-color: #F4E0D3;
    --header-height: 60px;

/*  ===============================
    DCI-P3 overrides
    =============================== */
    --primary-color: color(display-p3 0.518 0.443 1.000);
    --primary-light-color: color(display-p3 0.549 0.478 0.986);
    --primary-lighter-color: color(display-p3 0.705 0.666 1.000);
    --secondary-color: color(display-p3 0.294 0.847 0.310);
    --secondary-light-color: color(display-p3 0.602 0.953 0.612);
    --secondary-lighter-color: color(display-p3 0.694 0.965 0.698);
    --background-color: color(display-p3 0.012 0.012 0.027);
    --primary-background-color: color(display-p3 0.518 0.443 1.000 / 0.066);
    --secondary-background-color: color(display-p3 0.294 0.847 0.310 / 0.066);
    --text-color: color(display-p3 0.957 0.878 0.826);
}

/* ========== Global Resets ========== */
* {
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: "Geist", serif;
    margin: 0;
    padding: 0;
    color: var(--text-color);
    font-weight: 300;
    background-color: var(--background-color);
    overflow-x: hidden;
    padding-top: var(--header-height);
    font-size: clamp(0.95rem, 0.6vw + 0.85rem, 1.1rem);
}

.body_centred {
    inherits: body;
    text-align: center;
}

/* ========== Layout Containers ========== */
.wrapper {
    position: relative;
    max-width: min(97vw, 1300px);
    margin: 0 auto;
    padding: 0 clamp(1rem, 5vw, 2rem);
    min-height: calc(100vh - var(--header-height));
}

/* ========== Fixed Header ========== */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 1000;
    backdrop-filter: blur(10px);
    background-color: #0f0f0f3a;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Navbar inside header */
.navbar {
    max-width: min(97vw, 1300px);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 clamp(1rem, 5vw, 1.5rem);
}

/* ========== Navigation ========== */
.site-name {
    color: var(--primary-color);
    text-decoration: none;
    font-size: clamp(1.5rem, 1vw + 1rem, 1.8rem);
    font-family: "Inter Tight", serif;
    font-weight: 800;
    transition: color 0.15s ease;
}

.site-name:hover {
    color: var(--text-color);
}

.nav-links {
    display: flex;
    gap: 20px;
}

.nav-links a {
    color: inherit;
    text-decoration: none;
    font-size: clamp(1.1rem, 0.4vw + 1rem, 1.3rem);
    font-weight: 250;
    transition: color 0.15s ease;
}

.nav-links a:hover {
    color: var(--primary-color);
    transition: color 0.15s ease;
}

/* ========== Section Layouts ========== */
section,
.post {
    max-width: min(97vw, 1300px);
    margin: 0 auto;
    padding: clamp(0.25rem, 3vw, 4rem);
    padding-top: clamp(0.25rem, 2vw, 2rem);
    position: relative;
    transition: opacity 0.1s ease-in-out, visibility 0.1s ease-in-out;
    height: auto;
}

.post, section, .navbar {
    box-sizing: border-box;
    width: 100%;
    max-width: min(97vw, 1300px);
    margin: 0 auto;
}

/* ========== Typography ========== */
h1 {
    font-family: "Inter Tight", serif;
    font-size: clamp(1.6rem, 2.5vw + 1rem, 2.4rem);
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 1rem;
}

h2 {
    font-size: clamp(1.2rem, 2vw + 0.8rem, 1.7rem);
    font-family: "Inter Tight", serif;
    color: var(--primary-light-color);
    font-weight: 600;
}

h3 {
    font-size: clamp(1rem, 1.5vw + 0.6rem, 1.4rem);
    font-family: "Inter Tight", serif;
    font-weight: 500;
    color: var(--primary-lighter-color);
}

h4, h5, h6 {
    font-family: "Inter Tight", serif;
    font-weight: 400;
    color: var(--primary-lighter-color);
}

p {
    font-weight: inherit;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 1.5rem;
}

hr {
    border: none;
    border-top: 1px solid #222;
    margin: 2rem 0;
    opacity: 0.8;
}

strong, b {
  font-weight: 550;
}

/* ========== Markdown Elements ========== */
ul, ol {
    margin: 1.2rem 0 1.5rem 2rem;
    padding: 0;
}

li {
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

ul {
    list-style-type: disc;
}

blockquote {
    position: relative;
    margin: 0;
    padding: 0rem 1rem;
    color: var(--secondary-light-color);
    background-color: var(--secondary-background-color);
    border-radius: 8px;
}

/* rounded left bar */
blockquote::before {
    content: "";
    position: absolute;
    left: 5px;
    top: 5px;
    bottom: 5px;
    width: 3px;
    background-color: var(--secondary-color);
    border-radius: 2px;
}

/* Warning blockquote variant */
blockquote.warning-quote {
    padding: 0.25rem 1.2rem;
    padding-top: 0rem;
    background-color: color(display-p3 0.09 0.02 0.02); /* deep red tint */
    color: #ffcccc;
    border: 1px solid color(display-p3 0.6 0.1 0.1);
}

blockquote.warning-quote::before {
    content: "\25B3";
    font-variant-emoji: text;   
    color: color(display-p3 0.8 0.23 0.23);
    font-size: 1.1rem;
    margin-left: -0.8rem;
    margin-right: 0rem;
    position: static; /* let flexbox handle layout */
    background: none;
    border-radius: 0;
}
/* Inline code */
code {
    background-color: var(--secondary-background-color);
    color: var(--secondary-light-color);
    padding: 0.15em 0.35em;
    border-radius: 4px;
    font-family: "Fragment Mono", "Courier New", monospace;
    font-size: 0.95em;
}

/* Code block */
pre {
    background-color: var(--secondary-background-color);
    color: var(--secondary-light-color);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: "Fragment Mono", "Courier New", monospace;
    line-height: 1.6;
    font-size: 0.9rem;
}

pre code {
    background: none;
    padding: 0;
}

/* Links */
a {
    color: var(--primary-light-color);
    text-decoration: underline;
    transition: color 0.15s ease;
}
a:hover {
    color: var(--secondary-light-color);
}

/* Images */
img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.5rem auto;
    border-radius: 6px;
}

svg {
  width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
  max-width: 100%;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    table-layout: fixed; /* ensures equal-width columns */
}

th, td {
    border: 1px solid #333;
    padding: 0.6rem 0.8rem;
    text-align: center; /* centre text horizontally */
    vertical-align: middle; /* centre text vertically */
    width: auto; /* equal columns handled by table-layout: fixed */
}

th {
    background-color: var(--secondary-background-color);
    color: var(--secondary-light-color);
    font-weight: 500;
}

tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

/* ========== Footer ========== */
footer {
    text-align: center;
    padding: 1rem;
    max-width: 800px;
    margin: 0 auto;
}

/* ========== Post Layout ========== */
.post-header {
    margin-bottom: 2rem;
}

.post-date {
    font-size: clamp(0.9rem, 0.3vw + 0.8rem, 1rem);
    color: #aaa;
    margin: 0;
}

.post-content {
    line-height: inherit;
    font-size: inherit;
}

.post-footer {
    margin-top: 2rem;
    text-align: left;
    color: var(--primary-lighter-color);
}

#post-footer a {
    margin-top: 10px;
}

/* ========== Diagram Styles ========== */
.flow-diagram {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1.5rem 0;
}

.flow-horizontal {
    display: block !important;
}

.flow-vertical {
    display: none !important;
    max-height: 50vh;
    width: auto;
}

.ring-widget { color: var(--secondary-light-color); }

.background-ring {
    position: fixed;
    top: 50%;
    left: 50%;
    margin-top: calc(var(--header-height) / 2);
    width: min(90vmin, 800px);
    aspect-ratio: 1 / 1;
    transform: translate(-50%, -50%);
    z-index: -1;
    pointer-events: none;
}

.background-ring-svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== Table of Contents ===== */
.toc {
    position: fixed;
    top: calc(var(--header-height) + 1rem);
    left: calc(50% + min(650px, 48vw) - 50px);
    width: 240px;
    background: rgba(20, 20, 25, 0.6);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    color: var(--text-color);
    overflow-y: auto;
    max-height: 75vh;
    z-index: 100;
}

/* Header inside the TOC content block */
#toc-content::before {
    content: "Contents";
    display: block;
    margin: 0 0 .6rem;
    font: 600 1.05rem/1.2 var(--font-heading, "Inter Tight", system-ui, sans-serif);
    font-size: 1.2rem;
    color: var(--primary-light-color);
}


/* ToC links */
.toc a {
    display: block;
    color: var(--text-color);
    text-decoration: none;
    margin: 0.35rem 0;
    font-size: 0.93rem;
    transition: color 0.10s ease;
}

.toc-h3 {
    margin-left: 0.75rem;
    font-size: 0.9rem;
}

.toc-toggle {
    display: none;
}

/* ===== ToC Hierarchy Styling ===== */
#toc-content a {
    display: block;
    text-decoration: none;
    margin: 0.5rem 0;
    line-height: 1.3;
    color: var(--text-color);
    transition: color 0.15s ease;
    font-weight: 500;
}

#toc-content a:hover {
    color: #b6a79d;
}

/* H3 indentation (nested look) */
#toc-content a.toc-h3 {
    padding-left: 1.25rem;
    font-weight: 400;
    opacity: 0.85;
}

/* ===== Mobile view ===== */
@media (max-width: 1700px) {
    .toc {
        position: fixed;
        right: 0;
        top: var(--header-height);
        width: 75%;
        max-width: 320px;
        height: calc(100vh - var(--header-height));
        background: rgba(10, 10, 15, 0.97);
        transform: translateX(100%);
        transition: transform 0.3s ease-in-out;
        padding-top: 1rem;
    }

    body.toc-open .toc {
        transform: translateX(0);
    }

    .toc-toggle {
        display: block;
        position: fixed;
        right: 1rem;
        top: calc(var(--header-height) + 0.5rem);
        background: rgba(30, 30, 35, 0.7);
        color: var(--text-color);
        border: none;
        border-radius: 6px;
        padding: 0.4rem 0.6rem;
        cursor: pointer;
        z-index: 200;
        backdrop-filter: blur(10px);
    }
}

/* Offset anchor scroll for fixed navbar */
h1, h2, h3, h4, h5, h6 {
    scroll-margin-top: calc(var(--header-height) + 20px); /* Adjust this value as needed */
}

/* ========== Responsive Adjustments ========== */
@media (max-width: 600px) {
    html, body, .post-content {
        font-size: 0.95rem;
        line-height: 1.55;
    }

    header {
        padding: 0;
    }
    .flow-horizontal {
        display: none !important;
    }
    .flow-vertical {
        display: block !important;
    }
}

:not(pre):not(.highlight) > code {
    display: inline;
    padding: 0.10em 0.30em !important;
    margin: 0 !important;
    background-color: var(--secondary-background-color) !important;
    color: var(--secondary-light-color) !important;
    border-radius: 4px !important;
    font-family: "Fragment Mono", "Courier New", monospace;
    font-size: 0.90em !important;
    line-height: normal !important;
    box-shadow: none !important;
}
