/* Monty 3D — meadow showcase */

:root {
    --m3d-ink: #23453a;
    --m3d-muted: #5d7a6f;
    --m3d-green: #376457;
    --m3d-mint: #b7e7d7;
    --m3d-cream: #fdf8ec;
    --m3d-panel: rgba(255, 255, 255, 0.8);
    --m3d-shadow: 0 24px 60px rgba(35, 69, 58, 0.16);
    --m3d-radius: 26px;
    --m3d-font-display: ui-rounded, "SF Pro Rounded", "Avenir Next", "Nunito", system-ui, sans-serif;
    --m3d-font-body: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body.m3d-page {
    margin: 0;
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    color: var(--m3d-ink);
    font-family: var(--m3d-font-body);
    background:
        radial-gradient(1100px 620px at 50% -8%, rgba(253, 248, 236, 0.98) 0%, rgba(253, 248, 236, 0) 62%),
        radial-gradient(760px 560px at 8% 35%, rgba(183, 231, 215, 0.75) 0%, rgba(183, 231, 215, 0) 65%),
        radial-gradient(760px 560px at 94% 18%, rgba(210, 230, 255, 0.72) 0%, rgba(210, 230, 255, 0) 64%),
        linear-gradient(180deg, #edf9f3 0%, #dcefe6 52%, #cbe5d9 100%);
}

[hidden] {
    display: none !important;
}

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

/* The skip link is the first thing a keyboard or screen-reader user meets.
   Keep it visually hidden until it has focus, then show it as a real control:
   otherwise the only way onto the page is an invisible 1x1px target. */
.sr-only:focus,
.sr-only:focus-visible {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 20;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0.6rem 1rem;
    overflow: visible;
    clip: auto;
    white-space: normal;
    color: var(--m3d-ink);
    font-weight: 700;
    text-decoration: none;
    background: #fffdf6;
    border: 2px solid var(--m3d-green);
    border-radius: 999px;
    box-shadow: 0 8px 20px rgba(35, 69, 58, 0.2);
}

/* The skip target carries tabindex="-1" in the markup so the fragment lands
   on <main> instead of <body>. main is a container, not a control, so it does
   not paint a focus ring around the whole stage; the canvas is the next Tab
   stop and has its own visible ring. */
#monty-stage:focus {
    outline: none;
}

.m3d-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: clamp(0.85rem, 2.2vw, 1.6rem) clamp(1rem, 4vw, 3rem) 0.4rem;
    z-index: 3;
}

.m3d-back,
.m3d-play {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 56px;
    min-width: 56px;
    padding: 0.55rem 0.95rem;
    border-radius: 999px;
    color: var(--m3d-ink);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.62);
    box-shadow: 0 6px 18px rgba(35, 69, 58, 0.1);
    transition: background 180ms ease, transform 180ms ease;
}

/* Hover is a pointer affordance, not a press affordance: touch devices latch
   the last hover style. Every hover on this page is behind this query; touch
   gets the shared :active press below. */
@media (hover: hover) and (pointer: fine) {
    .m3d-back:hover,
    .m3d-play:hover {
        background: rgba(255, 255, 255, 0.92);
        transform: translateY(-1px);
    }
}

.m3d-back svg,
.m3d-play svg {
    width: 1.1em;
    height: 1.1em;
    flex: 0 0 auto;
}

.m3d-brand {
    text-align: center;
    line-height: 1;
}

.m3d-eyebrow {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--m3d-muted);
    font-size: clamp(0.62rem, 1.4vw, 0.74rem);
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.m3d-brand h1 {
    margin: 0;
    font-family: var(--m3d-font-display);
    font-size: clamp(1.55rem, 4.2vw, 2.35rem);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.m3d-stage {
    position: relative;
    min-height: 0;
    overflow: hidden;
    isolation: isolate;
}

.m3d-stage::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 8%;
    width: min(62vw, 560px);
    aspect-ratio: 1;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 68%);
    pointer-events: none;
    z-index: 0;
}

.m3d-stage::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 4%;
    width: min(74%, 640px);
    height: 12%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse, rgba(55, 100, 87, 0.22) 0%, rgba(55, 100, 87, 0) 70%);
    filter: blur(6px);
    pointer-events: none;
    z-index: 0;
}

#monty-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    z-index: 1;
}

/* The canvas is the keyboard target for orbit keys; make that focus visible. */
#monty-canvas:focus-visible {
    outline: 3px solid #1e5c4b;
    outline-offset: -3px;
}

.m3d-float {
    position: absolute;
    z-index: 0;
    width: 18px;
    height: 18px;
    border-radius: 61% 39% 55% 45% / 48% 55% 45% 52%;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.78), rgba(183, 231, 215, 0.32));
    box-shadow: 0 8px 22px rgba(55, 100, 87, 0.08);
    animation: m3d-drift 11s ease-in-out infinite;
    pointer-events: none;
}

.m3d-float--a { left: 9%; top: 22%; animation-delay: -2s; }
.m3d-float--b { right: 12%; top: 16%; width: 12px; height: 12px; animation-delay: -5s; }
.m3d-float--c { left: 18%; bottom: 20%; width: 10px; height: 10px; animation-delay: -7s; }
.m3d-float--d { right: 8%; bottom: 28%; width: 22px; height: 22px; animation-delay: -3s; }

@keyframes m3d-drift {
    0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
    50% { transform: translate3d(10px, -18px, 0) rotate(18deg); }
}

.m3d-loading {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-content: center;
    gap: 0.9rem;
    text-align: center;
    color: var(--m3d-muted);
    background: radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 62%);
}

.m3d-spinner {
    width: 46px;
    height: 46px;
    margin: 0 auto;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--m3d-green) 0deg, var(--m3d-mint) 220deg, rgba(55, 100, 87, 0.08) 300deg);
    -webkit-mask: radial-gradient(circle, transparent 52%, #000 54%);
    mask: radial-gradient(circle, transparent 52%, #000 54%);
    animation: m3d-spin 1.15s linear infinite;
}

.m3d-loading p {
    margin: 0;
    font-family: var(--m3d-font-display);
    font-size: 1rem;
    font-weight: 700;
}

@keyframes m3d-spin {
    to { transform: rotate(360deg); }
}

.m3d-fallback {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    text-align: center;
}

.m3d-fallback img {
    width: min(52vw, 300px);
    height: auto;
    filter: drop-shadow(0 18px 24px rgba(55, 100, 87, 0.2));
}

.m3d-fallback p {
    max-width: 30rem;
    margin: 0;
    color: var(--m3d-muted);
    font-size: 0.95rem;
}

.m3d-hint {
    position: absolute;
    left: 50%;
    bottom: 0.8rem;
    transform: translateX(-50%);
    z-index: 2;
    margin: 0;
    padding: 0.38rem 0.8rem;
    border-radius: 999px;
    color: var(--m3d-muted);
    font-size: 0.76rem;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.64);
    box-shadow: 0 4px 14px rgba(35, 69, 58, 0.08);
    pointer-events: none;
}

.m3d-panel {
    position: relative;
    z-index: 3;
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto clamp(0.75rem, 2vw, 1.4rem);
    padding: 0.85rem clamp(0.85rem, 2vw, 1.35rem) 0.9rem;
    border-radius: var(--m3d-radius);
    background: var(--m3d-panel);
    box-shadow: var(--m3d-shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.m3d-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem 1.4rem;
}

.m3d-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.m3d-label {
    width: 100%;
    margin: 0 0 0.15rem 0.2rem;
    color: var(--m3d-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.m3d-btn,
.m3d-link-btn {
    min-height: 56px;
    min-width: 56px;
    padding: 0.55rem 0.9rem;
    border: 0;
    border-radius: 999px;
    color: var(--m3d-ink);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 4px 14px rgba(35, 69, 58, 0.08);
    transition: background 170ms ease, color 170ms ease, transform 170ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .m3d-btn:hover {
        background: #ffffff;
        transform: translateY(-1px);
    }
}

.m3d-btn[aria-pressed="true"] {
    color: var(--m3d-cream);
    background: var(--m3d-green);
    box-shadow: 0 6px 18px rgba(55, 100, 87, 0.3);
}

.m3d-btn:disabled,
.m3d-btn[aria-disabled="true"] {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
    transform: none;
}

/* One press cue for every pressable control on this page, after the hover
   rules so a press outranks a lift. It is not behind the hover query: :active
   is the feedback a touchscreen actually gets. */
.m3d-back:active,
.m3d-play:active,
.m3d-btn:active,
.m3d-link-btn:active {
    transform: scale(0.97);
}

.m3d-actions {
    margin-left: auto;
}

.m3d-note {
    margin: 0.65rem 0 0;
    color: var(--m3d-muted);
    font-size: 0.74rem;
    line-height: 1.4;
}

.m3d-note a {
    color: var(--m3d-green);
    font-weight: 700;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.m3d-retry {
    margin-top: 0.35rem;
}

.m3d-btn:focus-visible,
.m3d-link-btn:focus-visible,
.m3d-back:focus-visible,
.m3d-play:focus-visible,
.m3d-note a:focus-visible {
    outline: 3px solid #1e5c4b;
    outline-offset: 3px;
}

@media (max-width: 760px) {
    .m3d-header {
        padding: 0.7rem 0.9rem 0.2rem;
    }

    .m3d-back,
    .m3d-play {
        padding: 0.55rem 0.7rem;
        font-size: 0.82rem;
    }

    .m3d-back span,
    .m3d-play span {
        display: none;
    }

    .m3d-brand h1 {
        font-size: clamp(1.35rem, 6vw, 1.8rem);
    }

    .m3d-stage {
        min-height: 46vh;
    }

    .m3d-hint {
        bottom: 0.45rem;
        font-size: 0.7rem;
    }

    .m3d-panel {
        width: calc(100% - 1rem);
        margin-bottom: 0.5rem;
        padding: 0.7rem 0.7rem 0.75rem;
        border-radius: 22px;
    }

    .m3d-controls {
        gap: 0.55rem 0.85rem;
    }

    .m3d-group {
        gap: 0.3rem;
    }

    .m3d-label {
        font-size: 0.62rem;
    }

    .m3d-btn {
        min-height: 56px;
        padding: 0.52rem 0.72rem;
        font-size: 0.82rem;
    }

    .m3d-actions {
        margin-left: 0;
    }

    .m3d-note {
        margin-top: 0.55rem;
        font-size: 0.68rem;
    }
}

@media (max-width: 420px) {
    .m3d-brand .m3d-eyebrow {
        display: none;
    }

    .m3d-brand h1 {
        font-size: 1.2rem;
    }

    .m3d-header {
        gap: 0.4rem;
        padding-left: 0.6rem;
        padding-right: 0.6rem;
    }

    .m3d-stage {
        min-height: 43vh;
    }

    .m3d-hint {
        max-width: 92%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Must come after the 420px block: that block still sets the 43vh stage floor. */
@media (max-width: 360px) {
    .m3d-stage {
        min-height: 0;
    }
}

@media (orientation: landscape) and (max-height: 620px) {
    .m3d-header {
        padding: 0.4rem 0.8rem 0.15rem;
    }

    .m3d-brand h1 {
        font-size: 1.25rem;
    }

    .m3d-eyebrow {
        display: none;
    }

    .m3d-stage {
        min-height: 0;
    }

    .m3d-panel {
        width: calc(100% - 1rem);
        padding: 0.4rem 0.65rem 0.45rem;
        margin-bottom: 0.3rem;
        border-radius: 18px;
    }

    .m3d-controls {
        flex-wrap: wrap;
        gap: 0.3rem 0.55rem;
        align-items: center;
    }

    .m3d-group {
        flex-wrap: nowrap;
        gap: 0.25rem;
    }

    .m3d-label {
        display: none;
    }

    .m3d-actions {
        margin-left: auto;
    }

    .m3d-btn {
        min-height: 56px;
        padding: 0.45rem 0.65rem;
        font-size: 0.78rem;
    }

    /* The group labels are hidden here, so a hairline keeps View, Move and
       More from reading as one nine-button row. */
    .m3d-group + .m3d-group {
        padding-left: 0.55rem;
        border-left: 1px solid rgba(23, 60, 49, 0.16);
    }

    .m3d-note,
    .m3d-hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }

    .m3d-float {
        display: none;
    }

    .m3d-spinner {
        animation: none;
        background: conic-gradient(from 0deg, var(--m3d-green) 0deg, var(--m3d-mint) 220deg, rgba(55, 100, 87, 0.08) 300deg);
    }

    .m3d-back:active,
    .m3d-play:active,
    .m3d-btn:active,
    .m3d-link-btn:active {
        transform: none;
    }
}

@media (prefers-contrast: more) {
    .m3d-panel,
    .m3d-back,
    .m3d-play,
    .m3d-hint,
    .m3d-btn {
        background: #ffffff;
        box-shadow: none;
        border: 2px solid #173c31;
    }

    .m3d-btn[aria-pressed="true"] {
        background: #173c31;
        color: #ffffff;
    }

    .m3d-note,
    .m3d-eyebrow,
    .m3d-label,
    .m3d-hint {
        color: #173c31;
    }

    .m3d-stage::before,
    .m3d-stage::after {
        display: none;
    }
}
