/* =========================================================
   mores.dev — A Standard for Software Mores
   Swiss typographic discipline, minimalist functional clarity.
   ========================================================= */

:root {
    /* Palette (DESIGN.md hex values, exact) */
    --paper-white: #fafaf8;
    --rule-black: #1a1a22;
    --standard-blue: #2563eb;
    --code-surface: #f0ede8;
    --commentary-gray: #6b7280;
    --rule-line: #e5e7eb;
    --ethical-green: #059669;

    /* Typography */
    --font-display: "Space Grotesk", "Inter", system-ui, -apple-system, sans-serif;
    --font-body: "Crimson Pro", Georgia, "Times New Roman", serif;
    --font-mono: "IBM Plex Mono", "SF Mono", Menlo, Consolas, monospace;

    /* Layout */
    --measure: 720px;
    --gutter: clamp(20px, 5vw, 48px);
    --rule-space: 2rem;
    --section-gap: 3.5rem;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--paper-white);
    color: var(--rule-black);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.8;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
}

/* =========================================================
   Sticky bar — current section indicator
   ========================================================= */

.sticky-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: #ffffff;
    border-bottom: 1px solid var(--rule-line);
    padding: 8px 0;
    transition: box-shadow 220ms ease, background 220ms ease;
}

.sticky-bar.is-floating {
    box-shadow: 0 1px 0 rgba(26, 26, 34, 0.04), 0 8px 24px -16px rgba(26, 26, 34, 0.18);
}

.sticky-bar__inner {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 var(--gutter);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 2rem;
    row-gap: 4px;
    position: relative;
}

.sticky-bar__brand {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--rule-black);
    letter-spacing: 0.02em;
}

.sticky-bar__mark {
    color: var(--standard-blue);
    font-weight: 600;
    font-size: 0.95rem;
}

.sticky-bar__title {
    font-weight: 500;
}

.sticky-bar__current {
    justify-self: end;
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--commentary-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.sticky-bar__label {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
}

.sticky-bar__num {
    color: var(--standard-blue);
    font-weight: 600;
    transition: opacity 180ms ease, transform 180ms ease;
}

.sticky-bar__num.is-flipping {
    opacity: 0;
    transform: translateY(-4px);
}

.sticky-bar__sep {
    color: var(--rule-line);
}

.sticky-bar__name {
    color: var(--rule-black);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 28ch;
}

.sticky-bar__progress {
    grid-column: 1 / -1;
    height: 1px;
    background: transparent;
    position: relative;
    margin-top: 6px;
}

.sticky-bar__progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: var(--standard-blue);
    transition: width 120ms linear;
}

@media (max-width: 540px) {
    .sticky-bar__label {
        display: none;
    }
    .sticky-bar__name {
        max-width: 14ch;
    }
}

/* =========================================================
   Document container
   ========================================================= */

.document {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 var(--gutter) 6rem;
}

/* =========================================================
   Hero / Masthead
   ========================================================= */

.hero {
    padding: clamp(3rem, 7vw, 5.5rem) 0 1.5rem;
    text-align: left;
}

.hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--commentary-gray);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 2rem;
}

.hero__meta > span {
    position: relative;
    padding-right: 1.25rem;
}

.hero__meta > span:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 0.85em;
    background: var(--rule-line);
}

.hero__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(2.2rem, 6vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: -0.02em;
    margin: 0 0 1.25rem;
    color: var(--rule-black);
}

/* The title text "mores.dev" already contains its own period;
   no decorative pseudo-element is added. */

.hero__descriptor {
    font-family: var(--font-body);
    font-size: clamp(1.15rem, 1.6vw, 1.35rem);
    line-height: 1.55;
    color: var(--rule-black);
    max-width: 56ch;
    margin: 0 0 2.75rem;
    font-weight: 400;
}

.hero__masthead {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    border-top: 1px solid var(--rule-line);
    margin: 0;
    padding-top: 1rem;
}

.hero__masthead-row {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 1rem;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--rule-line);
    align-items: baseline;
}

.hero__masthead-row dt {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--commentary-gray);
    margin: 0;
}

.hero__masthead-row dd {
    margin: 0;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--rule-black);
    line-height: 1.5;
}

@media (max-width: 540px) {
    .hero__masthead-row {
        grid-template-columns: 1fr;
        gap: 0.15rem;
        padding: 0.6rem 0;
    }
}

/* =========================================================
   Rule dividers
   ========================================================= */

.rule {
    border: 0;
    border-top: 1px solid var(--rule-line);
    margin: var(--rule-space) 0;
    height: 0;
}

.rule--major {
    margin: calc(var(--rule-space) * 1.6) 0;
    position: relative;
}

.rule--major::before,
.rule--major::after {
    content: "";
    position: absolute;
    left: 50%;
    top: -1px;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--standard-blue);
    box-shadow: 14px 0 0 var(--rule-line), -14px 0 0 var(--rule-line);
}

.rule--major::after {
    display: none;
}

/* =========================================================
   Table of contents
   ========================================================= */

.toc {
    padding: 0.5rem 0 0.5rem;
}

.toc__eyebrow {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--commentary-gray);
    margin: 0 0 1rem;
}

.toc__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 2.5rem;
    row-gap: 0;
}

@media (max-width: 600px) {
    .toc__list {
        grid-template-columns: 1fr;
    }
}

.toc__list li {
    border-bottom: 1px dotted var(--rule-line);
}

.toc__list a {
    display: grid;
    grid-template-columns: 3.5rem 1fr;
    gap: 1rem;
    padding: 0.5rem 0;
    text-decoration: none;
    color: var(--rule-black);
    transition: color 140ms ease, background 140ms ease;
    align-items: baseline;
}

.toc__list a:hover {
    color: var(--standard-blue);
}

.toc__num {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--standard-blue);
    font-weight: 600;
    letter-spacing: 0.02em;
}

.toc__label {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.35;
}

.toc__list a.is-current {
    color: var(--standard-blue);
}

.toc__list a.is-current .toc__label {
    text-decoration: underline;
    text-decoration-color: var(--standard-blue);
    text-underline-offset: 4px;
    text-decoration-thickness: 1px;
}

/* =========================================================
   Sections
   ========================================================= */

.section {
    padding: 0.5rem 0;
    scroll-margin-top: 90px;
}

.section__head {
    display: grid;
    grid-template-columns: 5.5rem 1fr;
    gap: 1.25rem;
    align-items: baseline;
    margin-bottom: 1.5rem;
}

@media (max-width: 540px) {
    .section__head {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

.section__num {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--standard-blue);
    font-size: clamp(1rem, 2vw, 1.5rem);
    letter-spacing: 0.01em;
    line-height: 1;
}

.section__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    line-height: 1.2;
    letter-spacing: -0.015em;
    color: var(--rule-black);
    margin: 0;
}

.section__body {
    grid-column: 2;
    margin-left: 0;
}

@media (min-width: 541px) {
    .section__body {
        margin-left: calc(5.5rem + 1.25rem);
    }
}

.section__body p {
    margin: 0 0 1.1rem;
    font-size: 1.05rem;
    line-height: 1.75;
    color: var(--rule-black);
    font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
}

.section__body p.lead {
    font-size: 1.18rem;
    line-height: 1.65;
    color: var(--rule-black);
}

.section__body em {
    font-style: italic;
    color: var(--rule-black);
}

.section__body code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--code-surface);
    padding: 0.08em 0.4em;
    border-radius: 3px;
    color: var(--rule-black);
}

.section__body a,
.inline-link {
    color: var(--standard-blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(37, 99, 235, 0.35);
    transition: border-color 140ms ease, color 140ms ease;
}

.section__body a:hover,
.inline-link:hover {
    border-bottom-color: var(--standard-blue);
}

/* =========================================================
   Plain list (do/avoid, in scope/out of scope)
   ========================================================= */

.plain-list {
    list-style: none;
    margin: 1.5rem 0;
    padding: 0;
    border-top: 1px solid var(--rule-line);
}

.plain-list li {
    display: grid;
    grid-template-columns: 8rem 1fr;
    gap: 1.25rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--rule-line);
    align-items: baseline;
}

@media (max-width: 540px) {
    .plain-list li {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }
}

.plain-list__marker {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--commentary-gray);
}

.plain-list li:first-child .plain-list__marker,
.plain-list li:nth-child(2) .plain-list__marker {
    color: var(--ethical-green);
}

/* =========================================================
   Numbered list
   ========================================================= */

.numbered-list {
    counter-reset: num-list;
    list-style: none;
    padding: 0;
    margin: 1.25rem 0 1.5rem;
}

.numbered-list li {
    counter-increment: num-list;
    position: relative;
    padding-left: 2.75rem;
    margin-bottom: 0.85rem;
    line-height: 1.7;
    font-size: 1.05rem;
}

.numbered-list li::before {
    content: counter(num-list, decimal) ".";
    position: absolute;
    left: 0;
    top: 0;
    font-family: var(--font-mono);
    color: var(--standard-blue);
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.9;
    width: 2rem;
    text-align: left;
}

.numbered-list strong {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--rule-black);
}

/* =========================================================
   Sidenote (small aside)
   ========================================================= */

.sidenote {
    margin: 1.5rem 0;
    padding: 1rem 1.1rem;
    border-left: 2px solid var(--rule-line);
    background: transparent;
    color: var(--commentary-gray);
}

.sidenote__label {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--commentary-gray);
    margin-bottom: 0.4rem;
}

.sidenote p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--commentary-gray);
}

/* =========================================================
   Pullquote
   ========================================================= */

.pullquote {
    margin: 2rem 0;
    padding: 0.5rem 0 0.5rem 1.25rem;
    border-left: 2px solid var(--rule-black);
    font-family: var(--font-body);
}

.pullquote p {
    font-size: 1.18rem;
    line-height: 1.55;
    font-style: italic;
    color: var(--rule-black);
    margin: 0 0 0.5rem;
}

.pullquote__source {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--commentary-gray);
}

/* =========================================================
   Codeblock — ethics-annotated
   ========================================================= */

.codeblock {
    margin: 1.75rem 0 2rem;
    background: var(--code-surface);
    border-left: 3px solid var(--ethical-green);
    border-radius: 0 4px 4px 0;
    padding: 1rem 1.1rem 1.1rem;
    overflow: hidden;
}

.codeblock__cap {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin: 0 0 0.7rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(26, 26, 34, 0.08);
}

.codeblock__num {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ethical-green);
    font-weight: 600;
}

.codeblock__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.92rem;
    color: var(--rule-black);
}

.codeblock pre {
    margin: 0;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--rule-black);
    padding: 0.25rem 0 0.1rem;
    -webkit-overflow-scrolling: touch;
}

.codeblock code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: inherit;
    color: inherit;
    white-space: pre;
}

/* Token highlighting (lightweight) */
.tok-c { color: var(--commentary-gray); font-style: italic; }
.tok-k { color: var(--standard-blue); }
.tok-fn { color: var(--rule-black); font-weight: 600; }
.tok-s { color: var(--ethical-green); }
.tok-v { color: var(--rule-black); }

/* =========================================================
   Colophon
   ========================================================= */

.colophon {
    margin: 2.5rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--rule-line);
    display: grid;
    gap: 0;
}

.colophon__row {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 1rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--rule-line);
    align-items: baseline;
}

.colophon__row dt {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--commentary-gray);
    margin: 0;
}

.colophon__row dd {
    margin: 0;
    font-family: var(--font-body);
    font-size: 0.98rem;
    color: var(--rule-black);
}

@media (max-width: 540px) {
    .colophon__row {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }
}

/* =========================================================
   Page foot
   ========================================================= */

.page-foot {
    margin-top: 4rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule-line);
}

.page-foot__line {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--commentary-gray);
    text-align: left;
    margin: 0;
    letter-spacing: 0.02em;
}

/* =========================================================
   Back-to-top
   ========================================================= */

.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 60;
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--rule-line);
    background: #ffffff;
    color: var(--rule-black);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    border-radius: 2px;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 200ms ease, transform 200ms ease, color 140ms ease, border-color 140ms ease;
    box-shadow: 0 1px 0 rgba(26, 26, 34, 0.04), 0 12px 28px -18px rgba(26, 26, 34, 0.25);
}

.back-to-top.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    color: var(--standard-blue);
    border-color: var(--standard-blue);
}

.back-to-top__arrow {
    color: var(--standard-blue);
    font-weight: 600;
}

@media (max-width: 540px) {
    .back-to-top {
        bottom: 16px;
        right: 16px;
        padding: 0.45rem 0.7rem;
        font-size: 0.72rem;
    }
}

/* =========================================================
   Selection
   ========================================================= */

::selection {
    background: rgba(37, 99, 235, 0.18);
    color: var(--rule-black);
}

/* =========================================================
   Print refinements (Swiss documents like printing)
   ========================================================= */

@media print {
    .sticky-bar,
    .back-to-top {
        display: none;
    }
    body {
        background: #ffffff;
    }
    .document {
        max-width: 100%;
    }
}
