/* ---------------------------------------------------------------------------
   Ilyass Bougati — portfolio.
   Monospace, square corners, one accent. The page is meant to read like the
   manual of an old piece of software: numbered sections, rules, a status line.
   Light is paper, dark is a phosphor terminal.
   --------------------------------------------------------------------------- */

:root {
    --bg: #f2efe6;
    --panel: #ebe7db;
    --fg: #1a1a1a;
    --dim: #6b6660;
    --accent: #b02020;
    --rule: #c9c3b4;
    --rule-strong: #1a1a1a;
    --glow: none;

    --mono: "DejaVu Sans Mono", "Liberation Mono", Menlo, Consolas, monospace;
    --measure: 76ch;
}

[data-theme="dark"] {
    --bg: #14161a;
    --panel: #1a1d23;
    --fg: #d8d4cc;
    --dim: #7d8590;
    --accent: #ff5f56;
    --rule: #2f343c;
    --rule-strong: #3a3f47;
    --glow: 0 0 18px rgba(255, 95, 86, 0.22);
}

/* Anyone who lands before main.js runs still gets their system preference. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #14161a;
        --panel: #1a1d23;
        --fg: #d8d4cc;
        --dim: #7d8590;
        --accent: #ff5f56;
        --rule: #2f343c;
        --rule-strong: #3a3f47;
        --glow: 0 0 18px rgba(255, 95, 86, 0.22);
    }
}

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

html {
    background: var(--bg);
    scroll-behavior: smooth;
    scroll-padding-top: 4.5rem;
}

body {
    background: var(--bg);
    color: var(--fg);
    font-family: var(--mono);
    font-size: 16px;
    line-height: 1.65;
    margin: 0;
    padding: 0 0 5rem;
}

/* Scanlines, dark theme only. Low enough not to fight the text. */
[data-theme="dark"] body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 90;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.025) 0 1px,
        transparent 1px 3px
    );
}

main,
footer {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- status line ---------------------------------------------------------
   A tmux-ish bar: who you are on the left, what you can change on the right. */

.statusbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 0.55rem 1.5rem;
    background: var(--bg);
    border-bottom: 1px solid var(--rule-strong);
    font-size: 0.78rem;
}

.sb-host {
    color: var(--accent);
    white-space: nowrap;
}

.sb-nav {
    display: flex;
    gap: 1rem;
    margin-right: auto;
}

.sb-nav a {
    color: var(--dim);
    text-decoration: none;
    border: 0;
    padding: 0;
}

.sb-nav a::before {
    content: "/";
    margin-right: 0.15em;
    opacity: 0.55;
}

.sb-nav a:hover,
.sb-nav a:focus-visible {
    color: var(--accent);
    background: none;
    outline: none;
}

.sb-switches {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.switch {
    font: inherit;
    color: var(--dim);
    background: none;
    border: 0;
    padding: 0.1rem 0.2rem;
    cursor: pointer;
    white-space: nowrap;
}

.switch b {
    font-weight: 400;
    opacity: 0.45;
}

.switch:hover,
.switch:focus-visible {
    color: var(--accent);
    outline: none;
}

/* The theme button names what a click will do, not where you already are,
   which is also what its aria-label says. */
[data-theme="dark"] .is-dark,
[data-theme="light"] .is-light {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .is-dark  { display: none; }
    :root:not([data-theme="light"]) .is-light { display: inline; }
}

.skip {
    position: absolute;
    left: -9999px;
}

.skip:focus {
    position: static;
    display: inline-block;
    margin: 0.5rem 1.5rem;
}

/* --- language switching --------------------------------------------------
   Both languages ship in the markup; only one is ever displayed. No JS needed
   to read the page, and view-source shows the whole thing. */

[data-lang="en"] .fr,
[data-lang="fr"] .en {
    display: none;
}

/* --- hero ----------------------------------------------------------------- */

.hero {
    padding: 3.5rem 0 2rem;
}

.banner {
    margin: 0 0 1.75rem;
    color: var(--accent);
    font-size: clamp(6px, 2.35vw, 19px);
    /* Block glyphs have to touch across rows or the letters look striped. */
    line-height: 0.85;
    text-shadow: var(--glow);
    overflow: hidden;
}

.name {
    font-size: 2rem;
    letter-spacing: 0.02em;
    margin: 0 0 1.25rem;
}

/* On anything wide enough for the block letters, the banner is the name. */
@media (min-width: 640px) {
    .name {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (max-width: 639px) {
    .banner {
        display: none;
    }
}

.headline {
    font-size: 1.05rem;
    max-width: 60ch;
    margin: 0 0 1.75rem;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.85rem;
    color: var(--dim);
}

.hero-meta li::before {
    content: "·";
    color: var(--accent);
    margin-right: 0.5em;
}

/* --- prompt lines --------------------------------------------------------- */

.prompt {
    color: var(--dim);
    font-size: 0.85rem;
    margin: 0 0 0.6rem;
    letter-spacing: 0.04em;
}

.sigil {
    color: var(--accent);
    margin-right: 0.4em;
}

.prompt::after {
    content: "_";
    color: var(--accent);
    margin-left: 0.15em;
    animation: blink 1.1s step-end infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.profile {
    padding-bottom: 1rem;
}

.summary {
    font-size: 1rem;
    max-width: 66ch;
    margin: 0;
}

/* --- sections ------------------------------------------------------------- */

section {
    padding-top: 3.25rem;
}

h2 {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    margin: 0 0 1.75rem;
}

h2 .num {
    color: var(--accent);
    font-weight: 400;
    letter-spacing: 0.1em;
}

h2 .fill {
    flex: 1;
    border-bottom: 1px dashed var(--rule);
}

/* --- entries -------------------------------------------------------------- */

.entry {
    position: relative;
    padding: 0 0 0 1.5rem;
    margin-bottom: 2.5rem;
    border-left: 1px solid var(--rule);
}

/* The square sits on the rule and marks where an entry starts. */
.entry::before {
    content: "";
    position: absolute;
    left: -3.5px;
    top: 0.62em;
    width: 6px;
    height: 6px;
    background: var(--accent);
}

.entry:last-child {
    margin-bottom: 0;
}

.entry.compact {
    margin-bottom: 1.5rem;
}

.entry-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 1rem;
}

/* The title takes the slack so a long one wraps on itself and leaves the
   date where it belongs, at the top right. */
.entry-head h3 {
    flex: 1 1 0;
    min-width: 0;
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.entry-head h3 .at {
    font-weight: 400;
    color: var(--dim);
}

.meta {
    flex: 0 0 auto;
    font-size: 0.78rem;
    color: var(--dim);
    white-space: nowrap;
    letter-spacing: 0.03em;
}

.sub {
    font-size: 0.85rem;
    color: var(--dim);
    margin: 0.2rem 0 0.9rem;
}

.bullets {
    list-style: none;
    margin: 0;
    padding: 0;
}

.bullets li {
    position: relative;
    padding-left: 1.4rem;
    margin-bottom: 0.55rem;
    font-size: 0.93rem;
}

.bullets li::before {
    content: "▸";
    position: absolute;
    left: 0;
    color: var(--accent);
}

.bullets li:last-child {
    margin-bottom: 0;
}

b {
    font-weight: 700;
}

/* --- the featured entry --------------------------------------------------
   Framed like a figure in a manual, with technical-drawing corner marks. */

.entry.featured {
    border: 1px solid var(--rule-strong);
    background: var(--panel);
    padding: 1.6rem 1.5rem;
    margin-bottom: 0;
}

.entry.featured::before {
    content: none;
}

.frame-top,
.frame-bottom {
    position: absolute;
    left: 0;
    right: 0;
    height: 0;
}

.frame-top { top: 0; }
.frame-bottom { bottom: 0; }

.frame-top::before,
.frame-top::after,
.frame-bottom::before,
.frame-bottom::after {
    content: "+";
    position: absolute;
    color: var(--accent);
    font-size: 0.8rem;
    line-height: 0;
}

.frame-top::before,
.frame-bottom::before {
    left: 0;
    transform: translate(-50%, 0);
}

.frame-top::after,
.frame-bottom::after {
    right: 0;
    transform: translate(50%, 0);
}

/* --- stack + contact lists ------------------------------------------------ */

.stack,
.contact {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 1.75rem;
    row-gap: 0.9rem;
    margin: 0;
}

.stack dt,
.contact dt {
    font-size: 0.78rem;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding-top: 0.35rem;
    white-space: nowrap;
}

.stack dd,
.contact dd {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.contact dd {
    padding-top: 0.25rem;
    font-size: 0.93rem;
}

.tag {
    display: inline-block;
    font-size: 0.82rem;
    color: var(--fg);
    border: 1px solid var(--rule);
    padding: 0.1rem 0.5rem;
    white-space: nowrap;
}

.tag::before { content: "["; color: var(--dim); margin-right: 0.25em; }
.tag::after  { content: "]"; color: var(--dim); margin-left: 0.25em; }

.tag:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.contact-line {
    margin: 0 0 1.75rem;
    max-width: 62ch;
}

/* --- two-column block ----------------------------------------------------- */

.columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
    gap: 2rem;
}

.column h4 {
    font-size: 0.78rem;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 400;
    margin: 0 0 0.9rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--rule);
}

.plain {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.9rem;
}

.plain li {
    margin-bottom: 0.65rem;
    padding-left: 1.2rem;
    position: relative;
}

.plain li::before {
    content: "·";
    position: absolute;
    left: 0.25rem;
    color: var(--accent);
}

.dim {
    color: var(--dim);
}

/* --- links ---------------------------------------------------------------- */

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid var(--accent);
    padding: 0.1rem 0.15rem;
}

/* Invert on hover, the way a terminal selection looks. */
a:hover,
a:focus-visible {
    background: var(--accent);
    color: var(--bg);
    outline: none;
}

/* --- footer --------------------------------------------------------------- */

footer {
    margin-top: 4.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--rule);
}

footer p {
    margin: 0 0 0.6rem;
    max-width: 62ch;
    font-size: 0.85rem;
}

/* --- error pages ----------------------------------------------------------
   not_found.html and bad_request.html: one big code, one line under it. */

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

.error .code {
    font-size: 4rem;
    line-height: 1;
    margin: 0 0 1rem;
    color: var(--accent);
    text-shadow: var(--glow);
}

.error h1 {
    font-size: 1.1rem;
    font-weight: 400;
    margin: 0 0 1.25rem;
}

.error p {
    color: var(--dim);
    margin: 0 0 2rem;
    max-width: 60ch;
}

.back {
    display: inline-block;
}

.back::before { content: "["; }
.back::after  { content: "]"; }

/* --- the old sefaultd page ------------------------------------------------ */

.plainpage {
    max-width: 68ch;
    margin: 0 auto;
    padding: 4rem 1.5rem 6rem;
}

.plainpage h1 {
    font-size: 1.5rem;
    line-height: 1.3;
    margin: 0 0 1.5rem;
}

.plainpage p {
    margin: 0 0 1.5rem;
}

.plainpage a {
    display: inline-block;
    margin-right: 0.5rem;
}

.plainpage a::before { content: "["; }
.plainpage a::after  { content: "]"; }

/* --- motion + narrow screens ---------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .prompt::after { animation: none; }
}

@media (max-width: 720px) {
    .sb-nav {
        display: none;
    }

    .statusbar {
        justify-content: space-between;
        padding: 0.55rem 1rem;
    }

    main,
    footer {
        padding: 0 1.25rem;
    }

    .stack,
    .contact {
        grid-template-columns: 1fr;
        row-gap: 0.4rem;
    }

    .stack dt,
    .contact dt {
        padding-top: 0.9rem;
    }

    .entry-head {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* --- print ---------------------------------------------------------------
   The page doubles as a CV, so make it survive a printer: paper colours,
   no chrome, no page breaks through an entry. */

@media print {
    :root {
        --bg: #fff;
        --panel: #fff;
        --fg: #000;
        --dim: #444;
        --accent: #000;
        --rule: #bbb;
        --rule-strong: #000;
        --glow: none;
    }

    .statusbar,
    .skip,
    .prompt,
    .sb-nav,
    footer .dim {
        display: none;
    }

    body::after { content: none; }

    body {
        font-size: 10pt;
    }

    .hero {
        padding-top: 0;
    }

    .banner {
        display: none;
    }

    .name {
        position: static;
        width: auto;
        height: auto;
        clip-path: none;
        font-size: 1.6rem;
    }

    section {
        padding-top: 1.5rem;
    }

    .entry,
    .column {
        break-inside: avoid;
    }

    a {
        border-bottom: 0;
    }

    /* Links are only useful on paper if the address comes with them —
       except in the contact list, where the address is already the text. */
    .bullets a::after,
    .sub a::after,
    .entry-head h3 a::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #444;
        word-break: break-all;
    }
}
