/* ========== VARIABLES ========== */
:root {
    --bg: rgb(182, 182, 182);
    --text: #2c2420;
    --text-light: #7d6f67;
    --accent: #c94020;
    --rule: #625549;
    --max-w: 620px;
    --photo-w: 45vw;
    --speed: 0.15s;
}

/* ========== RESET ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
html {
    scroll-behavior: smooth;
}

::selection {
    background: #1a1a1a;
    color: #f0ece6;
}

body {
    font-family: "Playfair Display", Georgia, serif;
    font-optical-sizing: auto;
    color: var(--text);
    background: var(--bg);
    line-height: 1.77;
    font-size: 17.5px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ========== BASE ELEMENTS ========== */
h2 {
    font-weight: 500;
    font-size: clamp(22px, 3vw, 27px);
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 24px;
}

p {
    margin-bottom: 18px;
}
p:last-child {
    margin-bottom: 0;
}

a {
    color: var(--text);
    text-decoration-color: var(--rule);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
    border-radius: 0.5px;
    transition:
        color var(--speed),
        text-decoration-color var(--speed),
        box-shadow var(--speed),
        background-color var(--speed);
}
a:hover {
    background-color: #1a1a1a;
    color: #f0ece6;
    box-shadow: 0 0 0 3px #1a1a1a;
}

.section-rule {
    width: 40px;
    height: 1.5px;
    background: var(--accent);
    margin-bottom: 32px;
}

/* ========== LANG SWITCH ========== */
.lang-switch {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    letter-spacing: 0.08em;
}
/* Fixed positioning only on main page where lang-switch is a direct body child */
body > .lang-switch {
    position: fixed;
    top: 28px;
    right: 32px;
    z-index: 200;
    padding: 1px;
    background: var(--bg);
}
.lang-switch button {
    border: none;
    background: transparent;
    padding: 4px 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    letter-spacing: inherit;
    color: var(--text);
    border-radius: 0.5px;
    transition:
        color var(--speed),
        background-color var(--speed),
        box-shadow var(--speed);
    position: relative;
}
.lang-switch button:hover {
    background-color: #1a1a1a;
    color: #f0ece6;
    box-shadow: 0 0 0 3px #1a1a1a;
}
.lang-switch button.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 6px;
    right: 6px;
    height: 2px;
    background: var(--accent);
}
.lang-switch-sep {
    color: var(--rule);
    padding: 4px 0;
    user-select: none;
}

/* ========== CONTENT BLOCK TOGGLE ========== */
.content-block {
    display: none;
}
.content-block.active {
    display: block;
}

/* ========== MAIN PAGE — SPLIT LAYOUT ========== */
.page-wrapper {
    display: flex;
    min-height: 100vh;
}

.photo-column {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--photo-w);
    z-index: 10;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
}
.photo-column img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    filter: grayscale(0.3) contrast(1.05);
    mix-blend-mode: luminosity;
}

.content-column {
    margin-left: var(--photo-w);
    flex: 1;
    min-height: 100vh;
    position: relative;
}

/* ========== MAIN PAGE — HERO ========== */
.hero {
    padding: clamp(80px, 15vh, 160px) 48px 64px 48px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 100vh;
    min-height: 100svh;
}

.greeting {
    font-style: italic;
    font-size: 27px;
    color: var(--text);
    margin-bottom: 6px;
    opacity: 0;
    animation: fadeUp 0.9s ease forwards 0.2s;
}

.name {
    font-weight: 400;
    font-size: clamp(41px, 5vw, 54px);
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 28px;
    opacity: 0;
    animation: fadeUp 0.9s ease forwards 0.4s;
}

.lead {
    font-size: 23px;
    line-height: 1.65;
    color: var(--text);
    max-width: var(--max-w);
    opacity: 0;
    animation: fadeUp 0.9s ease forwards 0.6s;
}

.sub-lead {
    font-family: "IBM Plex Mono", monospace;
    font-size: 14px;
    color: var(--text-light);
    letter-spacing: 0.06em;
    margin-top: 16px;
    opacity: 0;
    animation: fadeUp 0.9s ease forwards 0.8s;
}
.sub-lead span {
    margin: 0 8px;
    color: var(--accent);
}

.scroll-hint {
    margin-top: 48px;
    opacity: 0;
    animation: fadeUp 0.9s ease forwards 1s;
}
.scroll-hint svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-light);
    animation: bobDown 2s ease-in-out infinite 2s;
}

/* ========== MAIN PAGE — SECTIONS ========== */
.sections-area {
    padding: 0 48px;
    position: relative;
}

.section-inner {
    max-width: var(--max-w);
    position: relative;
}

.section {
    padding: 56px 0;
    opacity: 0;
    transform: translateY(14px);
    transition:
        opacity 0.7s ease,
        transform 0.7s ease;
}
.section.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-marker {
    font-family: "IBM Plex Mono", monospace;
    font-size: 27px;
    color: var(--text-light);
    margin-bottom: 24px;
    user-select: none;
    letter-spacing: 0.06em;
}

.bio p {
    font-size: 16.5px;
}

.projects p {
    margin-bottom: 14px;
}

/* ========== MARKDOWN CONTENT (loam output) ========== */
.project-content {
    font-size: 16.5px;
}

/* Suppress redundant h1 — template title already handles it */
.project-content h1 {
    display: none;
}

/* First h3 after suppressed h1 acts as subtitle/lead */
.project-content h1 + h3 {
    display: block;
    font-family: "Playfair Display", Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: 19px;
    line-height: 1.5;
    letter-spacing: 0;
    color: var(--text-light);
    margin-top: 0;
    margin-bottom: 40px;
}

.project-content h2 {
    font-size: clamp(20px, 2.5vw, 24px);
    margin-top: 48px;
    margin-bottom: 16px;
}

.project-content h3 {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 500;
    font-size: 18px;
    line-height: 1.4;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-top: 32px;
    margin-bottom: 12px;
}

.project-content img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 40px 0;
    filter: grayscale(0.9) contrast(0.7);
    transition: filter 0.4s ease;
}
.project-content img:hover {
    filter: none;
}

.project-content blockquote {
    border-left: 3px solid var(--accent);
    margin: 40px 0;
    padding: 4px 0 4px 24px;
    font-style: italic;
    font-size: 18px;
    line-height: 1.7;
    color: var(--text);
}

.project-content blockquote p {
    margin-bottom: 0;
}

/* ========== TABLES ========== */
.project-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 15px;
}

.project-content thead th {
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-light);
    text-align: left;
    padding: 0 16px 10px 0;
    border-bottom: 1.5px solid var(--rule);
}

.project-content thead th:last-child {
    padding-right: 0;
}

.project-content tbody td {
    padding: 10px 16px 10px 0;
    border-bottom: 1px solid rgba(98, 85, 73, 0.25);
    vertical-align: top;
    color: var(--text);
}

.project-content tbody td:last-child {
    padding-right: 0;
}

.project-content tbody tr:last-child td {
    border-bottom: none;
}

/* Numeric columns right-aligned */
.project-content tbody td:not(:first-child),
.project-content thead th:not(:first-child) {
    text-align: right;
}

.project-content pre {
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.06);
    padding: 20px;
    overflow-x: auto;
    margin: 32px 0;
    line-height: 1.6;
}

.project-content code {
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 5px;
}

.project-content pre code {
    background: none;
    padding: 0;
}

.project-content hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 48px 0;
}

/* ========== MAIN PAGE — PORTFOLIO LIST ========== */
.portfolio-list {
    margin-top: 8px;
}

.portfolio-entry {
    padding: 20px 0;
    border-bottom: 1px solid var(--rule);
}
.portfolio-entry:last-child {
    border-bottom: none;
}

.entry-meta {
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    color: var(--text-light);
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    display: flex;
    gap: 16px;
}

h3.entry-title {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 500;
    font-size: 20px;
    line-height: 1.3;
    letter-spacing: -0.01em;
    margin-bottom: 8px;
}
h3.entry-title a {
    text-decoration: none;
}

.entry-desc {
    font-size: 15.5px;
    color: var(--text);
    margin-bottom: 0;
}

/* ========== MAIN PAGE — CONTACT ========== */
.contact-section {
    padding-bottom: clamp(80px, 12vh, 140px);
}

.juice-line {
    font-style: italic;
    font-size: 16.5px;
    margin-top: 4px;
}

.contact-links {
    font-family: "IBM Plex Mono", monospace;
    font-size: 14px;
    line-height: 2.2;
    margin-top: 24px;
}
.contact-links a:hover {
    text-decoration-color: #1a1a1a;
    color: #f0ece6;
}

/* ========== PORTFOLIO PAGES — NAV ========== */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 32px 28px 48px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
}

.back-link {
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--text-light);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--speed);
}
.back-link::before {
    content: "←";
}
.back-link:hover {
    color: var(--text);
    background: transparent;
    box-shadow: none;
}

/* ========== PORTFOLIO PAGES — CONTENT ========== */
.project-page {
    max-width: calc(var(--max-w) + 96px);
    margin: 0 auto;
    padding: 48px 48px clamp(80px, 12vh, 140px);
}

.project-meta {
    font-family: "IBM Plex Mono", monospace;
    font-size: 12px;
    color: var(--text-light);
    letter-spacing: 0.06em;
    margin-bottom: 16px;
    display: flex;
    gap: 16px;
}

h1.project-title {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 400;
    font-size: clamp(34px, 5vw, 48px);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 40px;
}

.project-page h2 {
    font-family: "Playfair Display", Georgia, serif;
    font-size: clamp(20px, 2.5vw, 24px);
    margin-top: 40px;
    margin-bottom: 16px;
}

.project-link {
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    letter-spacing: 0.04em;
    display: inline-block;
    margin-top: 32px;
    text-decoration: none;
    border-bottom: 1.5px solid var(--rule);
    padding-bottom: 2px;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes bobDown {
    0%,
    100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(6px);
    }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    :root {
        --photo-w: 40vw;
    }
    .hero,
    .sections-area {
        padding-left: 36px;
        padding-right: 36px;
    }
}

@media (max-width: 768px) {
    .page-wrapper {
        flex-direction: column;
    }
    .photo-column {
        position: relative;
        width: 100%;
        height: 60vh;
        justify-content: center;
    }
    .photo-column img {
        object-position: center center;
        height: 100%;
    }
    .content-column {
        margin-left: 0;
    }
    .hero {
        min-height: auto;
        padding-top: 48px;
        padding-bottom: 48px;
    }
    .hero,
    .sections-area {
        padding-left: 24px;
        padding-right: 24px;
    }
    .scroll-hint {
        display: none;
    }
    .top-nav {
        padding: 20px 24px;
    }
    .project-page {
        padding: 32px 24px clamp(60px, 10vh, 100px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .greeting,
    .name,
    .lead,
    .sub-lead,
    .scroll-hint {
        animation: none;
        opacity: 1;
    }
    .section {
        opacity: 1;
        transform: none;
        transition: none;
    }
    .scroll-hint svg {
        animation: none;
    }
    * {
        transition-duration: 0.01ms !important;
    }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 6px;
    background-color: transparent;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--rule);
    background-clip: padding-box;
    border-radius: 4px;
    border: 2px solid transparent;
}
@supports not selector(::-webkit-scrollbar) {
    * {
        scrollbar-width: thin;
        scrollbar-color: var(--rule) transparent;
    }
}
