/* =====================================================================
   MATT KHAN — PORTFOLIO V2
   "The annotated spec": editorial essay + specification vernacular.
   Paper / ink / graphite / hairline / one functional redline accent.
   Newsreader (display) · Public Sans (body) · IBM Plex Mono (annotation)
   ===================================================================== */

:root {
    --paper: #F7F7F5;
    --paper-raise: #FFFFFF;
    --ink: #1A1B1E;
    --graphite: #575A62;
    --hairline: #E4E4DE;
    --redline: #C8371F;

    --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
    --sans: 'Public Sans', -apple-system, 'Helvetica Neue', Arial, sans-serif;
    --mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;

    --measure: 42rem;      /* prose column */
    --wide: 66rem;         /* figures, work index */
    --page: 76rem;         /* outer frame */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: 16px;
}

@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.125rem;
    line-height: 1.65;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: var(--ink); color: var(--paper); }

a { color: inherit; }

img { max-width: 100%; height: auto; display: block; }

/* ---------- annotation utilities (the mono voice) ---------- */
.anno {
    font-family: var(--mono);
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--graphite);
    font-weight: 400;
}

.anno--redline { color: var(--redline); }

/* measurement underline — the signature mark */
.redline-measure {
    position: relative;
    white-space: nowrap;
}
.redline-measure::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: -0.14em;
    height: 9px;
    border-left: 1px solid var(--redline);
    border-right: 1px solid var(--redline);
    background:
        linear-gradient(var(--redline), var(--redline)) center / 100% 1px no-repeat;
}

/* ---------- frame ---------- */
.frame {
    max-width: var(--page);
    margin: 0 auto;
    padding: 0 1.5rem;
}

@media (min-width: 700px) {
    .frame { padding: 0 3rem; }
}

/* ---------- masthead ---------- */
.masthead {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.6rem 0 1.4rem;
    border-bottom: 1px solid var(--hairline);
    position: sticky;
    top: 0;
    z-index: 60;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.masthead-name {
    font-family: var(--mono);
    font-size: 0.95rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    text-decoration: none;
    font-weight: 500;
}

.masthead-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.6rem 1.75rem;
}

.masthead-nav a {
    font-family: var(--mono);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-decoration: none;
    color: var(--graphite);
}

.masthead-nav a:hover { color: var(--redline); }

.masthead-nav a.is-active {
    color: var(--ink);
    text-decoration: underline;
    text-decoration-color: var(--redline);
    text-decoration-thickness: 1px;
    text-underline-offset: 6px;
}

/* reading progress — hairline redline across the very top */
.progress {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--redline);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 100;
    pointer-events: none;
}

/* ---------- hero ---------- */
.hero {
    padding: 6.5rem 0 5rem;
}

.hero .anno { display: block; margin-bottom: 2.2rem; }

.hero-title {
    font-family: var(--serif);
    font-optical-sizing: auto;
    font-weight: 380;
    font-size: clamp(2.35rem, 6vw, 4.4rem);
    line-height: 1.13;
    letter-spacing: -0.015em;
    max-width: 21ch;
    text-wrap: balance;
}

.hero-title em {
    font-style: italic;
    font-weight: 360;
}

.hero-sub {
    max-width: var(--measure);
    margin-top: 2.4rem;
    font-size: 1.1rem;
    color: var(--ink);
}

.hero-sub + .hero-sub { margin-top: 0.9rem; }

/* spec-sheet facts table */
.spec {
    margin-top: 4.2rem;
    border-top: 1px solid var(--hairline);
    display: grid;
    grid-template-columns: 1fr;
}

@media (min-width: 700px) {
    .spec { grid-template-columns: repeat(4, 1fr); }
    .spec--three { grid-template-columns: repeat(3, 1fr); }
}

.spec-cell {
    padding: 1.1rem 1.5rem 1.2rem 0;
    border-bottom: 1px solid var(--hairline);
}

.spec-cell .anno { display: block; margin-bottom: 0.45rem; }

.spec-value {
    font-size: 1.08rem;
    line-height: 1.45;
}

/* ---------- trust strip ---------- */
.trust {
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    padding: 1.5rem 0 1.7rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.9rem 2.6rem;
}

.trust .anno { margin-right: 0.6rem; }

.trust-mark {
    font-family: var(--serif);
    font-weight: 420;
    font-size: 1.12rem;
    letter-spacing: 0.01em;
    color: var(--graphite);
    white-space: nowrap;
}

/* ---------- section scaffolding ---------- */
.section { padding: 5.5rem 0 1rem; }

.section-head {
    display: flex;
    align-items: baseline;
    gap: 1.25rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--ink);
    margin-bottom: 0.5rem;
}

.section-head h2 {
    font-family: var(--serif);
    font-weight: 420;
    font-size: 2.15rem;
    letter-spacing: -0.012em;
    text-wrap: balance;
}

section[id] { scroll-margin-top: 5.5rem; }

/* ---------- work index ---------- */
.work-entry {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.4rem;
    padding: 2.6rem 0;
    border-bottom: 1px solid var(--hairline);
    text-decoration: none;
}

@media (min-width: 860px) {
    .work-entry { grid-template-columns: 3.2rem 1fr 17rem; gap: 2rem; }
}

.work-index {
    font-family: var(--serif);
    font-size: 1.6rem;
    font-weight: 380;
    line-height: 1;
    color: var(--graphite);
    opacity: 0.6;
    padding-top: 0.45rem;
    font-variant-numeric: oldstyle-nums;
}

.work-title {
    display: block;
    font-family: var(--serif);
    font-weight: 420;
    font-size: clamp(1.45rem, 2.6vw, 1.9rem);
    line-height: 1.22;
    letter-spacing: -0.01em;
    max-width: 24ch;
}

.work-entry:hover .work-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: var(--redline); }

.work-dek {
    display: block;
    margin-top: 0.7rem;
    color: var(--graphite);
    font-size: 1.08rem;
    max-width: 52ch;
}

.work-meta {
    margin-top: 0.9rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.4rem;
}

.work-thumb {
    align-self: center;
    border: 1px solid var(--hairline);
    background: var(--paper-raise);
    padding: 0.4rem;
    transition: box-shadow 200ms ease;
}

.work-entry:hover .work-thumb,
.work-entry:focus-visible .work-thumb { box-shadow: 0 6px 18px rgba(26, 27, 30, 0.08); }

.work-thumb img {
    aspect-ratio: 16 / 10;
    object-fit: cover;
    object-position: top;
    filter: saturate(0.35);
    transition: filter 200ms ease;
}

.work-entry:hover .work-thumb img,
.work-entry:focus-visible .work-thumb img { filter: saturate(1); }

/* additional work — compact ledger */
.ledger {
    list-style: none;
    columns: 1;
    column-gap: 4rem;
    padding: 1.4rem 0 2rem;
}

@media (min-width: 700px) { .ledger { columns: 2; } }

.ledger li {
    break-inside: avoid;
    border-bottom: 1px solid var(--hairline);
}

.ledger a {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.85rem 0;
    text-decoration: none;
}

.ledger a:hover .ledger-name { text-decoration: underline; text-decoration-color: var(--redline); text-underline-offset: 3px; text-decoration-thickness: 1px; }

.ledger-name { font-size: 1.05rem; }

/* ---------- selected results ---------- */
.results {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 2rem;
    border-top: 1px solid var(--hairline);
}

@media (min-width: 700px) {
    .results { grid-template-columns: 1fr 1fr; column-gap: 3.5rem; }
}

.results li {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.9rem;
    padding: 1rem 0 1.05rem;
    border-bottom: 1px solid var(--hairline);
    font-size: 1.08rem;
    line-height: 1.5;
    break-inside: avoid;
}

.results li i {
    color: var(--redline);
    font-size: 0.95rem;
    padding-top: 0.42rem;
}

/* ---------- design principles ---------- */
.principles {
    list-style: none;
    max-width: var(--wide);
    margin-top: 1.2rem;
}

.principles li {
    display: grid;
    grid-template-columns: 3.6rem 1fr;
    gap: 1.6rem;
    align-items: baseline;
    padding: 1.35rem 0 1.45rem;
    border-bottom: 1px solid var(--hairline);
}

.principle-no {
    font-family: var(--serif);
    font-size: 1.7rem;
    font-weight: 380;
    line-height: 1;
    color: var(--redline);
    font-variant-numeric: oldstyle-nums;
}

.principle-text {
    font-family: var(--serif);
    font-weight: 400;
    font-size: clamp(1.25rem, 2.4vw, 1.55rem);
    line-height: 1.32;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

/* ---------- about ---------- */
.prose {
    max-width: var(--measure);
    padding: 2.2rem 0;
}

.prose p + p { margin-top: 1.1rem; }

.prose p { text-wrap: pretty; }

/* editorial drop cap */
.prose--dropcap > p:first-child::first-letter {
    font-family: var(--serif);
    font-size: 3.3em;
    float: left;
    line-height: 0.8;
    padding: 0.09em 0.14em 0 0;
    font-weight: 400;
}

.skills {
    display: grid;
    grid-template-columns: 1fr;
    border-top: 1px solid var(--hairline);
    margin-top: 1.4rem;
}

@media (min-width: 700px) { .skills { grid-template-columns: repeat(3, 1fr); } }

.skills-group {
    border-bottom: 1px solid var(--hairline);
    padding: 1.3rem 1.5rem 1.4rem 0;
}

.skills-group .anno { display: block; margin-bottom: 0.6rem; }

.skills-group ul { list-style: none; }

.skills-group li {
    font-size: 1.02rem;
    line-height: 1.75;
    color: var(--ink);
}

/* ---------- contact ---------- */
.contact { padding: 6rem 0 2rem; }

.contact-line {
    font-family: var(--serif);
    font-weight: 380;
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    line-height: 1.2;
    letter-spacing: -0.012em;
    max-width: 24ch;
}

.contact-actions {
    margin-top: 2.4rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2.5rem;
    align-items: baseline;
}

.contact-actions a {
    font-family: var(--mono);
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-decoration: none;
    border-bottom: 1px solid var(--ink);
    padding-bottom: 0.2rem;
}

.contact-actions a:hover { border-bottom-color: var(--redline); color: var(--redline); }

.foot {
    margin-top: 5rem;
    padding: 1.4rem 0 2.2rem;
    border-top: 1px solid var(--hairline);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.8rem;
}

/* =====================================================================
   CASE STUDY
   ===================================================================== */
.cs-head { padding: 5rem 0 0; }

.cs-title {
    font-family: var(--serif);
    font-weight: 390;
    font-size: clamp(2rem, 5vw, 3.6rem);
    line-height: 1.14;
    letter-spacing: -0.014em;
    max-width: 22ch;
    margin-top: 2rem;
    text-wrap: balance;
}

.cs-dek {
    max-width: var(--measure);
    margin-top: 1.6rem;
    font-size: 1.1rem;
    color: var(--graphite);
}

.cs-spec { margin-top: 3.4rem; }

.cs-section { padding-top: 4.5rem; }

.cs-section > .anno { display: block; margin-bottom: 1.1rem; }

.cs-section h2 {
    font-family: var(--serif);
    font-weight: 420;
    font-size: 1.7rem;
    letter-spacing: -0.01em;
    margin-bottom: 1.2rem;
    max-width: 26ch;
}

.cs-section .prose { padding: 0; }

/* figures */
figure.fig {
    max-width: var(--wide);
    margin: 2.6rem 0 0;
}

figure.fig img {
    border: 1px solid var(--hairline);
    background: var(--paper-raise);
    width: 100%;
}

figure.fig figcaption {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    padding-top: 0.7rem;
    max-width: var(--measure);
}

figure.fig figcaption .fig-no {
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--redline);
    padding-top: 0.15rem;
    white-space: nowrap;
}

figure.fig figcaption .fig-text {
    font-size: 1rem;
    line-height: 1.55;
    color: var(--graphite);
}

figure.fig--narrow { max-width: 30rem; }

/* lead figure at the top of a section: sits higher, with room before the title */
.cs-section > figure.fig:first-child {
    margin-top: 0;
    margin-bottom: 3rem;
}

/* browser-mockup swipe gallery: horizontal scroll-snap between screens,
   vertical scroll within a screen like a live page */
.browser {
    border: 1px solid var(--hairline);
    background: var(--paper-raise);
}

.browser-chrome {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--hairline);
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--graphite);
}

.browser-dots { display: inline-flex; gap: 5px; }
.browser-dots i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--hairline);
}

.browser-addr {
    flex: 1;
    min-width: 0;
    background: var(--paper);
    border: 1px solid var(--hairline);
    border-radius: 99px;
    padding: 0.15rem 0.9rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.browser-count {
    color: var(--redline);
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.browser-btn {
    font-family: var(--mono);
    font-size: 0.9rem;
    line-height: 1;
    padding: 0.25rem 0.6rem;
    background: var(--paper);
    border: 1px solid var(--hairline);
    color: var(--ink);
    cursor: pointer;
}
.browser-btn:disabled { opacity: 0.35; cursor: default; }
.browser-btn:hover:not(:disabled) { border-color: var(--graphite); }

.browser-strip {
    position: relative;
    display: flex;
    gap: 1rem;
    padding: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 1rem;
    height: min(70vh, 40rem);
}

.browser-slide {
    flex: 0 0 min(88%, 30rem);
    scroll-snap-align: start;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--hairline);
    background: #fff;
}

.browser-slide img {
    width: 100%;
    height: auto;
    border: 0;
}

/* phones: slides don't scroll internally (vertical swipes stay with the page);
   tap a screen to see it full size in the lightbox instead */
@media (max-width: 700px) {
    .browser-strip { height: min(55vh, 40rem); }
    .browser-slide { overflow-y: hidden; }
}

/* lightbox: click any figure or gallery screen to view it full size */
figure.fig img,
.browser-slide img { cursor: zoom-in; }

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    padding: 2rem;
    background: rgba(26, 27, 30, 0.93);
    overflow: auto;
    cursor: zoom-out;
}

.lightbox img {
    margin: auto;
    max-width: min(94vw, 90rem);
    height: auto;
    border: 1px solid var(--hairline);
    background: #fff;
}

.lightbox-hint {
    position: fixed;
    top: 1rem;
    right: 1.4rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--paper);
    opacity: 0.8;
    pointer-events: none;
}

/* prev / next */
.cs-next {
    margin-top: 6rem;
    border-top: 1px solid var(--ink);
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    padding: 1.6rem 0 0;
}

.cs-next a {
    text-decoration: none;
    max-width: 46%;
}

.cs-next a .anno { display: block; margin-bottom: 0.5rem; }

.cs-next a strong {
    font-family: var(--serif);
    font-weight: 420;
    font-size: 1.25rem;
    line-height: 1.3;
}

.cs-next a:hover strong { text-decoration: underline; text-decoration-color: var(--redline); text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* ---------- load sequence ---------- */
@media (prefers-reduced-motion: no-preference) {
    .rise {
        opacity: 0;
        transform: translateY(10px);
        animation: rise 620ms cubic-bezier(0.2, 0.6, 0.2, 1) forwards;
    }
    .rise:nth-child(2) { animation-delay: 70ms; }
    .rise:nth-child(3) { animation-delay: 140ms; }
    .rise:nth-child(4) { animation-delay: 210ms; }
    .rise:nth-child(5) { animation-delay: 280ms; }
    @keyframes rise { to { opacity: 1; transform: none; } }
}

/* ---------- scroll reveals (added by v2.js only when motion is allowed;
   without JS nothing is hidden) ---------- */
@media (prefers-reduced-motion: no-preference) {
    .reveal {
        opacity: 0;
        transform: translateY(14px);
        transition: opacity 550ms ease, transform 550ms cubic-bezier(0.2, 0.6, 0.2, 1);
    }
    .reveal.is-in { opacity: 1; transform: none; }
}

/* ---------- hover refinements ---------- */
.work-thumb { overflow: hidden; }

.work-entry:hover .work-index,
.work-entry:focus-visible .work-index { color: var(--redline); opacity: 1; }

.ledger a .anno { transition: color 150ms ease; }
.ledger a:hover .anno { color: var(--redline); }

.foot-top { text-decoration: none; }
.foot-top:hover { color: var(--redline); }

@media (prefers-reduced-motion: no-preference) {
    .work-index { transition: color 200ms ease, opacity 200ms ease; }
    .work-thumb img { transition: filter 300ms ease, transform 600ms cubic-bezier(0.2, 0.6, 0.2, 1); }
    .work-entry:hover .work-thumb img,
    .work-entry:focus-visible .work-thumb img { transform: scale(1.025); }
    .cta { transition: transform 150ms ease, color 150ms ease, border-color 150ms ease, background 150ms ease; }
    .cta:hover { transform: translateY(-1px); }
}

/* print: never hide revealed content, drop screen chrome */
@media print {
    .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    .progress, .foot-top { display: none !important; }
    .masthead { position: static; }
}

/* ---------- access ---------- */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--ink);
    color: var(--paper);
    padding: 0.7rem 1.2rem;
    font-family: var(--mono);
    font-size: 0.8rem;
    text-decoration: none;
}
.skip-link:focus { left: 0; }

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--redline);
    outline-offset: 3px;
}

/* case-study quote */
.cs-quote {
    max-width: var(--measure);
    margin: 2.4rem 0 0;
    padding-left: 1.4rem;
    border-left: 2px solid var(--redline);
}

.cs-quote p {
    font-family: var(--serif);
    font-size: 1.25rem;
    line-height: 1.5;
    font-weight: 380;
    font-style: italic;
}

.cs-quote cite {
    display: block;
    margin-top: 0.8rem;
    font-style: normal;
    font-family: var(--mono);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--graphite);
}

/* ---------- icons (Font Awesome, used sparingly) ---------- */
.anno i,
.status-pill i,
.contact-actions a i,
.foot i {
    font-size: 0.9em;
    color: inherit;
}

.anno i { margin-right: 0.15em; }

/* spec cells: icon becomes a block-level anchor above the label */
.spec-cell > .anno > i {
    display: block;
    font-size: 1.55rem;
    margin: 0 0 0.7rem;
    color: var(--ink);
    opacity: 0.85;
}

/* section heads: slightly larger wayfinding icons */
.section-head .anno i { font-size: 1.05em; }
.status-pill i { margin-right: 0.35em; }
.cs-next .anno i { margin: 0; }

/* ---------- recruiter CTAs ---------- */
.hero-cta-row {
    margin-top: 2.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.cta {
    font-family: var(--mono);
    font-size: 0.88rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    border: 1px solid var(--ink);
    padding: 0.8rem 1.3rem;
    color: var(--ink);
}

.cta:hover { border-color: var(--redline); color: var(--redline); }

.cta--primary {
    background: var(--ink);
    color: var(--paper);
}

.cta--primary:hover { background: var(--redline); border-color: var(--redline); color: var(--paper); }

.masthead-resume {
    border: 1px solid var(--ink);
    padding: 0.45rem 0.8rem;
    color: var(--ink) !important;
}

.masthead-resume:hover { border-color: var(--redline); color: var(--redline) !important; }

.work-thumb--seal img { filter: none; }
