/* =====================================================
   unixmagic.net — shared styles

   Color tokens are the single source of truth for the
   palette; edit the values in :root below and every
   alias follows.
   ===================================================== */
:root {
    /* Dark palette */
    --dark-bg:             #15161a;
    --dark-panel:          #1c1d22;
    --dark-fg:             #d4d4d0;
    --dark-fg-muted:       #8a8a86;
    --dark-fg-subtle:      #55565b;
    --dark-accent:         #d46a79;
    --dark-accent-hover:   #e88293;  /* on dark, hover is brighter */
    --dark-accent-tint:    rgba(212, 106, 121, 0.18);
    --dark-border:         #2a2b30;
    --dark-border-strong:  #3a3b42;

    /* Light palette */
    --light-bg:            #f4efe3;
    --light-panel:         #fbf7ec;
    --light-fg:            #2b2a26;
    --light-fg-muted:      #6b6a63;
    --light-fg-subtle:     #9a9890;
    --light-accent:        #bc4f5f;
    --light-accent-hover:  #9b3d4c;  /* on light, hover is darker */
    --light-accent-tint:   #f3d6da;
    --light-border:        #d9d2c3;
    --light-border-strong: #b8ae97;

    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    /* Default binding: dark (also used when the OS has no preference) */
    --bg:             var(--dark-bg);
    --panel:          var(--dark-panel);
    --fg:             var(--dark-fg);
    --fg-muted:       var(--dark-fg-muted);
    --fg-subtle:      var(--dark-fg-subtle);
    --accent:         var(--dark-accent);
    --accent-hover:   var(--dark-accent-hover);
    --accent-tint:    var(--dark-accent-tint);
    --border:         var(--dark-border);
    --border-strong:  var(--dark-border-strong);
}

/* Auto mode: follow the OS when it prefers light */
@media (prefers-color-scheme: light) {
    :root {
        --bg:             var(--light-bg);
        --panel:          var(--light-panel);
        --fg:             var(--light-fg);
        --fg-muted:       var(--light-fg-muted);
        --fg-subtle:      var(--light-fg-subtle);
        --accent:         var(--light-accent);
        --accent-hover:   var(--light-accent-hover);
        --accent-tint:    var(--light-accent-tint);
        --border:         var(--light-border);
        --border-strong:  var(--light-border-strong);
    }
}

/* Explicit user override via [data-theme] wins over :root + @media */
html[data-theme="dark"] {
    --bg:             var(--dark-bg);
    --panel:          var(--dark-panel);
    --fg:             var(--dark-fg);
    --fg-muted:       var(--dark-fg-muted);
    --fg-subtle:      var(--dark-fg-subtle);
    --accent:         var(--dark-accent);
    --accent-hover:   var(--dark-accent-hover);
    --accent-tint:    var(--dark-accent-tint);
    --border:         var(--dark-border);
    --border-strong:  var(--dark-border-strong);
}
html[data-theme="light"] {
    --bg:             var(--light-bg);
    --panel:          var(--light-panel);
    --fg:             var(--light-fg);
    --fg-muted:       var(--light-fg-muted);
    --fg-subtle:      var(--light-fg-subtle);
    --accent:         var(--light-accent);
    --accent-hover:   var(--light-accent-hover);
    --accent-tint:    var(--light-accent-tint);
    --border:         var(--light-border);
    --border-strong:  var(--light-border-strong);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.55;
    background-color: var(--bg);
    color: var(--fg);
    scroll-behavior: smooth;
    overflow-x: hidden;
}

::selection {
    background: var(--accent-tint);
    color: var(--fg);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

/* -------- Header: prompt line --------
   Two stacked rows:
     row 1: the shell invocation (drio@unixmagic:~$ ls)
     row 2: the nav + toggles, read as the output of
            that invocation. */
.header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px 16px 10px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.header-prompt {
    display: flex;
    gap: 8px;
    align-items: baseline;
}
.header-prompt .cmd { color: var(--fg); }

.header-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    width: 100%;
    justify-content: flex-start;
}

.prompt {
    color: var(--fg-muted);
    white-space: nowrap;
}

.prompt .user { color: var(--accent); }
.prompt .host { color: var(--fg); }
.prompt .cursor {
    display: inline-block;
    width: 0.55em;
    height: 1em;
    background: var(--fg);
    vertical-align: text-bottom;
    animation: blink 1.1s steps(2, start) infinite;
    margin-left: 2px;
}

@keyframes blink { to { visibility: hidden; } }

.header-link {
    color: var(--fg-muted);
    font-size: 13px;
}

.header-link::before { content: "["; color: var(--fg-subtle); }
.header-link::after  { content: "]"; color: var(--fg-subtle); }

.header-link:hover {
    color: var(--accent);
    text-decoration: none;
}
.header-link:hover::before,
.header-link:hover::after { color: var(--accent); }

.header-toggle {
    background: none;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    padding: 3px 10px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--fg-muted);
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

#theme-toggle { margin-left: auto; }

.header-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.frame-toggle.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* -------- About / poster-info -------- */
.poster-info-container {
    display: flex;
    justify-content: center;
    margin: 0 auto;
    max-width: 820px;
}

.poster-info {
    max-width: 820px;
    font-size: 14px;
    color: var(--fg);
    padding: 22px 18px 8px;
}

.poster-info h2 {
    font-size: 13px;
    font-weight: normal;
    color: var(--fg-muted);
    margin: 0 0 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.poster-info h2::before {
    content: "$ ";
    color: var(--accent);
}

.poster-info p {
    margin: 0 0 14px;
    line-height: 1.65;
}

.poster-info .sig {
    display: flex;
    justify-content: flex-end;
    color: var(--fg-muted);
    font-size: 12px;
    margin-top: 18px;
}

.poster-info .sig pre {
    margin: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 8px 14px;
    font-family: var(--mono);
}

/* Man-page header line for the About section: mirrors the footer's
   three-column pattern so the About block bookends like a real
   man page (header + NAME + body + footer). */
.poster-info-manline {
    margin-bottom: 16px;
}

/* -------- Man-page sub-sections inside About -------- */
.man-section { margin: 14px 0; }
.man-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--fg);
    text-transform: uppercase;
    margin-bottom: 6px;
}
.man-section-body {
    color: var(--fg);
    padding-left: 16px;
}
.man-section-body p { margin: 0 0 10px; }
.man-section-body p:last-child { margin-bottom: 0; }

.man-row {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 12px;
    padding: 1px 0;
    color: var(--fg-muted);
    font-size: 13px;
}
.man-row .k { color: var(--accent); }
.man-row .k a { color: inherit; }
.man-row a { word-break: break-all; }

/* -------- File viewer (images opened from the FILES section) -------- */
.file-viewer { width: min(80vw, 900px); }
.file-viewer .side-content {
    border-left: 2px solid var(--accent);
    padding: 16px 14px 14px;
    overflow: auto;
}
.file-viewer img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0;
}
.file-caption {
    font-size: 12px;
    color: var(--fg-muted);
    margin-bottom: 10px;
    font-family: var(--mono);
}

/* -------- Poster + markers -------- */
.image-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 12px 0;
}

/* Scoped to the poster so we don't cap every image on the page. */
.image-container img {
    max-width: 100%;
    max-height: 100vh;
    display: block;
    margin: auto;
}

.marker {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--mono);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding-top: 1px; /* optical baseline nudge for mono digits */
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: fadeIn 1.2s ease-out forwards;
    transition: transform 0.15s ease, background-color 0.15s;
}

/* Reset button defaults so <button class="marker"> looks like the old div. */
button.marker {
    padding: 0;
    padding-top: 1px;
    border: 1.5px solid rgba(255, 255, 255, 0.9);
    appearance: none;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--mono);
}

.marker:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    to   { opacity: 0.92; transform: translate(-50%, -50%) scale(1); }
}

.marker:hover {
    opacity: 1;
    background: var(--accent-hover);
    transform: translate(-50%, -50%) scale(1.25);
}

.marker.highlight {
    opacity: 1 !important;
    background: var(--accent-hover);
    transform: translate(-50%, -50%) scale(1.6) !important;
    box-shadow: 0 0 0 3px var(--accent-tint), 0 0 0 5px var(--accent);
    z-index: 100;
}

/* -------- Annotations list -------- */
.annotations {
    max-width: 820px;
    margin: 0 auto;
    padding: 10px 12px 30px;
}

.annotations-header {
    font-size: 13px;
    color: var(--fg-muted);
    padding: 6px 0 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
}
.annotations-header::before {
    content: "$ ";
    color: var(--accent);
}

.annotation {
    background-color: var(--panel);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
    padding: 14px 16px;
    margin-bottom: 14px;
}

.annotation-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}

.annotation-number {
    background-color: var(--accent);
    color: #fff;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 600;
    width: 26px;
    height: 26px;
    line-height: 1;
    padding-top: 1px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.annotation-text { display: flex; flex-direction: column; }

.annotation-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--fg);
}

.annotation-description {
    font-size: 13px;
    color: var(--fg-muted);
    margin-top: 2px;
}

.annotation-body {
    font-size: 14px;
    line-height: 1.65;
    color: var(--fg);
}

.annotation-body p { margin: 0 0 10px; }
.annotation-body code {
    background: var(--accent-tint);
    border: 1px solid var(--border-strong);
    color: var(--accent);
    padding: 1px 5px;
    font-size: 13px;
}
.annotation-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px 12px;
    overflow-x: auto;
    font-size: 13px;
}
.annotation-body pre code { background: none; border: none; padding: 0; }
.annotation-body table {
    border-collapse: collapse;
    margin: 8px 0 14px;
    font-size: 13px;
}
.annotation-body th,
.annotation-body td {
    border: 1px solid var(--border);
    padding: 4px 10px;
    text-align: left;
    vertical-align: top;
}
.annotation-body th { color: var(--fg); background: var(--bg); }

.annotation-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}

.share-btn,
.back-to-top {
    background: none;
    border: none;
    font-family: var(--mono);
    color: var(--fg-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    transition: color 0.15s;
    text-decoration: none;
}

.share-btn::before,
.back-to-top::before { content: "["; color: var(--fg-subtle); }
.share-btn::after,
.back-to-top::after  { content: "]"; color: var(--fg-subtle); }

.share-btn:hover,
.back-to-top:hover { color: var(--accent); text-decoration: none; }
.share-btn:hover::before, .share-btn:hover::after,
.back-to-top:hover::before, .back-to-top:hover::after { color: var(--accent); }

/* -------- Side panel --------
   visibility has a zero-duration transition matched to the transform,
   but with a delay on close so the panel stays visible while sliding out. */
.side-container {
    position: fixed;
    top: 0;
    left: 0;
    width: min(70vw, 700px);
    max-height: 90vh;
    background: var(--panel);
    border-right: 1px solid var(--border-strong);
    border-bottom: 1px solid var(--border-strong);
    box-shadow: 2px 2px 0 var(--border);
    padding: 20px 24px 20px 20px;
    transform: translateX(-100%);
    transition: transform 0.25s ease-in-out, visibility 0s linear 0.25s;
    z-index: 1000;
    visibility: hidden;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.side-container.active {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s ease-in-out, visibility 0s linear 0s;
}

.close-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: none;
    font-family: var(--mono);
    font-size: 14px;
    cursor: pointer;
    color: var(--fg-muted);
    transition: color 0.15s;
    z-index: 10;
}
.close-btn::before { content: "[ "; color: var(--fg-subtle); }
.close-btn::after  { content: " ]"; color: var(--fg-subtle); }
.close-btn:hover { color: var(--accent); }
.close-btn:hover::before, .close-btn:hover::after { color: var(--accent); }

.side-content .annotation {
    max-height: 85vh;
    overflow-y: auto;
    padding-top: 16px;
    padding-right: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--fg);
    scrollbar-width: thin;
    border: none;
    border-left: 2px solid var(--accent);
    background-color: transparent;
    margin: 0;
}

.side-content::-webkit-scrollbar { width: 6px; }
.side-content::-webkit-scrollbar-thumb { background: var(--border-strong); }

/* -------- Footer -------- */
.footer {
    text-align: center;
    padding: 22px 16px 30px;
    font-size: 12px;
    color: var(--fg-muted);
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.footer::before {
    content: "-- EOF --";
    display: block;
    color: var(--fg-subtle);
    letter-spacing: 0.2em;
    margin-bottom: 10px;
}

/* Man-page style footer line: UNIX-MAGIC(1)   DATE · SHA   author */
.footer-manline {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    max-width: 900px;
    margin: 0 auto;
    font-size: 11px;
    color: var(--fg-subtle);
    font-variant-numeric: tabular-nums;
}
.footer-manline > * { white-space: nowrap; }
.footer-manline .v-mid { color: var(--fg-muted); }
.footer-manline a {
    color: inherit;
    border-bottom: 1px dotted var(--fg-subtle);
}
.footer-manline a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
    text-decoration: none;
}

.footer a {
    color: var(--accent);
    font-weight: 600;
}

/* -------- Loading screen -------- */
#loading {
    position: fixed;
    opacity: 1;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--fg);
    z-index: 99999;
    gap: 8px;
}

#loading .load-line {
    color: var(--fg-muted);
}
#loading .load-line .prompt-char { color: var(--accent); margin-right: 6px; }
#loading .cursor {
    display: inline-block;
    width: 0.55em;
    height: 1em;
    background: var(--fg);
    vertical-align: text-bottom;
    animation: blink 1.1s steps(2, start) infinite;
    margin-left: 4px;
}

/* -------- Help (man page) -------- */
.help-container {
    position: fixed;
    top: 50px;
    left: 16px;
    background: var(--panel);
    border: 1px solid var(--border-strong);
    box-shadow: 3px 3px 0 var(--border);
    padding: 18px 22px 14px 18px;
    z-index: 1000;
    display: none;
    max-width: 420px;
    font-size: 12.5px;
    line-height: 1.55;
}

.help-container.active { display: block; }

.help-title {
    font-size: 11px;
    letter-spacing: 0.15em;
    color: var(--fg-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    padding-bottom: 6px;
    margin-bottom: 10px;
}

.help-section {
    margin: 10px 0;
}

.help-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--fg);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.help-section-body {
    color: var(--fg);
    padding-left: 12px;
}

.help-section-body .row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 10px;
    padding: 1px 0;
    color: var(--fg-muted);
}
.help-section-body .row .k {
    color: var(--accent);
}

.help-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: none;
    background: none;
    font-family: var(--mono);
    font-size: 12px;
    cursor: pointer;
    color: var(--fg-subtle);
    transition: color 0.15s;
}
.help-close:hover { color: var(--accent); }

/* -------- Frame mode -------- */
.frame-container { display: block; }
.frame-sidebar   { display: none; }

body.frame-mode .frame-container {
    display: grid;
    grid-template-columns: 1fr minmax(auto, 700px) 1fr;
    gap: 12px;
    padding: 6px 15px;
    max-width: 1600px;
    margin: 0 auto;
    align-items: start;
}

body.frame-mode .frame-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-height: 86vh;
    overflow-y: auto;
    padding: 6px 4px;
    scrollbar-width: thin;
    animation: sidebarFadeIn 0.2s ease-out;
    background: var(--panel);
    border: 1px solid var(--border);
}

@keyframes sidebarFadeIn { from { opacity: 0; } to { opacity: 1; } }

body.frame-mode .frame-sidebar-left  { justify-self: end; }
body.frame-mode .frame-sidebar-right { justify-self: start; }

.frame-sidebar::-webkit-scrollbar { width: 4px; }
.frame-sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); }

.frame-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 8px;
    cursor: pointer;
    transition: background-color 0.15s;
    font-size: 13px;
}

.frame-item:hover { background-color: var(--bg); }
.frame-item.highlight {
    background-color: var(--accent-tint);
    color: var(--fg);
}

.frame-item-number {
    color: var(--accent);
    font-size: 12px;
    min-width: 2ch;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.frame-item-number::before { content: "["; color: var(--fg-subtle); }
.frame-item-number::after  { content: "]"; color: var(--fg-subtle); }

.frame-item-title {
    font-size: 13px;
    color: var(--fg);
    text-decoration: none;
    transition: color 0.15s;
}

.frame-item:hover .frame-item-title { color: var(--accent); }

/* Frame mode needs room for poster + two sidebars; below ~1200px
   we drop back to single-column. */
@media (max-width: 1200px) {
    .frame-toggle { display: none; }
    body.frame-mode .frame-container { display: block; }
    body.frame-mode .frame-sidebar   { display: none; }
}

@media (max-width: 600px) {
    .header { padding: 12px 10px 8px; font-size: 12px; }
    .prompt { font-size: 12px; }
    /* At iPhone widths, let the nav center itself and drop the
       push-right so the toggles sit naturally among the links. */
    .header-nav { justify-content: center; }
    #theme-toggle { margin-left: 0; }
    .poster-info { padding: 16px 14px 4px; }
    .annotations { padding: 8px 10px 24px; }
    .side-container { width: 92vw; padding: 18px 18px 18px 16px; }
    /* Stack the man-page footer line centered instead of wrapping
       mid-column, which looked ragged on narrow screens. */
    .footer-manline { flex-direction: column; align-items: center; gap: 4px; }
}

/* =====================================================
   single.html only — per-annotation page
   ===================================================== */
.single-container {
    max-width: 820px;
    margin: 0 auto;
    padding: 22px 18px 40px;
}

.single-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    flex-wrap: wrap;
}

.back-link {
    color: var(--fg-muted);
    font-size: 13px;
}
.back-link::before { content: "["; color: var(--fg-subtle); }
.back-link::after  { content: "]"; color: var(--fg-subtle); }
.back-link:hover { color: var(--accent); text-decoration: none; }
.back-link:hover::before, .back-link:hover::after { color: var(--accent); }

.single-content { padding: 26px 0 10px; }

.title-block {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.marker-number {
    background-color: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    width: 34px;
    height: 34px;
    line-height: 1;
    padding-top: 1px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.single-content h1 {
    color: var(--fg);
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.single-content .description {
    font-size: 13px;
    color: var(--fg-muted);
    margin-top: 2px;
}

.single-body {
    line-height: 1.7;
    color: var(--fg);
    padding: 14px 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 2px solid var(--accent);
}

.single-body p { margin: 0 0 12px; }
.single-body p:last-child { margin-bottom: 0; }

.single-body code {
    background: var(--accent-tint);
    border: 1px solid var(--border-strong);
    color: var(--accent);
    padding: 1px 5px;
    font-size: 13px;
}
.single-body pre {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 10px 12px;
    overflow-x: auto;
    font-size: 13px;
}
.single-body pre code { background: none; border: none; padding: 0; }

.single-footer {
    margin-top: 24px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--fg-subtle);
    letter-spacing: 0.2em;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    .prompt .cursor,
    #loading .cursor { animation: none; }
    .marker { animation: none; opacity: 0.92; }
    .frame-sidebar { animation: none; }
}
