:root {
    /* Colors */
    --color-bg: #ffffff;
    --color-fg: #000000;

    /* Typography */
    --font-family: 'Readex Pro', sans-serif;

    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 3rem;

    /* Transitions */
    --transition-fast: 0.15s;

    /* UI */
    --control-height: 2.75rem;
}

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

html, body {
    height: 100%;
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-fg);
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-lg);
}

/* `display: contents` flattens #app's children into body's flex layout, so the
   `.hint` (rendered inside #app by Blazor) can sit above #puzzle-mount via `order`. */
#app {
    display: contents;
}

/* ---- Logo / puzzle ---- */

.logo-wrapper {
    width: min(280px, 65vw);
}

.logo-wrapper.hidden {
    display: none;
}

.logo-svg {
    width: 100%;
    height: auto;
}

.logo-letter {
    font-family: var(--font-family);
    font-size: 22.5px;
    font-weight: 500;
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: central;
}

.logo-label {
    font-family: var(--font-family);
    font-size: 11px;
    font-weight: 400;
    fill: var(--color-fg);
}

.puzzle-cell.clickable,
.puzzle-letter.clickable {
    cursor: pointer;
}

.puzzle-letter {
    user-select: none;
    transition: opacity var(--transition-fast), fill var(--transition-fast);
    transform-box: fill-box;
    transform-origin: center;
}

.puzzle-letter.inverted {
    fill: var(--color-fg);
}

/* Letter animation once the puzzle is solved */

.puzzle-svg.solved .puzzle-cell.clickable,
.puzzle-svg.solved .puzzle-letter.clickable {
    cursor: default;
}

.puzzle-svg.solved .puzzle-letter {
    animation: solved-pulse 0.5s ease-out both;
}

.puzzle-svg.solved .puzzle-letter[data-cell="0"] { animation-delay: 0.00s; }
.puzzle-svg.solved .puzzle-letter[data-cell="1"] { animation-delay: 0.06s; }
.puzzle-svg.solved .puzzle-letter[data-cell="2"] { animation-delay: 0.12s; }
.puzzle-svg.solved .puzzle-letter[data-cell="3"] { animation-delay: 0.18s; }
.puzzle-svg.solved .puzzle-letter[data-cell="4"] { animation-delay: 0.24s; }
.puzzle-svg.solved .puzzle-letter[data-cell="5"] { animation-delay: 0.30s; }
.puzzle-svg.solved .puzzle-letter[data-cell="6"] { animation-delay: 0.36s; }
.puzzle-svg.solved .puzzle-letter[data-cell="7"] { animation-delay: 0.42s; }
.puzzle-svg.solved .puzzle-letter[data-cell="8"] { animation-delay: 0.48s; }

@keyframes solved-pulse {
    0%   { transform: scale(1);    }
    50%  { transform: scale(1.25); }
    100% { transform: scale(1);    }
}

/* ---- Loading indicator ---- */

.loading-dots {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    height: var(--control-height);
}

.loading-dots span {
    display: block;
    width: 6px;
    height: 6px;
    background: var(--color-fg);
    animation: dot-pulse 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
    0%, 80%, 100% { opacity: 0.15; transform: scale(0.8); }
    40%            { opacity: 1;    transform: scale(1); }
}

/* ---- Landing controls ---- */

.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

/* Idle hint: two coupled animations on one cell:
   - The letter does a tactile "bouncy press" (compresses, rebounds, settles)
   - A square outline ripples outward from the cell at the same time
   Together they signal "interact with me" without any text. */

.puzzle-letter.demo {
    animation: cell-press 0.5s ease-in-out;
}

@keyframes cell-press {
    0%, 100% { transform: scale(1);    }
    50%      { transform: scale(0.85); }
}

.cell-ripple {
    fill: none;
    stroke: #fff;
    stroke-width: 1;
    transform-box: fill-box;
    transform-origin: center;
    animation: cell-ripple 0.8s ease-out forwards;
    pointer-events: none;
}

@keyframes cell-ripple {
    0%   { transform: scale(1);    opacity: 1; }
    100% { transform: scale(2.5);  opacity: 0; }
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--control-height);
    padding: 0 2.5rem;
    background: none;
    border: 1.5px solid var(--color-fg);
    color: var(--color-fg);
    text-decoration: none;
    font-family: var(--font-family);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), opacity 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-fg);
    color: var(--color-bg);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-fg);
    font-family: var(--font-family);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    cursor: pointer;
    padding: var(--space-xs) var(--space-sm);
    text-decoration: underline;
    text-underline-offset: 4px;
    opacity: 0.55;
    transition: opacity var(--transition-fast);
}

.btn-link:hover:not(:disabled) {
    opacity: 1;
}

.btn-link:disabled {
    opacity: 0.2;
    cursor: default;
}

/* ---- Not Found page ---- */

.not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    text-align: center;
}

.not-found-code {
    font-family: var(--font-family);
    font-size: 5rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    line-height: 1;
}

.not-found-text {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: var(--space-md);
}

/* ---- Blazor error ---- */

#blazor-error-ui {
    background: var(--color-fg);
    color: var(--color-bg);
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 0.875rem;
}

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