/* ==========================================================================
   Harkonnen Mentat: theme and layout
   Light "Desert Parchment" and dark "Arrakis Night", switched with [data-theme].
   ========================================================================== */

@font-face {
    font-family: "Cinzel";
    src: url("../fonts/cinzel.woff2") format("woff2");
    font-weight: 400 900;
    font-display: swap;
}

@font-face {
    font-family: "Cormorant Garamond";
    src: url("../fonts/cormorant-garamond-italic.woff2") format("woff2");
    font-style: italic;
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Inter";
    src: url("../fonts/inter.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
    --font-quote: "Cormorant Garamond", Georgia, serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

    /* Desert Parchment (light) */
    --bg: #efe2c4;
    --bg-grain-opacity: 0.35;
    --surface: #f7edd6;
    --surface-2: #ead8b1;
    --surface-sunken: #e3cfa3;
    --text: #2b1d10;
    --text-muted: #6b5236;
    --rule: #b8945c;
    --rule-soft: rgba(139, 98, 44, 0.25);
    --accent: #c2611f;
    --accent-strong: #a24d12;
    --accent-contrast: #fff8ec;
    --harkonnen: #8b1e1e;
    --harkonnen-soft: rgba(139, 30, 30, 0.12);
    --atreides: #2e5b3c;
    --atreides-soft: rgba(46, 91, 60, 0.12);
    --highlight: #2f5fa8;
    --disabled: rgba(43, 29, 16, 0.35);
    --shadow: 0 1px 2px rgba(60, 35, 5, 0.18), 0 6px 18px rgba(60, 35, 5, 0.12);
    --dune-ridge: #d9bf8a;

    --radius: 10px;
    --radius-lg: 16px;
    --gap: 16px;
    --tap: 56px;

    color-scheme: light;
}

:root[data-theme="dark"] {
    /* Arrakis Night (dark) */
    --bg: #12141f;
    --bg-grain-opacity: 0.12;
    --surface: #1c2030;
    --surface-2: #252a3d;
    --surface-sunken: #161926;
    --text: #e9dcc0;
    --text-muted: #a99b80;
    --rule: #6d5a3c;
    --rule-soft: rgba(233, 220, 192, 0.14);
    --accent: #e8833a;
    --accent-strong: #f39a55;
    --accent-contrast: #1a1006;
    --harkonnen: #c23b3b;
    --harkonnen-soft: rgba(194, 59, 59, 0.18);
    --atreides: #5e9e6e;
    --atreides-soft: rgba(94, 158, 110, 0.18);
    --highlight: #5b8cff;
    --disabled: rgba(233, 220, 192, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
    --dune-ridge: #1f2335;

    color-scheme: dark;
}

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

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Faint sand grain over the whole page. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: var(--bg-grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.32 0 0 0 0 0.15 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    z-index: 0;
}

/* Dune ridge silhouette along the bottom edge. */
body::after {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 90px;
    pointer-events: none;
    background: var(--dune-ridge);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 90' preserveAspectRatio='none'%3E%3Cpath d='M0 70 C150 30 260 40 380 62 S620 20 760 48 S1010 75 1200 38 L1200 90 L0 90 Z'/%3E%3C/svg%3E") bottom / 100% 100% no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 90' preserveAspectRatio='none'%3E%3Cpath d='M0 70 C150 30 260 40 380 62 S620 20 760 48 S1010 75 1200 38 L1200 90 L0 90 Z'/%3E%3C/svg%3E") bottom / 100% 100% no-repeat;
    opacity: 0.6;
    z-index: 0;
}

#app {
    position: relative;
    z-index: 1;
    min-height: 100dvh;
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.04em;
    margin: 0;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.3rem;
}

h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

p {
    margin: 0;
}

a {
    color: var(--accent-strong);
}

button {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--highlight);
    outline-offset: 2px;
}

/* Blazor moves focus to the page heading after navigation; it should not look selected. */
h1:focus,
h2:focus {
    outline: none;
}

.quote {
    font-family: var(--font-quote);
    font-style: italic;
    font-size: 1.15rem;
    color: var(--text-muted);
}

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

/* ---------- Ornamental frames (double rule with a diamond) ---------- */

.frame {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow), inset 0 0 0 4px var(--surface), inset 0 0 0 5px var(--rule-soft);
    padding: 20px 22px;
}

.ornament {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--rule);
}

.ornament::before,
.ornament::after {
    content: "";
    flex: 1;
    height: 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule-soft);
    padding-top: 2px;
}

.ornament > span {
    font-size: 0.8rem;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: var(--tap);
    padding: 0 22px;
    border-radius: var(--radius);
    border: 1px solid var(--rule);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.06em;
    cursor: pointer;
    text-decoration: none;
    user-select: none;
    touch-action: manipulation;
    transition: transform 80ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.99);
}

.btn:disabled {
    cursor: not-allowed;
    color: var(--disabled);
    border-color: var(--rule-soft);
    background: transparent;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent-strong);
    color: var(--accent-contrast);
    box-shadow: var(--shadow);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-strong);
}

.btn-big {
    width: 100%;
    min-height: 72px;
    font-size: 1.2rem;
    border-radius: var(--radius-lg);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    font-family: var(--font-body);
    font-weight: 600;
    letter-spacing: 0;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--rule-soft);
}

.btn-small {
    min-height: 44px;
    padding: 0 14px;
    font-size: 0.85rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--rule-soft);
    background: transparent;
    cursor: pointer;
    color: var(--text);
}

.icon-btn:hover {
    background: var(--rule-soft);
}

.icon-btn svg {
    width: 24px;
    height: 24px;
}

/* ---------- App shell ---------- */

.shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.shell-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--rule-soft);
    background: color-mix(in srgb, var(--surface) 75%, transparent);
    backdrop-filter: blur(6px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.shell-title {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-decoration: none;
    color: var(--text);
    font-size: 1rem;
    white-space: nowrap;
}

.shell-title .diamond {
    color: var(--accent);
    margin-right: 6px;
}

.shell-header .spacer {
    flex: 1;
}

.shell-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ---------- Home / centred pages ---------- */

.page-centered {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 20px 110px;
}

.hero {
    width: min(720px, 100%);
    display: flex;
    flex-direction: column;
    gap: 22px;
    text-align: center;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3.2rem);
    letter-spacing: 0.18em;
}

.hero .subtitle {
    font-family: var(--font-display);
    letter-spacing: 0.08em;
    color: var(--harkonnen);
    font-size: 1.05rem;
    margin-top: -8px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ---------- Blazor loading and error UI ---------- */

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 30vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--rule-soft);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-family: var(--font-display);
    inset: calc(30vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    background: var(--harkonnen);
    color: #fff;
    bottom: 0;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.3);
    display: none;
    left: 0;
    padding: 0.8rem 1.25rem 0.8rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #fff;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.6rem;
}
