/* nightmare.css
   Shared stylesheet for the static Nightmare.org sites.
   Place at: https://www.nightmare.org/assets/css/nightmare.css
*/

:root {
    color-scheme: dark;

    --bg: #050505;
    --bg-soft: #0d0d0d;
    --panel: #121212;
    --panel-strong: #181818;

    --text: #d8d8d8;
    --text-muted: #9b9b9b;
    --heading: #f0df9b;

    --link: #d6b85f;
    --link-hover: #fff0a6;
    --accent: #9b1c1c;
    --accent-hover: #c42b2b;

    --border: #3a3020;
    --border-soft: #242424;

    --shadow: 0 10px 30px rgb(0 0 0 / 45%);
    --radius: 10px;

    --content-width: 1200px;
    --reading-width: 820px;

    --font-body: Verdana, Geneva, Tahoma, Arial, sans-serif;
    --font-display: Georgia, "Times New Roman", serif;
    --font-mono: "Courier New", Courier, monospace;
}

/* ---------- Reset ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgb(75 35 15 / 12%), transparent 34rem),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    overflow-wrap: anywhere;
}

.no-results {
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.page-shell {
    width: min(calc(100% - 2rem), var(--content-width));
    margin: 0 auto 3rem;
}

.page-title {
    margin: .25rem 0 1rem;
    color: var(--heading);
    text-align: center;
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2.35rem);
}

img,
svg,
video,
iframe {
    display: block;
    max-width: 100%;
}

img {
    height: auto;
}

button,
input,
select,
textarea {
    font: inherit;
}

a {
    color: var(--link);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

a:hover,
a:focus-visible {
    color: var(--link-hover);
}

hr {
    border: 0;
    border-top: 1px solid var(--border-soft);
    margin: 2rem 0;
}

/* ---------- Accessibility ---------- */

:focus-visible {
    outline: 3px solid var(--link-hover);
    outline-offset: 3px;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: 1rem;
    z-index: 1000;
    padding: 0.75rem 1rem;
    background: var(--heading);
    color: #000;
    font-weight: 700;
    border-radius: 0 0 6px 6px;
}

.skip-link:focus {
    top: 0;
}

/* ---------- Main layout ---------- */

.site-shell,
.container {
    width: min(calc(100% - 2rem), var(--content-width));
    margin-inline: auto;
}

.reading-width {
    width: min(100%, var(--reading-width));
    margin-inline: auto;
}

main {
    padding-block: 1rem 3rem;
}

section {
    margin-block: 2rem;
}

/* ---------- Header image ---------- */

.site-header {
    width: min(calc(100% - 2rem), var(--content-width));
    margin-inline: auto;
    padding: 1rem 0 0.5rem;
    text-align: center;
}

.site-header a {
    display: inline-block;
}

.site-header img,
.site-logo,
.header-image {
    width: auto;
    max-width: 100%;
    max-height: 300px;
    margin-inline: auto;
    object-fit: contain;
}

/* ---------- Navigation ---------- */

.site-nav {
    width: min(calc(100% - 2rem), var(--content-width));
    margin: 0.75rem auto 1.5rem;
    padding: 0.65rem;
    background: rgb(14 14 14 / 92%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.site-nav ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav a {
    display: block;
    padding: 0.55rem 0.8rem;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 6px;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current="page"] {
    color: var(--heading);
    background: var(--panel-strong);
    border-color: var(--border);
}

/* ---------- Headings and text ---------- */

h1,
h2,
h3,
h4 {
    color: var(--heading);
    font-family: var(--font-display);
    line-height: 1.2;
    text-wrap: balance;
}

h1 {
    margin: 0.6rem 0 1.2rem;
    font-size: clamp(2rem, 6vw, 4rem);
    text-align: center;
}

h2 {
    margin-top: 2.5rem;
    font-size: clamp(1.5rem, 4vw, 2.35rem);
}

h3 {
    font-size: clamp(1.2rem, 3vw, 1.65rem);
}

p,
li {
    max-width: 80ch;
}

.lead {
    max-width: 70ch;
    margin-inline: auto;
    color: var(--text-muted);
    font-size: 1.08rem;
    text-align: center;
}

.muted,
.small,
small {
    color: var(--text-muted);
}

.center {
    text-align: center;
}

/* ---------- Panels ---------- */

.panel,
.content-box,
.random-card-box,
.search-panel {
    padding: clamp(1rem, 3vw, 1.5rem);
    background:
        linear-gradient(180deg, rgb(255 255 255 / 2%), transparent),
        var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.random-card-box {
    width: min(100%, 760px);
    margin: 1rem auto 2rem;
    text-align: center;
}

.random-card-box h2 {
    margin-top: 0;
}

.random-card-box p {
    margin-inline: auto;
}

/* ---------- Buttons ---------- */

.button,
button,
input[type="submit"],
input[type="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0.7rem 1rem;
    color: #f7e7b1;
    background: linear-gradient(#2b1d0f, #120b05);
    border: 1px solid var(--link);
    border-radius: 7px;
    box-shadow: 0 4px 12px rgb(0 0 0 / 35%);
    cursor: pointer;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
}

.button:hover,
.button:focus-visible,
button:hover,
button:focus-visible,
input[type="submit"]:hover,
input[type="submit"]:focus-visible,
input[type="button"]:hover,
input[type="button"]:focus-visible {
    color: #fff7d7;
    background: linear-gradient(#452516, #1b0d08);
    border-color: var(--link-hover);
}

.button-danger {
    color: #fff;
    background: linear-gradient(var(--accent-hover), #5c0d0d);
    border-color: #d45a5a;
}

/* ---------- Forms and search ---------- */

.search-row,
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

input[type="search"],
input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 0.7rem 0.85rem;
    color: var(--text);
    background: #090909;
    border: 1px solid #4a4a4a;
    border-radius: 6px;
}

input::placeholder,
textarea::placeholder {
    color: #777;
}

.search-row input[type="search"] {
    flex: 1 1 260px;
}

/* ---------- Sticky controls ---------- */

.controls {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: center;
    padding: .8rem;
    margin-bottom: 1rem;
    background: rgba(7, 7, 7, .94);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.controls input {
    width: min(32rem, 100%);
    padding: .7rem .85rem;
    border: 1px solid #4a4a4a;
    border-radius: .4rem;
    background: #151515;
    color: var(--heading);
    font: inherit;
}

.controls button {
    padding: .7rem .9rem;
    border: 1px solid #4a4a4a;
    border-radius: .4rem;
    background: #1d1d1d;
    color: var(--heading);
    cursor: pointer;
    font: inherit;
}

.controls button:hover {
    background: #292929;
}

.result-count {
    color: var(--text-muted);
    font-size: .88rem;
}

/* ---------- Card and issue grids ---------- */

.card-grid,
.issue-grid,
.archive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.card,
.issue,
.archive-item {
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgb(0 0 0 / 28%);
}

.card a,
.issue a,
.archive-item a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.card img,
.issue img,
.archive-item img {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: #000;
}

.card-body,
.issue-body,
.archive-item-body {
    padding: 0.85rem;
}

.card-title,
.issue-title,
.archive-item-title {
    margin: 0;
    color: var(--heading);
    font-weight: 700;
    line-height: 1.35;
}

.card:hover,
.card:focus-within,
.issue:hover,
.issue:focus-within,
.archive-item:hover,
.archive-item:focus-within {
    border-color: var(--link);
    transform: translateY(-2px);
}

/* ---------- Tarot-specific ---------- */

.tarot-card-page {
    width: min(100%, 900px);
    margin-inline: auto;
}

.tarot-card-image {
    width: min(100%, 420px);
    margin: 1rem auto;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.tarot-description {
    padding: clamp(1rem, 3vw, 1.75rem);
    background: var(--panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}

.card-navigation {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.65rem;
    margin: 1.5rem 0;
}

/* ---------- Tables ---------- */

.table-wrap {
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
}

th,
td {
    padding: 0.7rem 0.85rem;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--heading);
    background: var(--panel-strong);
}

tr:last-child td {
    border-bottom: 0;
}

/* ---------- Preformatted and textfile content ---------- */

pre,
code,
kbd,
samp {
    font-family: var(--font-mono);
}

code {
    color: #e8d595;
}

pre {
    max-width: 100%;
    margin: 1.5rem 0;
    padding: 1rem;
    overflow: auto;
    color: #bdbdbd;
    background: #000;
    border: 1px solid var(--border-soft);
    border-radius: 6px;
    line-height: 1.25;
    tab-size: 4;
    white-space: pre;
}

.binary-art,
.ascii-art {
    overflow-x: auto;
    font-size: clamp(0.55rem, 1.25vw, 0.9rem);
    line-height: 1;
    white-space: pre;
}

/* ---------- Lists ---------- */

.link-list {
    margin: 1rem 0;
    padding: 0;
    list-style: none;
}

.link-list li {
    padding: 0.45rem 0;
    border-bottom: 1px dotted var(--border-soft);
}

.link-list li:last-child {
    border-bottom: 0;
}

/* ---------- Footer ---------- */

.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 1rem 2rem;
    color: var(--text-muted);
    background: #030303;
    border-top: 1px solid var(--border-soft);
    text-align: center;
}

.site-footer p {
    margin-inline: auto;
}

/* ---------- Utility classes ---------- */

.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.full-width {
    width: 100%;
}

.no-margin {
    margin: 0;
}

/* ---------- Responsive adjustments ---------- */

@media (max-width: 700px) {
    body {
        font-size: 0.96rem;
    }

    .site-shell,
    .container,
    .site-header,
    .site-nav {
        width: min(calc(100% - 1rem), var(--content-width));
    }

    .site-nav ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .site-nav a {
        text-align: center;
    }

    .card-grid,
    .issue-grid,
    .archive-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.7rem;
    }

    .card-body,
    .issue-body,
    .archive-item-body {
        padding: 0.65rem;
    }

    .button,
    button,
    input[type="submit"],
    input[type="button"] {
        width: 100%;
    }

    .card-navigation .button {
        width: auto;
        flex: 1 1 140px;
    }
}

@media (max-width: 430px) {
    .site-nav ul,
    .card-grid,
    .issue-grid,
    .archive-grid {
        grid-template-columns: 1fr;
    }
}

/* ---------- Printing ---------- */

@media print {
    :root {
        color-scheme: light;
    }

    body {
        background: #fff;
        color: #000;
    }

    .site-nav,
    .site-footer,
    .button,
    button,
    .search-panel,
    .random-card-box {
        display: none !important;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    .panel,
    .card,
    .issue,
    .archive-item,
    .tarot-description {
        box-shadow: none;
        border-color: #999;
    }
}

/* ---------- Reduced motion ---------- */

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

    .card:hover,
    .issue:hover,
    .archive-item:hover {
        transform: none;
    }
}
