/* ============================================
   LOGBOOK HERO
   ============================================ */

.docs-hero {
    padding: 140px 2rem 3rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.docs-eyebrow {
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.docs-title {
    font-size: 2.75rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.docs-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    max-width: 640px;
    margin: 0 auto;
}

/* ============================================
   DOCS LAYOUT
   ============================================ */

.docs-layout {
    padding: 3rem 0 5rem;
}

.docs-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 3rem;
    align-items: start;
}

/* ============================================
   NAVIGATION TREE
   ============================================ */

.docs-sidebar {
    position: sticky;
    top: 100px;
}

/* Only shown on narrow layouts (see media query below) — on desktop the
   tree is just always visible in the sticky sidebar. */
.docs-toc-toggle {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    background: rgba(37, 37, 37, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 0.85rem 1rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.docs-toc-toggle:hover {
    border-color: var(--accent);
    background: rgba(99, 102, 241, 0.12);
}

.docs-toc-toggle-icon {
    color: var(--accent);
    transition: transform 0.2s ease;
}

.docs-toc-toggle[aria-expanded="true"] .docs-toc-toggle-icon {
    transform: rotate(180deg);
}

.docs-tree {
    background: rgba(37, 37, 37, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem;
}

.docs-tree-stage {
    margin-bottom: 0.25rem;
}

.docs-tree-stage:last-child {
    margin-bottom: 0;
}

.docs-tree-stage-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.6rem 0.5rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
    text-align: left;
}

.docs-tree-stage-toggle:hover {
    background: rgba(99, 102, 241, 0.12);
}

.docs-tree-caret {
    color: var(--accent);
    font-size: 0.7rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.docs-tree-stage-toggle[aria-expanded="false"] .docs-tree-caret {
    transform: rotate(-90deg);
}

.docs-tree-entries {
    list-style: none;
    margin: 0.1rem 0 0.5rem 1.6rem;
    border-left: 1px solid var(--border-color);
    padding-left: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow: hidden;
    max-height: 500px;
    transition: max-height 0.25s ease;
}

.docs-tree-entries.collapsed {
    max-height: 0;
}

.docs-tree-entry {
    display: block;
    padding: 0.4rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.docs-tree-entry:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.docs-tree-entry.active {
    color: var(--accent-light);
    background: rgba(99, 102, 241, 0.18);
    font-weight: 600;
}

/* ============================================
   ENTRY CONTENT
   ============================================ */

.docs-stage {
    margin-bottom: 3.5rem;
    scroll-margin-top: 100px;
}

.docs-stage:last-child {
    margin-bottom: 0;
}

.docs-stage-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.docs-entry {
    background: rgba(37, 37, 37, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
    scroll-margin-top: 100px;
    transition: border-color 0.3s ease;
}

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

.docs-entry:target {
    border-color: var(--accent);
}

.docs-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.docs-entry-title {
    font-size: 1.15rem;
    color: var(--text-primary);
}

.docs-entry-date {
    font-size: 0.8rem;
    color: var(--accent-light);
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.docs-entry-body p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.98rem;
}

.docs-entry-body p + p {
    margin-top: 1rem;
}

.docs-entry-image {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    margin-top: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Reusable photo-trio layout: two photos side by side on top, one wide
   photo spanning the bottom. Column widths are set per-instance via an
   inline grid-template-columns (use each image's own aspect ratio as the
   fr value — e.g. "0.757fr 6px 1.415fr" — and the two rendered heights
   come out equal automatically). Image sizing is just width: 100% /
   height: auto — no object-fit or percentage heights needed (those don't
   resolve reliably against auto grid rows). The seam between images is a
   hairline track filled with a continuous zigzag — like a jagged/torn
   edge meshing the photos together — rather than a gap. */
.docs-entry-photo-grid {
    display: grid;
    width: 100%;
    grid-template-columns: 1fr 6px 1fr; /* fallback if no inline override is set */
    grid-template-rows: auto 6px auto;
    margin-top: 1.25rem;
}

.docs-entry-photo-grid img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.docs-entry-photo-grid .photo-grid-left {
    grid-column: 1;
    grid-row: 1;
}

.docs-entry-photo-grid .photo-grid-right {
    grid-column: 3;
    grid-row: 1;
}

.docs-entry-photo-grid .photo-grid-wide {
    grid-column: 1 / -1;
    grid-row: 3;
}

.photo-divider {
    position: relative;
}

.photo-divider--vertical {
    grid-column: 2;
    grid-row: 1;
}

.photo-divider--horizontal {
    grid-column: 1 / -1;
    grid-row: 2;
}

.photo-divider::before {
    content: '';
    position: absolute;
    inset: 0;
}

/* Continuous zigzag running the full length of the seam — an SVG tile
   repeated along the strip, rather than spaced-out marks with gaps. */
.photo-divider--vertical::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='6' height='16'><path d='M1,0 L5,8 L1,16' stroke='%236366f1' stroke-width='1.6' fill='none'/></svg>");
    background-repeat: repeat-y;
}

.photo-divider--horizontal::before {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='6'><path d='M0,1 L8,5 L16,1' stroke='%236366f1' stroke-width='1.6' fill='none'/></svg>");
    background-repeat: repeat-x;
}

/* Current Aim / Notes: a reusable aside pattern any entry can add below its
   main narrative — set apart with a dashed divider + accent-bordered blocks
   rather than shouty labels. */
.docs-entry-meta {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.docs-entry-meta-block {
    padding: 0.1rem 0.75rem 0.1rem 1.25rem;
    border-left: 2px solid var(--accent);
}

.docs-entry-meta-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-light);
    margin-bottom: 0.35rem;
}

.docs-entry-meta-block p {
    color: var(--text-secondary);
    line-height: 1.7;
    font-size: 0.98rem;
}

/* Meta blocks with multiple lines (e.g. a "Media:" block linking out to
   several posts) — a little separation so consecutive links don't run
   together. */
.docs-entry-meta-block p + p {
    margin-top: 0.35rem;
}

/* Source-attribution links (e.g. "Source:" meta blocks pointing back to an
   external project log) — used on this project's entries since its build
   detail is sourced from elsewhere rather than written first-hand here. */
.docs-entry-meta-block a {
    color: var(--accent-light);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.docs-entry-meta-block a:hover {
    color: var(--accent);
}

/* ============================================
   ENTRY MEDIA CAROUSEL
   ============================================ */
/* Reusable for any entry: wrap N "slides" (each can be a single image or a
   .docs-entry-photo-grid group) in .docs-media > .docs-media-viewport >
   .docs-media-track > .docs-media-slide. JS wires up the arrows/dots/swipe
   and clicking any .docs-media-item opens it (and its siblings across the
   whole group) in the shared lightbox. */

.docs-media {
    position: relative;
    margin-top: 1.25rem;
}

.docs-media-viewport {
    overflow: hidden;
    border-radius: 8px;
}

.docs-media-track {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.docs-media-slide {
    flex: 0 0 100%;
    min-width: 0;
    /* The track stretches every slide to match the tallest one (default
       flex align-items: stretch); centering a slide's own content stops a
       shorter slide (e.g. a single wide image) from sitting pinned to the
       top of that taller box instead of lining up with the others. */
    display: flex;
    align-items: center;
    justify-content: center;
}

.docs-media-item {
    cursor: zoom-in;
}

.docs-media-single {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.docs-media-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 46px;
    border-radius: 8px;
    background: rgba(15, 15, 15, 0.75);
    border: 1px solid var(--border-color);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 4;
    opacity: 0.85;
    transition: opacity 0.2s ease, background 0.15s ease, border-color 0.15s ease;
}

/* Purple only while actually being pressed (:active) or, on devices that
   have a real pointer, while hovered — gated behind (hover: hover) so a tap
   on touch/emulated-touch screens doesn't leave it "stuck" purple the way a
   plain :hover rule would (touch UAs latch :hover until the next tap
   elsewhere instead of clearing it on release). */
@media (hover: hover) {
    .docs-media-nav:hover {
        opacity: 1;
        background: var(--accent);
        border-color: var(--accent);
    }
}

.docs-media-nav:active {
    opacity: 1;
    background: var(--accent);
    border-color: var(--accent);
}

.docs-media-nav--prev {
    left: 10px;
}

.docs-media-nav--next {
    right: 10px;
}

.docs-media-nav[hidden],
.docs-media-dots[hidden] {
    display: none;
}

.docs-media-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.85rem;
}

.docs-media-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background 0.2s ease;
}

.docs-media-dot--active {
    background: var(--accent);
}

/* Lightbox styling now lives in the shared root styles.css — the lightbox
   itself is a page-agnostic component (see script.js) usable by any page,
   not just this one. */

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 900px) {
    .docs-container {
        grid-template-columns: 1fr;
    }

    .docs-sidebar {
        position: static;
    }

    .docs-toc-toggle {
        display: flex;
    }

    /* Collapsed by default on narrow layouts — the toggle button reveals
       it instead of the full tree always taking up space above the entries. */
    .docs-tree {
        max-height: 0;
        padding: 0;
        border-width: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .docs-tree.is-open {
        max-height: 600px;
        padding: 0.75rem;
        border-width: 1px;
        overflow-y: auto;
    }
}

@media (max-width: 480px) {
    .docs-hero {
        padding: 120px 1.5rem 2.5rem;
    }

    .docs-title {
        font-size: 2rem;
    }

    /* Kept close to the desktop padding rather than shrinking further —
       tight side padding here was leaving entry text sitting almost flush
       against the card edge on narrow phones. */
    .docs-entry {
        padding: 1.5rem 1.35rem;
    }
}
