/* ========================================
   Subpage Styles
   ======================================== */

/* ========================================
   Page Navigation (Back & Share row)
   ======================================== */
.page-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--large-gap);
}

.back-link,
.share-btn {
    font-size: var(--font-large);
    font-weight: 700;
    color: var(--secondary-color);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: 'Lato', sans-serif;
    transition: opacity 0.2s ease;
}

.back-link:hover,
.share-btn:hover {
    opacity: 0.7;
}

/* ========================================
   Page Header
   ======================================== */
.page-header {
    margin-bottom: var(--large-gap);
}

.page-icon {
    color: var(--icon-color);
    margin-bottom: var(--large-gap);
    width: 88px;
    height: 88px;
}

.page-icon svg {
    width: 88px;
    height: 88px;
    color: var(--icon-color);
}

/* Align the visible icon graphic with the left edge of the page text.
   The shared `.icon-mask` centers the mask by default; on tall/narrow SVGs
   that creates a noticeable left inset on post pages. */
.page-icon .icon-mask {
    /* Optional per-icon horizontal tweak (defaults to 0%). */
    --page-icon-mask-offset-x: 0%;
    -webkit-mask-position: left var(--page-icon-mask-offset-x) center;
    mask-position: left var(--page-icon-mask-offset-x) center;
}

/* Some icons are square viewBoxes with built-in left padding, so `mask-position: left`
   alone can't align the drawn glyph. Nudge the mask left to compensate (page-only). */
.page-icon .icon-mask[data-icon="resume.svg"] {
    --page-icon-mask-offset-x: -17.5%;
}

.page-icon .icon-mask[data-icon="modern-ai-workspace.svg"] {
    --page-icon-mask-offset-x: -14.1667%;
}

@media (max-width: 520px) {
    .page-icon {
        width: 72px;
        height: 72px;
    }

    .page-icon svg {
        width: 72px;
        height: 72px;
    }
}

.page-title {
    font-size: 24pt;
    font-weight: 700;
    /* Match the "icon green" accent used throughout the site (light mode). */
    color: var(--icon-color);
    line-height: 1.2;
    margin-bottom: 8px;
}

/* ========================================
   Page Content
   ======================================== */
.page-content {
    color: var(--secondary-color);
    font-size: var(--font-large);
    line-height: 1.7;
}

.page-content h1,
.page-content h2,
.page-content h3,
.page-content h4,
.page-content h5,
.page-content h6 {
    /* Markdown headings should use the same accent as the page icon. */
    color: var(--icon-color);
    font-weight: 700;
    margin: 1.5em 0 0.6em;
}

.page-content ul,
.page-content ol {
    margin: 0 0 1.5em 1.2em;
}

.page-content ul ul,
.page-content ul ol,
.page-content ol ul,
.page-content ol ol {
    margin-top: 0.6em;
    margin-bottom: 0.8em;
}

.page-content li {
    margin-bottom: 0.4em;
}

.page-content .md-hr {
    border: none;
    height: 1px;
    background: var(--card-border);
    margin: 2.5em 0;
    opacity: 0.8;
}

.page-content img.md-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    box-shadow: var(--card-shadow);
    margin: 1.8em 0;
    transition: box-shadow 0.3s ease;
}

.page-content img.md-image:hover {
    box-shadow: var(--card-shadow-hover);
}

.page-content pre {
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    border-radius: 10px;
    padding: 12px 14px;
    overflow: auto;
    margin-bottom: 1.5em;
    color: var(--primary-color);
}

.page-content p {
    margin-bottom: 1.5em;
}

.page-content p:last-child {
    margin-bottom: 0;
}

.page-content .link {
    color: var(--secondary-color);
}

/* ========================================
   Post Table of Contents (desktop-only rail)
   ======================================== */
.post-toc {
    --toc-collapsed-width: 140px;
    --toc-open-width: 240px;
    --toc-inner-pad-x: 10px;
    --toc-width: var(--toc-collapsed-width);
    --toc-gutter: 24px;
    /* Set by JS so the ToC content aligns with the top of `#page-title`. */
    --toc-content-top: calc(var(--top-spacing) + 70px);

    position: fixed;
    top: 0;
    bottom: 0;
    /* Sit in the left gutter next to the centered content; clamp to the viewport edge. */
    left: max(0px, calc(50% - (var(--site-width) * 0.5) - var(--toc-open-width) - var(--toc-gutter)));

    width: var(--toc-width);
    overflow: hidden;
    z-index: 1200;

    transition: width 0.18s ease, left 0.18s ease;
    color: var(--secondary-color);
    outline: none;
}

/* Nudge the ToC a bit further left on wider screens. */
@media (min-width: 1280px) {
    .post-toc {
        --toc-gutter: 56px;
    }
}

@media (min-width: 1500px) {
    .post-toc {
        --toc-gutter: 80px;
    }
}

.post-toc:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 6px;
    border-radius: 999px;
}

.post-toc__panel {
    position: absolute;
    inset: 0;
    width: 100%;

    display: flex;
    flex-direction: column;
    gap: 10px;

    padding: var(--toc-content-top) var(--toc-inner-pad-x) 14px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: background 0.18s ease;
}

.post-toc__title {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    line-height: 1.2;
    opacity: 0.28;
    color: var(--primary-color);
    margin: 0;
    white-space: nowrap;
}

.post-toc__body {
    position: relative;
    flex: 1;
    min-height: 0;
}

.post-toc__collapsed-lines {
    position: absolute;
    inset: 0;
    overflow: hidden;

    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.post-toc__collapsed-line {
    display: block;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.18;
    margin: 7px 0;

    /* Length scaling to visually encode heading depth (left-aligned). */
    --toc-line-indent: 0px;
    --toc-line-scale: 1;
    width: 100%;
    margin-left: var(--toc-line-indent);
    transform-origin: left center;
    transform: scaleX(var(--toc-line-scale));
}

.post-toc__collapsed-line:first-child {
    margin-top: 0;
}

.post-toc__collapsed-line:last-child {
    margin-bottom: 0;
}

.post-toc__collapsed-line.is-active {
    opacity: 0.42;
}

.post-toc:hover,
.post-toc:focus-within {
    --toc-width: var(--toc-open-width);
}

.post-toc:hover .post-toc__panel,
.post-toc:focus-within .post-toc__panel {
    background: linear-gradient(to right, var(--toc-bg), transparent 92%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.post-toc__list {
    position: absolute;
    inset: 0;
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge legacy */

    visibility: hidden;
    opacity: 0;
    transform: translateX(-6px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}

.post-toc__list::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.post-toc:hover .post-toc__collapsed-lines,
.post-toc:focus-within .post-toc__collapsed-lines {
    opacity: 0;
    transform: translateX(-6px);
}

.post-toc:hover .post-toc__list,
.post-toc:focus-within .post-toc__list {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

.post-toc__item {
    padding-left: calc(var(--toc-depth, 0) * 12px);
}

.post-toc__link {
    display: block;
    padding: 4px 0;
    font-size: var(--font-small);
    line-height: 1.35;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.post-toc__link:hover {
    opacity: 0.95;
}

.post-toc__link:focus-visible {
    opacity: 1;
    outline: 2px solid var(--primary-color);
    outline-offset: 3px;
    border-radius: 4px;
}

.post-toc__link.is-active {
    opacity: 1;
    font-weight: 700;
    color: var(--primary-color);
}

/* Don't show the ToC rail on mobile. */
@media (max-width: 520px) {
    .post-toc {
        display: none !important;
    }
}

/* ========================================
   Resume Timeline Component
   ======================================== */
.resume-timeline {
    position: relative;
    padding-left: 32px;
}

/* The animated vertical timeline line */
.timeline-line {
    position: absolute;
    left: 6px;
    top: 13px; /* Align with center of first marker */
    width: 2px;
    height: 0;
    background: linear-gradient(
        to bottom,
        var(--secondary-color) 0%,
        var(--secondary-color) 70%,
        transparent 100%
    );
    opacity: 0.3;
    z-index: 0;
}

/* Line animation - grows from top to bottom */
.timeline-line.is-animating {
    height: var(--line-height, 0);
    transition: height 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Company block - contains marker + all roles for one company */
.timeline-company-block {
    position: relative;
    padding-bottom: 32px;
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.timeline-company-block:last-child {
    padding-bottom: 0;
}

/* Animated state for company blocks */
.timeline-company-block.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Timeline bullet marker - only on company blocks */
.timeline-marker {
    position: absolute;
    left: -32px;
    top: 6px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 3px solid var(--primary-color);
    box-shadow: 0 0 0 4px var(--bg-color);
    z-index: 2;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}

/* Show marker when company block is visible */
.timeline-company-block.is-visible .timeline-marker {
    opacity: 1;
    transform: scale(1);
}

/* Current position (first company) marker styling */
.timeline-marker.is-current {
    background: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--bg-color), 0 0 12px rgba(44, 58, 51, 0.3);
}

:root[data-theme="dark"] .timeline-marker.is-current {
    box-shadow: 0 0 0 4px var(--bg-color), 0 0 12px rgba(156, 172, 166, 0.3);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .timeline-marker.is-current {
        box-shadow: 0 0 0 4px var(--bg-color), 0 0 12px rgba(156, 172, 166, 0.3);
    }
}

/* Timeline content container */
.timeline-content {
    padding-left: 8px;
}

/* Company name */
.timeline-company {
    font-size: var(--font-large);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

/* Role container */
.timeline-role {
    margin-bottom: 24px;
}

.timeline-role:last-child {
    margin-bottom: 0;
}

/* Job title */
.timeline-title {
    font-size: var(--font-medium);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 4px;
}

/* Meta info (date range and duration) */
.timeline-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--font-small);
    color: var(--secondary-color);
    margin-bottom: 4px;
}

.timeline-separator {
    opacity: 0.5;
}

.timeline-date {
    font-weight: 700;
}

.timeline-duration {
    font-weight: 400;
}

/* Location */
.timeline-location {
    font-size: var(--font-small);
    color: var(--secondary-color);
    opacity: 0.8;
    margin-bottom: 12px;
}

/* Description */
.timeline-description {
    font-size: var(--font-medium);
    color: var(--secondary-color);
    line-height: 1.6;
    margin-bottom: 0;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .timeline-company-block {
        opacity: 1;
        transform: none;
        transition: none;
    }
    
    .timeline-marker {
        opacity: 1;
        transform: none;
        transition: none;
    }
    
    .timeline-line {
        height: 100% !important;
        transition: none;
    }
    
    .timeline-line.is-animating {
        height: var(--line-height, 100%) !important;
    }
}

/* Mobile responsive adjustments */
@media (max-width: 520px) {
    .resume-timeline {
        padding-left: 28px;
    }
    
    .timeline-line {
        left: 5px;
        top: 11px;
    }
    
    .timeline-marker {
        left: -28px;
        width: 12px;
        height: 12px;
        border-width: 2px;
    }
    
    .timeline-company-block {
        padding-bottom: 24px;
    }
    
    .timeline-meta {
        flex-wrap: wrap;
    }
}

/* ========================================
   4x4s Beats Timeline Component
   ======================================== */

/* Intro paragraph */
.beats-intro {
    margin-bottom: var(--large-gap);
}

.beats-intro p {
    font-size: var(--font-large);
    color: var(--secondary-color);
    line-height: 1.7;
    margin: 0;
}

.beats-intro .link {
    color: var(--secondary-color);
}

.beats-timeline {
    position: relative;
    padding-left: 56px;
}

/* The animated vertical timeline line */
.beats-line {
    position: absolute;
    left: 19px;
    top: 20px;
    width: 2px;
    height: 0;
    background: linear-gradient(
        to bottom,
        var(--secondary-color) 0%,
        var(--secondary-color) 70%,
        transparent 100%
    );
    opacity: 0.25;
    z-index: 0;
}

.beats-line.is-animating {
    height: var(--line-height, 0);
    transition: height 1.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Beat entry container */
.beats-entry {
    position: relative;
    padding-bottom: 36px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

.beats-entry:last-of-type {
    padding-bottom: 0;
}

.beats-entry.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Square date marker */
.beats-marker {
    position: absolute;
    left: -56px;
    top: 0;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--card-bg);
    border: none;
    box-shadow: var(--card-shadow);
    z-index: 2;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out, 
                background 0.2s ease;
}

.beats-entry.is-visible .beats-marker {
    opacity: 1;
    transform: scale(1);
}

/* Current (newest) marker styling */
.beats-marker.is-current {
    background: var(--primary-color);
    box-shadow: var(--card-shadow), 0 0 12px rgba(44, 58, 51, 0.25);
}

.beats-marker.is-current .beats-marker-date {
    color: var(--bg-color);
}

:root[data-theme="dark"] .beats-marker.is-current {
    box-shadow: var(--card-shadow), 0 0 12px rgba(156, 172, 166, 0.25);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .beats-marker.is-current {
        box-shadow: var(--card-shadow), 0 0 12px rgba(156, 172, 166, 0.25);
    }
}

.beats-marker-date {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

/* Content container */
.beats-content {
    padding-left: 8px;
    padding-top: 0;
}

/* Audio player container - same height as date marker */
.beats-player {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0 10px;
    height: 40px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.beats-player:not(.is-placeholder):hover {
    box-shadow: var(--card-shadow);
    border-color: var(--primary-color);
}

.beats-player.is-placeholder {
    opacity: 0.7;
}

/* Play button */
.beats-play-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--secondary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: color 0.2s ease, background 0.2s ease;
}

.beats-play-btn:not(:disabled):hover {
    color: var(--primary-color);
    background: var(--toggle-hover-bg);
}

.beats-play-btn:not(:disabled):active {
    transform: scale(0.95);
}

.beats-play-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.beats-play-icon,
.beats-pause-icon {
    width: 16px;
    height: 16px;
}

.beats-play-icon {
    margin-left: 1px;
}

/* Hide pause icon by default, show when playing */
.beats-pause-icon {
    display: none;
}

.beats-player.is-playing .beats-play-icon {
    display: none;
}

.beats-player.is-playing .beats-pause-icon {
    display: block;
}

/* Minimal progress line (replaces waveform) */
.beats-progress {
    flex: 1;
    position: relative;
    height: 2px;
    border-radius: 999px;
    background: var(--card-border);
    overflow: hidden;
}

.beats-progress-fill {
    position: absolute;
    inset: 0;
    background: var(--primary-color);
    transform-origin: left center;
    transform: scaleX(var(--beats-progress, 0));
    transition: transform 0.08s linear;
}

/* Download button inside player */
.beats-download {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--secondary-color);
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease;
}

.beats-download:not(.is-disabled):hover {
    color: var(--primary-color);
    background: var(--toggle-hover-bg);
}

.beats-download.is-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.beats-download-icon {
    width: 16px;
    height: 16px;
}

/* Load more trigger */
.beats-load-more {
    padding: 24px 0;
    display: flex;
    justify-content: center;
}

.beats-load-more-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--secondary-color);
    font-size: var(--font-small);
    opacity: 0.6;
}

.beats-load-more-text {
    animation: pulse-opacity 1.5s ease-in-out infinite;
}

@keyframes pulse-opacity {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .beats-entry {
        opacity: 1;
        transform: none;
        transition: none;
    }
    
    .beats-marker {
        opacity: 1;
        transform: none;
        transition: none;
    }
    
    .beats-line {
        height: 100% !important;
        transition: none;
    }
    
    .beats-line.is-animating {
        height: var(--line-height, 100%) !important;
    }
    
    .beats-load-more-text {
        animation: none;
        opacity: 0.6;
    }

    .beats-progress-fill {
        transition: none;
    }
}

/* Mobile responsive adjustments for beats timeline */
@media (max-width: 520px) {
    .beats-timeline {
        padding-left: 48px;
    }
    
    .beats-line {
        left: 15px;
        top: 16px;
    }
    
    .beats-marker {
        left: -48px;
        width: 34px;
        height: 34px;
        border-radius: 4px;
    }
    
    .beats-marker-date {
        font-size: 10px;
    }
    
    .beats-entry {
        padding-bottom: 20px;
    }
    
    .beats-player {
        height: 34px;
        gap: 6px;
        padding: 0 8px;
    }
    
    .beats-play-btn {
        width: 24px;
        height: 24px;
    }
    
    .beats-play-icon,
    .beats-pause-icon {
        width: 14px;
        height: 14px;
    }
    
    .beats-progress {
        height: 2px;
    }
    
    .beats-download {
        width: 24px;
        height: 24px;
    }
    
    .beats-download-icon {
        width: 14px;
        height: 14px;
    }
}
