
* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background: #F8F7F3;
    overscroll-behavior: none;
    user-select: none;
}

#world {
    position: fixed;
    inset: 0;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
}

#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 19px;
    padding: 24px;
    color: #292929;
    background: rgba(248, 247, 243, .97);
    font-family: Arial, sans-serif;
    text-align: center;
    transition: opacity .35s ease, visibility .35s ease;
}

#loading-screen[hidden] {
    display: none;
}

.loading-inks {
    position: relative;
    width: 54px;
    height: 28px;
    animation: riso-ink-turn 1.25s steps(12, end) infinite;
}

.loading-inks span {
    position: absolute;
    top: 3px;
    width: 21px;
    height: 21px;
    border-radius: 50%;
    opacity: .84;
}

.loading-inks span:nth-child(1) { left: 2px; background: #456F91; }
.loading-inks span:nth-child(2) { left: 16px; background: #D77B9C; mix-blend-mode: multiply; }
.loading-inks span:nth-child(3) { left: 30px; background: #D49A54; mix-blend-mode: multiply; }

.loading-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .24em;
}

.loading-progress {
    position: relative;
    width: min(220px, 70vw);
    height: 2px;
    overflow: hidden;
    background: rgba(41, 41, 41, .12);
}

.loading-progress span {
    position: absolute;
    inset: 0;
    width: 100%;
    background: #526E50;
    transform: scaleX(var(--loading-progress, 0));
    transform-origin: left center;
    transition: transform .18s ease;
}

.loading-message {
    max-width: min(320px, 84vw);
    color: rgba(41, 41, 41, .62);
    font-size: 10px;
    letter-spacing: .04em;
    line-height: 1.5;
}

.loading-retry {
    min-width: 140px;
}

#loading-screen.has-error .loading-inks,
#loading-screen.has-error .loading-progress {
    display: none;
}

@keyframes riso-ink-turn {
    to { transform: rotate(360deg); }
}

@keyframes riso-progress {
    0% { transform: translateX(0); }
    100% { transform: translateX(350%); }
}

@media (prefers-reduced-motion: reduce) {
    .loading-inks,
    .loading-progress span { animation-duration: 3s; }
}

.layer-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

body.dragging #world {
    cursor: grabbing;
}

#status {
    position: fixed;
    left: 18px;
    bottom: 16px;
    z-index: 20;

    color: #292929;
    font: 600 10px/1.2 Arial, sans-serif;
    letter-spacing: .18em;
    opacity: .55;

    pointer-events: none;
}

/* Fiche au survol */

#organism-card {
    position: fixed;
    z-index: 30;
    width: 248px;
    padding: 15px 16px 13px;

    color: #292929;
    background: rgba(250, 249, 245, .88);

    border: 1px solid rgba(41, 41, 41, .12);
    border-radius: 5px;

    box-shadow: 0 8px 28px rgba(35, 32, 25, .12);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);

    font: 12px/1.35 Arial, sans-serif;
    pointer-events: none;
}

#organism-card[hidden],
#follow-card[hidden],
#follow-form[hidden] {
    display: none;
}

.organism-heading,
.follow-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;

    font-size: 15px;
    letter-spacing: .02em;
}

.organism-status {
    font-size: 8px;
    letter-spacing: .16em;
    color: #3d7e54;
}

.organism-id,
.follow-id {
    margin-top: 3px;
    font-size: 10px;
    opacity: .5;
}

.organism-species,
.follow-species {
    margin: 9px 0 11px;
    font-size: 10px;
    opacity: .65;
}

.organism-stats,
.follow-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px 12px;
}

.organism-stats div,
.follow-stats div {
    display: flex;
    justify-content: space-between;
    gap: 8px;

    border-bottom: 1px solid rgba(41, 41, 41, .08);
    padding-bottom: 4px;
}

.organism-stats span,
.follow-stats span {
    opacity: .62;
}

.organism-stats b,
.follow-stats b {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.organism-personality,
.follow-personality {
    margin-top: 11px;
    font-size: 10px;
}

.organism-mutations,
.follow-mutations {
    margin-top: 6px;
    font-size: 9px;
    opacity: .6;
}

/* Interface de recherche et de suivi */

#follow-interface {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;

    width: 260px;

    font-family: Arial, sans-serif;
}

.follow-actions {
    display: flex;
    gap: 7px;
}

/* Liquid Glass */

.LiquidGlass,
.primary-button,
.secondary-button {
    position: relative;
    isolation: isolate;
    overflow: hidden;

    color: #292929;

    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, .95),
            rgba(255, 255, 255, .58)
        );

    border: 1px solid rgba(255, 255, 255, .95);
    outline: 1px solid rgba(41, 41, 41, .09);
    border-radius: 10px;

    box-shadow:
        0 5px 15px rgba(35, 32, 25, .09),
        0 1px 3px rgba(35, 32, 25, .05),
        inset 0 1px 2px rgba(255, 255, 255, .95),
        inset 0 -1px 2px rgba(255, 255, 255, .5);

    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);

    transition:
        background .2s ease,
        box-shadow .2s ease,
        transform .2s ease,
        border-color .2s ease;
}

/* Reflet lumineux */

.LiquidGlass::before,
.primary-button::before,
.secondary-button::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;

    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, .8) 0%,
        rgba(255, 255, 255, .18) 40%,
        transparent 65%
    );

    border-radius: inherit;
}

/* Survol */

.LiquidGlass:hover,
.primary-button:hover,
.secondary-button:hover {
    background:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 1),
            rgba(255, 255, 255, .72)
        );

    border-color: #fff;

    box-shadow:
        0 7px 20px rgba(35, 32, 25, .12),
        0 2px 5px rgba(35, 32, 25, .05),
        inset 0 1px 2px #fff;

    transform: translateY(-1px);
}

/* Pression */

.LiquidGlass:active,
.primary-button:active,
.secondary-button:active {
    transform: scale(.98);

    box-shadow:
        0 2px 6px rgba(35, 32, 25, .08),
        inset 0 1px 3px rgba(35, 32, 25, .08);
}

/* Boutons */

.primary-button,
.secondary-button {
    min-height: 36px;
    padding: 0 12px;

    font: 600 10px Arial, sans-serif;
    letter-spacing: .04em;

    cursor: pointer;
}

.primary-button {
    flex: 1;
    color: #405B3F;
}

.secondary-button {
    color: #292929;
}

/* Formulaire */

#follow-form {
    margin-bottom: 9px;
    padding: 14px;

    color: #292929;
    background: rgba(250, 249, 245, .94);

    border: 1px solid rgba(41, 41, 41, .12);
    border-radius: 5px;

    box-shadow: 0 8px 28px rgba(35, 32, 25, .12);

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.follow-form-title {
    margin-bottom: 13px;

    font-size: 10px;
    font-weight: 700;
    letter-spacing: .15em;
}

#follow-form label {
    display: block;
    margin: 9px 0 5px;

    font-size: 10px;
    opacity: .65;
}

#follow-form input {
    width: 100%;
    height: 34px;
    padding: 0 9px;

    color: #292929;
    background: rgba(255, 255, 255, .65);

    border: 1px solid rgba(41, 41, 41, .16);
    border-radius: 3px;
    outline: none;

    font: 12px Arial, sans-serif;
}

#follow-form input:focus {
    border-color: #526E50;
    box-shadow: 0 0 0 2px rgba(82, 110, 80, .12);
}

#follow-form button {
    width: 100%;
    margin-top: 14px;
}

#follow-message {
    margin-top: 7px;

    color: #526E50;
    font-size: 10px;
    line-height: 1.4;
    text-align: right;
}

/* Fiche fixe du Riso suivi */

#follow-card {
    position: fixed;
    right: 18px;
    bottom: 75px;
    z-index: 35;

    width: 260px;
    padding: 16px;

    color: #292929;
    background: rgba(250, 249, 245, .91);

    border: 1px solid rgba(41, 41, 41, .12);
    border-radius: 5px;

    box-shadow: 0 8px 28px rgba(35, 32, 25, .12);

    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

    font: 11px/1.4 Arial, sans-serif;
}

.follow-heading {
    align-items: flex-start;
    font-size: 15px;
}

.follow-heading > div {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.follow-label {
    color: #526E50;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .17em;
}

.follow-name {
    font-size: 16px;
}

.follow-layer {
    margin-top: 10px;
    font-size: 9px;
    opacity: .5;
}

.follow-message {
    margin: 8px 0 0;
    font-size: 11px;
    line-height: 1.5;
}

/* Responsive */

@media (max-width: 600px) {
    #follow-interface {
        right: 10px;
        bottom: 10px;
        width: min(260px, calc(100vw - 20px));
    }

    #follow-card {
        right: 10px;
        bottom: 65px;
        width: min(260px, calc(100vw - 20px));
    }
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#world {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
    touch-action: none;
}

#world canvas {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    touch-action: none;
}

@media (max-width: 768px) {
    #world {
        width: 100vw;
        height: 100dvh;
    }

    #world canvas {
        width: 100%;
        height: 100%;
    }

    #organism-card {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom));
        width: auto;
        max-width: none;
        max-height: 35dvh;
        overflow-y: auto;
        z-index: 20;
    }

    #status {
        max-width: calc(100vw - 24px);
    }
}
