/* ──────────────────────────────────────────────────────────────
   PERFEDGE — styles.css
   Editorial masthead aesthetic. Cream background, black text,
   type-driven, no images, no accent colors.
   ────────────────────────────────────────────────────────────── */

/* Tokens */
:root {
    /* Palette */
    --bg-cream:        #F5F2EC;
    --bg-cream-soft:   #F4F1EA;
    --bg-footer:       #ECECEC;
    --ink-black:       #0A0A0A;
    --ink-grey:        #555;
    --ink-mute:        #777d83;
    --rule-thin:       #c4c4be;
    --rule-soft:       #dcdcd5;
    --accent:          #a3120a;

    /* Type families */
    --font-display:    "Fraunces", Georgia, "Times New Roman", serif;
    --font-body:       "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-ui:         "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono:       "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

    /* Type scale */
    --t-display:       clamp(2.5rem, 7vw, 5.5rem);
    --t-h2:            clamp(1.5rem, 3vw, 2.25rem);
    --t-h3:            clamp(1.125rem, 2vw, 1.5rem);
    --t-body-lg:       1.125rem;
    --t-body:          1rem;
    --t-meta:          0.75rem;
    --t-tiny:          0.6875rem;

    /* Line height */
    --lh-display:      1.05;
    --lh-tight:        1.25;
    --lh-body:         1.6;

    /* Tracking */
    --tracking-meta:   0.18em;
    --tracking-display: -0.02em;

    /* Spacing scale */
    --s-1:             0.25rem;
    --s-2:             0.5rem;
    --s-3:             0.75rem;
    --s-4:             1rem;
    --s-5:             1.5rem;
    --s-6:             2rem;
    --s-7:             3rem;
    --s-8:             4rem;
    --s-9:             6rem;
    --s-10:            8rem;
    --s-11:            12rem;

    /* Layout */
    --content-medium:  860px;
    --content-wide:    1200px;
}

/* Minimal reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--t-body);
    line-height: var(--lh-body);
    color: var(--ink-black);
    background-color: #fff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

img, svg {
    display: block;
    max-width: 100%;
}

a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 0.2em;
    text-decoration-thickness: 1px;
}

a:hover {
    text-decoration-thickness: 2px;
}

em {
    color: var(--accent);
}

/* Containers */
.site {
    max-width: 1280px;
    margin: 0 auto;
    padding-inline: 56px;
}

@media (max-width: 720px) {
    .site { padding-inline: 22px; }
}

.container {
    width: 100%;
    max-width: var(--content-wide);
    margin: 0 auto;
}

.container-medium {
    max-width: var(--content-medium);
    margin: 0 auto;
    text-align: center;
}

/* Editorial primitives */
.meta {
    font-family: var(--font-mono);
    font-size: var(--t-meta);
    text-transform: uppercase;
    letter-spacing: var(--tracking-meta);
    font-weight: 500;
}

/* Display heading */
.display {
    font-family: var(--font-display);
    font-size: var(--t-display);
    line-height: var(--lh-display);
    letter-spacing: var(--tracking-display);
    font-weight: 500;
    text-align: center;
    max-width: var(--content-medium);
    margin: 0 auto;
}

/* Page-section spacing */
.section {
    padding: var(--s-9) 0;
}

.section--tight {
    padding: var(--s-7) 0;
}

/* ──────────────────────────────────────────────────────────────
   Masthead — header / nav / band
   ────────────────────────────────────────────────────────────── */
.masthead {
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.masthead__top {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding-top: var(--s-5);
    padding-bottom: var(--s-5);
    gap: var(--s-5);
    border-bottom: 1px solid var(--rule-thin);
}

.logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    justify-self: start;
}

.logo__img {
    display: block;
    height: 44px;
    width: auto;
}

.nav {
    justify-self: end;
}

.nav__list {
    list-style: none;
    display: flex;
    gap: var(--s-5);
    align-items: center;
}

.nav__link {
    font-family: var(--font-ui);
    text-decoration: none;
    font-size: 0.95rem;
    color: var(--ink-black);
    padding-bottom: 2px;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s;
}

.nav__link:hover {
    border-bottom-color: var(--ink-black);
}

.nav__link.is-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Dropdown submenu */
.nav__item--has-sub {
    position: relative;
}

.nav__sub {
    list-style: none;
    margin: 0;
    padding: var(--s-3) 0;
    position: absolute;
    top: calc(100% + var(--s-3));
    left: 0;
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--rule-thin);
    box-shadow: 0 12px 32px rgba(10, 10, 10, 0.06);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 150;
}

/* Hover bridge so the menu doesn't dismiss when crossing the gap */
.nav__item--has-sub::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: var(--s-3);
}

.nav__item--has-sub:hover .nav__sub,
.nav__item--has-sub:focus-within .nav__sub {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav__sub-link {
    display: block;
    padding: var(--s-2) var(--s-5);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    color: var(--ink-black);
    text-decoration: none;
    white-space: nowrap;
    border-left: 2px solid transparent;
}

.nav__sub-link:hover,
.nav__sub-link.is-active {
    background: var(--bg-cream);
    border-left-color: var(--accent);
}

.nav-toggle {
    display: none;
    background: none;
    border: 0;
    width: 32px;
    height: 32px;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 4px;
}

.nav-toggle span {
    display: block;
    height: 1px;
    background: var(--ink-black);
    width: 100%;
}

/* Mobile nav */
@media (max-width: 880px) {
    .masthead__top {
        grid-template-columns: 1fr auto;
    }
    .nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: #fff;
        display: none;
        align-items: center;
        justify-content: center;
        z-index: 200;
    }
    .nav.is-open {
        display: flex;
    }
    .nav__list {
        flex-direction: column;
        gap: var(--s-5);
        font-size: 1.25rem;
    }
    .nav-toggle {
        display: flex;
        justify-self: end;
    }
    .nav__item--has-sub::after {
        display: none;
    }
    .nav__sub {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        background: transparent;
        border: 0;
        box-shadow: none;
        margin-top: var(--s-3);
        padding: 0;
        text-align: center;
    }
    .nav__sub-link {
        font-size: 1rem;
        text-align: center;
        padding: var(--s-2) 0;
        border-left: 0;
    }
    .nav__sub-link:hover,
    .nav__sub-link.is-active {
        background: transparent;
        border-left: 0;
    }
}

/* ──────────────────────────────────────────────────────────────
   Main
   ────────────────────────────────────────────────────────────── */
.main {
    min-height: 60vh;
}

/* ──────────────────────────────────────────────────────────────
   Closing CTA
   ────────────────────────────────────────────────────────────── */
.closing-cta {
    text-align: center;
    border-top: 1px solid var(--rule-thin);
}

.closing-cta__lead {
    font-size: var(--t-body-lg);
    margin-bottom: var(--s-4);
}

.closing-cta__email {
    font-family: var(--font-mono);
    font-size: 0.95rem;
}

/* ──────────────────────────────────────────────────────────────
   Site footer
   ────────────────────────────────────────────────────────────── */
.site-footer {
    background: var(--bg-footer);
    border-top: 1px solid var(--rule-thin);
    margin-inline: -56px;
    padding: var(--s-7) 56px;
    margin-top: var(--s-8);
    font-size: var(--t-meta);
    line-height: 1.5;
    color: var(--ink-grey);
}

@media (max-width: 720px) {
    .site-footer {
        margin-inline: -22px;
        padding-inline: 22px;
    }
}

.site-footer__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-7);
}

.site-footer__col--right {
    text-align: right;
}

.site-footer__brand {
    font-weight: 600;
    color: var(--ink-black);
    letter-spacing: 0.04em;
    font-size: 0.85rem;
    margin-bottom: var(--s-3);
}

.site-footer__links {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-4);
    margin-bottom: var(--s-3);
}

.site-footer__links a {
    text-decoration: none;
    color: var(--ink-grey);
}

.site-footer__links a:hover {
    color: var(--ink-black);
}

.site-footer__email {
    font-family: var(--font-mono);
}

.site-footer__reg {
    color: var(--ink-grey);
}

.site-footer__copy {
    margin-top: var(--s-3);
}

@media (max-width: 600px) {
    .site-footer__grid {
        grid-template-columns: 1fr;
    }
    .site-footer__col--right {
        text-align: left;
    }
}

/* ──────────────────────────────────────────────────────────────
   Hero
   ────────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding-top: var(--s-7);
    padding-bottom: var(--s-5);
}

.hero .display {
    font-size: clamp(2rem, 5vw, 3.25rem);
}

/* ──────────────────────────────────────────────────────────────
   Divider grid: column grid with vertical rules between items.
   Default: 3 cols, compact density. Modifiers:
     .divider-grid--2     → 2 cols
     .divider-grid--4     → 4 cols
     .divider-grid--card  → heavier padding (homepage pillars, products, contact)
   ────────────────────────────────────────────────────────────── */
.divider-grid {
    --pad-x: var(--s-5);
    --pad-top: var(--s-6);
    display: grid;
    grid-template-columns: repeat(var(--cols, 3), 1fr);
    border-top: 1px solid var(--rule-thin);
}

.divider-grid--2 { --cols: 2; }
.divider-grid--4 { --cols: 4; }
.divider-grid--card {
    --pad-x: var(--s-7);
    --pad-top: var(--s-7);
}

.divider-grid > * {
    padding: var(--pad-top) var(--pad-x) var(--s-6) var(--pad-x);
    border-right: 1px solid var(--rule-soft);
}

/* Default 3-col: strip left padding on column 1, strip right padding/border on column 3 */
.divider-grid:not(.divider-grid--2):not(.divider-grid--4) > *:nth-child(3n+1) {
    padding-left: 0;
}
.divider-grid:not(.divider-grid--2):not(.divider-grid--4) > *:nth-child(3n) {
    padding-right: 0;
    border-right: 0;
}

/* 2-col variant */
.divider-grid--2 > *:nth-child(2n+1) {
    padding-left: 0;
}
.divider-grid--2 > *:nth-child(2n) {
    padding-right: 0;
    border-right: 0;
}

/* Safety net for the very last item if a row is short of cols */
.divider-grid > *:last-child {
    border-right: 0;
}

/* 2-col / 3-col → 1-col at 720px */
@media (max-width: 720px) {
    .divider-grid:not(.divider-grid--4) {
        --cols: 1;
    }
    .divider-grid:not(.divider-grid--4) > * {
        padding: var(--s-6) 0;
        border-right: 0;
        border-bottom: 1px solid var(--rule-soft);
    }
    .divider-grid:not(.divider-grid--4) > *:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }
}

/* 4-col: 2-col intermediate at 900px, 1-col at 600px */
@media (max-width: 900px) {
    .divider-grid--4 { --cols: 2; }
    .divider-grid--4 > * {
        padding: var(--s-6) 0;
        border-right: 0;
    }
    .divider-grid--4 > *:nth-child(odd) {
        padding-right: var(--s-4);
        border-right: 1px solid var(--rule-soft);
    }
    .divider-grid--4 > *:nth-child(even) {
        padding-left: var(--s-4);
    }
    .divider-grid--4 > *:nth-child(-n+2) {
        border-bottom: 1px solid var(--rule-soft);
    }
}

@media (max-width: 600px) {
    .divider-grid--4 { --cols: 1; }
    .divider-grid--4 > *,
    .divider-grid--4 > *:nth-child(odd),
    .divider-grid--4 > *:nth-child(even) {
        padding: var(--s-6) 0;
        border-right: 0;
        border-bottom: 1px solid var(--rule-soft);
    }
    .divider-grid--4 > *:last-child {
        border-bottom: 0;
        padding-bottom: 0;
    }
}

/* ──────────────────────────────────────────────────────────────
   Card primitives — used inside .divider-grid items
   ────────────────────────────────────────────────────────────── */
.card-title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.25rem;
    line-height: var(--lh-tight);
    letter-spacing: -0.01em;
    color: var(--ink-black);
    margin-bottom: var(--s-3);
}

.divider-grid--card .card-title {
    font-size: var(--t-h3);
    margin-bottom: var(--s-2);
}

.card-body {
    font-size: 0.9375rem;
    color: var(--ink-grey);
    line-height: var(--lh-body);
}

.divider-grid--card .card-body {
    font-size: var(--t-body);
    color: var(--ink-black);
    margin-bottom: var(--s-5);
}

.card-sub {
    font-family: var(--font-mono);
    font-size: var(--t-meta);
    color: var(--ink-grey);
    text-transform: uppercase;
    letter-spacing: var(--tracking-meta);
    margin-bottom: var(--s-4);
}

.card-link {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.card-link a {
    text-decoration: none;
    border-bottom: 1px solid var(--ink-black);
    padding-bottom: 1px;
}

.prose-section {
    border-bottom: 1px solid var(--rule-thin);
}

.prose-section:last-of-type,
.prose-section--flush {
    border-bottom: 0;
}

.prose-section p {
    font-size: var(--t-body-lg);
    line-height: var(--lh-body);
    margin-bottom: var(--s-5);
}

.prose-section p:last-child {
    margin-bottom: 0;
}

/* ──────────────────────────────────────────────────────────────
   Chapter (editorial: label + title + kicker, then items grid)
   ────────────────────────────────────────────────────────────── */
.chapter {
    border-bottom: 1px solid var(--rule-thin);
}

.chapter__head {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: var(--s-7);
    margin-bottom: var(--s-8);
}

.chapter__num {
    font-family: var(--font-mono);
    font-size: var(--t-meta);
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--ink-mute);
    padding-top: var(--s-3);
}

.chapter__num-roman {
    display: block;
    color: var(--accent);
    margin-bottom: var(--s-1);
}

.chapter__title {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.02em;
    font-size: clamp(1.75rem, 4vw, 3rem);
    line-height: var(--lh-tight);
    color: var(--ink-black);
    max-width: 22ch;
    text-wrap: balance;
}

.chapter__title--wide {
    max-width: 36ch;
}

.chapter__kicker {
    font-family: var(--font-body);
    font-size: var(--t-body-lg);
    color: var(--ink-grey);
    line-height: var(--lh-body);
    margin-top: var(--s-4);
    max-width: 78ch;
}

@media (max-width: 900px) {
    .chapter__head {
        grid-template-columns: 1fr;
        gap: var(--s-4);
        margin-bottom: var(--s-7);
    }
    .chapter__num {
        padding-top: 0;
    }
}

/* ──────────────────────────────────────────────────────────────
   Case-study layout overrides
   Case studies are content-heavy; widen the frame on larger
   screens and loosen the prose column slightly. The frame still
   centres, so smaller viewports are unaffected.
   ────────────────────────────────────────────────────────────── */
.body--case-study .site {
    max-width: 1440px;
}

.body--case-study .chapter__kicker {
    max-width: 88ch;
}

/* ──────────────────────────────────────────────────────────────
   Case-study figures (screenshots inside chapter prose)
   Stack one per row so dense screenshots are readable at full
   chapter-column width.
   ────────────────────────────────────────────────────────────── */
.case-figure {
    margin: var(--s-6) 0 0;
}

.case-figure__grid {
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
}

.case-figure img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--rule-thin);
    border-radius: 4px;
}

.case-figure__caption {
    font-family: var(--font-body);
    font-size: var(--t-meta);
    color: var(--ink-mute);
    line-height: var(--lh-body);
    margin-top: var(--s-4);
}

/* ──────────────────────────────────────────────────────────────
   Client logos (horizontal strip; sits below a chapter-head)
   ────────────────────────────────────────────────────────────── */
.client-logos {
    margin-top: var(--s-7);
    padding-top: var(--s-7);
    border-top: 1px solid var(--rule-thin);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--s-7) var(--s-9);
}

.client-logos__logo {
    height: clamp(28px, 2.4vw, 36px);
    width: auto;
    filter: grayscale(1);
    opacity: 0.65;
    transition: filter 200ms ease, opacity 200ms ease;
}

.client-logos__logo:hover {
    filter: grayscale(0);
    opacity: 1;
}

@media (max-width: 600px) {
    .client-logos {
        gap: var(--s-6) var(--s-7);
    }
}

/* ──────────────────────────────────────────────────────────────
   Contact card primitives (label/value/note pattern, contact page)
   ────────────────────────────────────────────────────────────── */
.contact-card__label {
    color: var(--ink-grey);
    margin-bottom: var(--s-3);
}

.contact-card__value {
    font-size: var(--t-body-lg);
    line-height: var(--lh-body);
    font-style: normal;
}

.contact-card__value a {
    font-family: var(--font-mono);
    font-size: 0.95rem;
    text-decoration: none;
    border-bottom: 1px solid var(--ink-black);
    padding-bottom: 1px;
}

.contact-card__note {
    font-size: var(--t-meta);
    color: var(--ink-grey);
    margin-top: var(--s-3);
    font-style: italic;
}
