/* ==========================================================================
   ultraflip_theme — Grav
   Derived from Ultratheme. Headlines: Unbounded (self-hosted, /fonts)
   Body: GuardianEgyp-Regular (copy the three files from the Ultratheme /fonts folder)
   ========================================================================== */

/* ---------- Fonts ---------- */
@font-face { font-family: "Unbounded"; font-weight: 300; font-style: normal; font-display: swap;
    src: url("../fonts/unbounded-latin-300.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-weight: 400; font-style: normal; font-display: swap;
    src: url("../fonts/unbounded-latin-400.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-weight: 500; font-style: normal; font-display: swap;
    src: url("../fonts/unbounded-latin-500.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-weight: 600; font-style: normal; font-display: swap;
    src: url("../fonts/unbounded-latin-600.woff2") format("woff2"); }

@font-face { font-family: "GuardianEgyp-Regular"; font-weight: normal; font-style: normal; font-display: swap;
    src: url("../fonts/9f267d7e77d5e399f5d28fa7985f8235.woff2") format("woff2"),
         url("../fonts/9f267d7e77d5e399f5d28fa7985f8235.woff")  format("woff"),
         url("../fonts/9f267d7e77d5e399f5d28fa7985f8235.ttf")   format("truetype"); }

/* ---------- Tokens ---------- */
:root {
    --ink:         #111;
    --ink-soft:    #555;
    --ink-mute:    #8a8a8a;
    --line:        rgba(0, 0, 0, 0.09);
    --line-strong: rgba(0, 0, 0, 0.24);
    --bg:          #fff;          /* whole site is white; change here for a tinted page */
    --tile-bg:     #f5f5f5;       /* empty thumbnail area */
    --accent:      #FD0042;       /* hover */
    --link:        #E5007E;       /* links in running text */

    --radius:      22px;          /* reading card */
    --radius-s:    14px;          /* thumbnails */
    --btn:         40px;          /* icon buttons / search height */
    --pad:         clamp(16px, 3vw, 40px);
    --grid-max:    1760px;
    --read:        900px;         /* width of the reading card */
    --measure:     38rem;         /* text column inside the card */

    --cols:        5;             /* tile columns: 5 large, 3 small, 1 phone (see media queries) */
    --gap-x:       22px;
    --gap-y:       34px;

    --font-head:   "Unbounded", "Helvetica Neue", Arial, sans-serif;
    --font-body:   "GuardianEgyp-Regular", Georgia, "Times New Roman", serif;
}

/* 5 columns >= 1200px, 3 columns 640-1199px, 1 column below 640px */
@media (max-width: 1199px) { :root { --cols: 3; } }
@media (max-width: 639px)  { :root { --cols: 1; } }

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }

body {
    background: var(--bg);
    color: #222;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1 0 auto; }

ol, ul { list-style: none; }
img, video { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }

a { color: var(--link); text-decoration: none; }
a:hover, a:active { color: var(--accent); }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-head);
    font-optical-sizing: auto;
    font-weight: 600;
    line-height: 1.15;
    clear: both;
}
b, strong { font-weight: 600; }

.ico { display: block; width: 18px; height: 18px; flex: none; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -9999px; top: 8px; z-index: 3000;
    background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 10px;
    font-family: var(--font-head); font-size: 0.7rem; border: 1px solid var(--line-strong);
}
.skip-link:focus { left: 8px; }

/* ---------- Hinweis-Banner (klein, schwarz, ganz oben) ---------- */
.site-banner {
    background: #000;
    color: #fff;
    text-align: center;
    font-family: var(--font-head);
    font-weight: 500;
    font-size: 0.62rem;
    line-height: 1.5;
    letter-spacing: 0.03em;
    padding: 7px var(--pad);
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header { background: var(--bg); }
.site-header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: var(--grid-max);
    margin: 0 auto;
    padding: 14px var(--pad);
}

.brand {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.02em;
    color: var(--ink);
    margin-right: auto;
    white-space: nowrap;
}
.brand:hover { color: var(--accent); }

.icon-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: var(--btn);
    height: var(--btn);
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--bg);
    color: #444;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { border-color: var(--ink); color: var(--accent); }
.site-links { display: flex; gap: 8px; }

/* the overview keeps the search reachable while scrolling */
.is-grid .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}

/* ---------- Search ---------- */
.search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 1 420px;
    min-width: 0;
    height: var(--btn);
    padding: 0 8px 0 13px;
    border: 1px solid var(--line-strong);
    border-radius: 13px;
    background: var(--bg);
}
.search:focus-within { border-color: var(--ink); }
.search-icon { color: var(--ink-mute); display: flex; }
.search input {
    flex: 1 1 60px;
    min-width: 60px;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    -webkit-appearance: none;
    appearance: none;
}
.search input:focus-visible { outline: 0; }
.search input::-webkit-search-cancel-button { display: none; }
.search input::placeholder { color: var(--ink-mute); }
.search-clear {
    display: grid; place-items: center; flex: none;
    width: 26px; height: 26px; border: 0; border-radius: 8px;
    background: transparent; color: var(--ink-mute); cursor: pointer;
}
.search-clear:hover { color: var(--ink); }
.search-clear[hidden] { display: none; }

.chips { display: contents; }
.chip {
    flex: none;
    display: inline-flex; align-items: center; gap: 5px;
    max-width: 11rem;
    padding: 2px 8px 2px 10px;
    border: 1px solid var(--ink);
    border-radius: 999px;
    background: var(--bg);
    font-size: 0.78rem;
    line-height: 1.4;
    cursor: pointer;
    white-space: nowrap;
}
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip .ico { width: 12px; height: 12px; }
.chip:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 720px) {
    .site-header-inner { flex-wrap: wrap; }
    .search { order: 3; flex: 1 1 100%; }
}

/* ==========================================================================
   Overview
   ========================================================================== */
.wrap { max-width: var(--grid-max); margin: 0 auto; padding: 0 var(--pad); }

.filters {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    gap: 16px;
    padding: 16px 0 4px;
    font-size: 0.82rem;
    color: var(--ink-mute);
}
.count { padding-top: 1px; white-space: nowrap; }

.tags-all summary {
    display: inline-block;
    cursor: pointer;
    list-style: none;
    color: var(--ink-soft);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}
.tags-all summary::-webkit-details-marker { display: none; }
.tags-all[open] summary { text-decoration-style: solid; color: var(--ink); }
.tags-n { color: var(--ink-mute); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 0 6px; }
.tag-list button, .tile-tags button {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--bg);
    color: var(--ink-soft);
    font-size: 0.78rem;
    line-height: 1.5;
    padding: 1px 10px;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}
.tag-list button:hover, .tile-tags button:hover { border-color: var(--ink); color: var(--ink); }
.tag-list .n { color: var(--ink-mute); margin-left: 2px; }
button[data-tag][aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: #f3f3f3; }

.grid {
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: var(--gap-y) var(--gap-x);
    padding: 18px 0 72px;
}
.grid[hidden], .tile[hidden] { display: none; }

.tile article {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
}
.tile-media {
    aspect-ratio: var(--tile-ratio, 4 / 3);
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: var(--tile-bg);
    overflow: hidden;
    transition: border-color 0.15s ease;
}
.tile-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile:hover .tile-media { border-color: var(--line-strong); }

.tile-title {
    font-size: 0.72rem;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0.01em;
    overflow-wrap: anywhere;
}
.tile-title a { color: var(--ink); }
.tile-title a:hover { color: var(--accent); }
/* the whole tile is the link */
.tile-title a::after { content: ""; position: absolute; inset: 0; }
.tile-title a:focus-visible { outline: 0; }
.tile-title a:focus-visible::after { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: var(--radius-s); }

.tile-edited { margin: -2px 0 0; font-size: 0.72rem; line-height: 1.3; color: var(--ink-mute); }

.tile-text {
    font-size: 0.88rem;
    line-height: 1.42;
    color: var(--ink-soft);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tile-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: auto; padding-top: 2px; }
.tile-tags button { position: relative; z-index: 2; font-size: 0.74rem; padding: 0 9px; }

.empty {
    max-width: 30rem;
    padding: 64px 0 96px;
    color: var(--ink-soft);
}
.empty[hidden] { display: none; }
.empty button {
    margin-top: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: var(--bg);
    padding: 5px 16px;
    cursor: pointer;
}
.empty button:hover { border-color: var(--ink); color: var(--accent); }

/* ==========================================================================
   Reading view
   ========================================================================== */
.entry {
    max-width: var(--read);
    margin: 28px auto 72px;
    padding: clamp(22px, 4.5vw, 52px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
@media (max-width: 960px) { .entry { margin-left: var(--pad); margin-right: var(--pad); } }
@media (max-width: 640px) {
    .entry { margin: 8px 0 48px; border: 0; border-radius: 0; padding: 12px var(--pad) 0; }
}

.entry-head { margin-bottom: 2rem; }
.entry-head h1 { font-size: clamp(1.3rem, 3.2vw, 1.9rem); font-weight: 600; overflow-wrap: anywhere; }
.entry-abstract { max-width: var(--measure); margin-top: 0.9rem; font-size: 1.08rem; line-height: 1.5; color: var(--ink-soft); }

.entry-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin-top: 1.1rem; font-size: 0.85rem; color: var(--ink-mute); }
.entry-meta a { color: var(--ink-soft); }
.entry-meta a:hover { color: var(--accent); }
.repo { display: inline-flex; align-items: center; gap: 7px; }
.repo .ico { width: 16px; height: 16px; }

.entry-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 1rem; }
.entry-tags a {
    display: inline-block;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 1px 11px;
    font-size: 0.8rem;
    color: var(--ink-soft);
    transition: border-color 0.15s ease, color 0.15s ease;
}
.entry-tags a:hover { border-color: var(--ink); color: var(--ink); }

.entry-body { font-size: 1.0625rem; line-height: 1.65; }
.entry-body > * { margin-top: 1.1em; }
.entry-body > :first-child { margin-top: 0; }
.entry-body > :not(figure):not(.gallery):not(.vid):not(pre):not(table):not(details.prompt) { max-width: var(--measure); }

.entry-body h2 { font-size: 1.05rem; font-weight: 500; margin-top: 2.2em; }
.entry-body h3 { font-size: 0.9rem; font-weight: 500; margin-top: 1.9em; }
.entry-body h4, .entry-body h5, .entry-body h6 { font-size: 0.8rem; font-weight: 500; margin-top: 1.6em; }
.entry-body ul, .entry-body ol { padding-left: 1.3em; }
.entry-body ul { list-style: disc; }
.entry-body ol { list-style: decimal; }
.entry-body li + li { margin-top: 0.3em; }
.entry-body blockquote { padding-left: 1em; border-left: 2px solid var(--line-strong); color: var(--ink-soft); }
.entry-body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; max-width: var(--measure); }
.entry-body small { font-size: 0.78em; color: var(--ink-mute); }
.entry-body code {
    font: 0.86em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: #f4f4f4; padding: 1px 5px; border-radius: 5px;
}
.entry-body pre {
    background: #f7f7f7; border: 1px solid var(--line); border-radius: 12px;
    padding: 14px 16px; overflow: auto; font-size: 0.82rem; line-height: 1.5;
}
.entry-body pre code { background: none; padding: 0; font-size: inherit; }
.entry-body table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 0.92rem; }
.entry-body th, .entry-body td { border-bottom: 1px solid var(--line); padding: 6px 14px 6px 0; text-align: left; vertical-align: top; }
.entry-body th { font-family: var(--font-head); font-weight: 500; font-size: 0.72rem; }

/* images: markdown title = caption under the image, alt = lightbox only */
.entry-body img { display: block; border: 1px solid var(--line); border-radius: 10px; }
.entry-body figure { margin: 1.6em 0; }
.entry-body figure img { cursor: zoom-in; }
.entry-body figcaption { margin-top: 6px; font-size: 0.78rem; font-style: italic; line-height: 1.4; color: var(--ink-mute); }

.gallery { display: grid; grid-template-columns: repeat(var(--per, 4), minmax(0, 1fr)); gap: 10px; margin: 1.6em 0; }
.gallery[data-count="2"] { --per: 2; }
.gallery[data-count="3"] { --per: 3; }
.gallery[data-count="4"] { --per: 4; }
.gallery[data-count="5"] { --per: 5; }
.gallery[data-count="6"] { --per: 3; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; }
@media (max-width: 640px) { .gallery[data-count] { --per: 2; } }

.vid { margin: 1.6em 0; }
.vid video { display: block; width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #f5f5f5; }

.entry-files { margin-top: 2.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.entry-files h2 { font-size: 0.75rem; font-weight: 500; color: var(--ink-soft); }
.entry-files ul { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 0.9rem; }
.entry-files a {
    display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--line); border-radius: 10px;
    padding: 5px 12px; font-size: 0.85rem; color: var(--ink-soft);
}
.entry-files a:hover { border-color: var(--ink); color: var(--accent); }
.entry-files .ico { width: 16px; height: 16px; }

.entry-error .entry-head { margin-bottom: 1.2rem; }

/* ==========================================================================
   Prompt box ([p]…[/p]) — a right-aligned pill; opens as overlay with JS
   ========================================================================== */
details.prompt { max-width: none; text-align: right; }
details.prompt > summary {
    display: inline-block;
    list-style: none;
    cursor: pointer;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    padding: 3px 14px;
    font-family: var(--font-head);
    font-size: 0.6rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--ink-soft);
    background: var(--bg);
}
details.prompt > summary::-webkit-details-marker { display: none; }
details.prompt > summary:hover { border-color: var(--ink); color: var(--ink); }
details.prompt[open] > :not(summary) { text-align: left; font-size: 0.85rem; line-height: 1.5; color: var(--ink-soft); }

/* overlays (lightbox + prompt) */
.overlay {
    position: fixed; inset: 0; z-index: 2000;
    display: grid; place-items: center;
    padding: 24px;
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}
.overlay[hidden] { display: none; }
html.overlay-open { overflow: hidden; }

.overlay-close, .lb-nav {
    position: absolute;
    display: grid; place-items: center;
    width: var(--btn); height: var(--btn);
    border: 1px solid var(--line-strong); border-radius: 13px;
    background: var(--bg); color: #333; cursor: pointer;
}
.overlay-close:hover, .lb-nav:hover { border-color: var(--ink); color: var(--accent); }
.overlay-close { top: 16px; right: 16px; }
.lb-nav[hidden] { display: none; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }

.lb-figure { display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: min(94vw, 1400px); }
.lb-figure img { max-width: 100%; max-height: 82vh; width: auto; height: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.lb-caption { max-width: 46rem; text-align: center; font-size: 0.85rem; line-height: 1.4; color: var(--ink-soft); }
.lb-caption strong { display: block; font-family: var(--font-head); font-weight: 500; font-size: 0.7rem; color: var(--ink); margin-bottom: 3px; }
.lb-caption:empty { display: none; }

.prompt-box {
    width: min(640px, 100%);
    max-height: 82vh;
    display: flex; flex-direction: column;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.35);
    padding: 22px 24px 20px;
}
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.prompt-title { font-family: var(--font-head); font-weight: 500; font-size: 0.7rem; color: var(--ink); }
.prompt-body { overflow: auto; font-size: 0.85rem; line-height: 1.55; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; padding-right: 6px; }
.prompt-body p + p { margin-top: 0.8em; }
.prompt-actions { display: flex; justify-content: flex-end; margin-top: 16px; }
.prompt-copy {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line-strong); border-radius: 999px; background: #fff;
    padding: 5px 14px; font-family: var(--font-head); font-size: 0.6rem; font-weight: 500; letter-spacing: 0.06em; color: var(--ink-soft);
    cursor: pointer;
}
.prompt-copy .ico { width: 14px; height: 14px; }
.prompt-copy:hover { border-color: var(--ink); color: var(--ink); }
.prompt-copy.copied { color: var(--accent); border-color: var(--accent); }
.prompt-box .overlay-close { position: static; width: 32px; height: 32px; border-radius: 10px; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { flex: none; border-top: 1px solid var(--line); }
.site-footer-inner {
    display: flex; justify-content: space-between; gap: 16px;
    max-width: var(--grid-max); margin: 0 auto;
    padding: 18px var(--pad) 26px;
    font-size: 0.78rem; color: var(--ink-mute);
}
.edit-link { color: var(--ink-mute); text-decoration: underline dotted; text-underline-offset: 3px; }
.edit-link:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
