html,
body {
    margin: 0;
    padding: 0;
    font-family: Helvetica, Arial, sans-serif;
}

/* Globally prevent text selection (e.g. word-select on double-tap/double-click). */
* {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Re-enable selection where the user actually edits/selects text. */
input,
textarea,
[contenteditable]:not([contenteditable="false"]) {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

:root {
    --title-size: min(1.9vh, 1.6vw);
    --body-size: calc(var(--title-size) * 0.66);

    /* Banner layout variables */
    --banner-left-edge: 2.5vh; /* matches .tutorial-banner { left } */
    --banner-left-pad: 1.8vh; /* left padding that forms part of red block */
    --banner-icon-size: 3vh; /* actual icon size */
    --banner-icon-pad: 0.6vh; /* padding inside icon box on each side */
    --banner-content-gap: 1vh; /* gap between icon and text */
    --banner-text-buffer: 0.4vh; /* extra buffer so text is fully outside */
    /* Distance from banner left edge to text start (icon + its padding + gap) */
    --banner-text-left: calc(var(--banner-icon-size) + (2 * var(--banner-icon-pad)) + var(--banner-content-gap));
    /* Total width of the red strip on the left */
    --banner-red-width: calc(var(--banner-left-pad) + var(--banner-icon-size) + (2 * var(--banner-icon-pad)));
    /* How much of the banner stays hidden under the iPad on the right side */
    --banner-peek-inside: 2vh;
    /* iPad bezel/border width to clear for full text visibility */
    --ipad-border-width: 0.5vh;
}

body {
    display: flex;
    align-items: stretch;
    gap: 3vw;
    padding: 0 3vw;
    background: #E6F3FA;
    color: #2d2d2d;
    height: 100vh;
}

/* Left pane should take remaining space; iPad fixed width on the right */
.left-pane {
    flex: 1 1 0;
    min-width: 0;
    max-width: 50vw;
    container-type: inline-size;
    container-name: left-pane;
}
.ipad {
    flex: 0 0 auto;
}

/* Tutorial panel shown inside left-pane feature grid (spans two columns) */
#tutorial-panel {
    display: none;
    padding: 0;
    grid-column: 1 / -1; /* span two grid columns */
}
@media (min-aspect-ratio: 1/1) {
    #tutorial-panel {
        display: block;
    }
}
#tutorial-panel .tutorial-frame,
#tutorial-panel .tutorial-welcome-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
#tutorial-panel .tutorial-frame-shell {
    position: relative;
}
#tutorial-panel .tutorial-pdf-loading {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 248, 240, 0.95);
    color: #2d2d2d;
    font-weight: 700;
    text-align: center;
    z-index: 3;
}
#tutorial-panel .tutorial-pdf-loading.show {
    display: flex;
}
#tutorial-panel .tutorial-wrapper {
    position: relative;
    border: 1px solid #000;
    border-radius: 1vw;
    padding: 0;
    background: transparent;
    overflow: hidden; /* clip inner content to rounded corners */
}
#tutorial-panel .tutorial-frame-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: transparent;
    pointer-events: auto;
    touch-action: none;
}
#tutorial-panel .tutorial-header {
    display: flex;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0 0.6rem 0 0; /* remove vertical padding so red strip fills full height */
    border-bottom: 1px solid #000;
}
#tutorial-panel .tutorial-title {
    font-weight: 700;
    color: red;
    font-size: var(--title-size);
    margin: 0.8rem 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
#tutorial-panel .tutorial-switch-link {
    flex: 0 0 auto;
    align-self: center;
    margin: 0 0.6rem 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: red;
    font-size: calc(var(--body-size) * 0.95);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
#tutorial-panel .tutorial-switch-link:hover {
    color: #000;
    background: transparent;
}
body:not(.show-tutorial) #tutorial-panel .tutorial-close {
    display: none;
}
#tutorial-panel .tutorial-project-shell {
    display: none;
}
body.show-tutorial #tutorial-panel .tutorial-welcome-shell {
    display: none;
}
body.show-tutorial #tutorial-panel .tutorial-project-shell {
    display: block;
}
body.show-tutorial #tutorial-panel .tutorial-welcome-title {
    display: none;
}
#tutorial-panel .tutorial-project-title {
    display: none;
}
body.show-tutorial #tutorial-panel .tutorial-project-title {
    display: inline;
}
body.show-tutorial #tutorial-panel .tutorial-switch-link {
    display: none !important;
}
#tutorial-panel .tutorial-header-spacer {
    flex: 1 1 auto;
}
#tutorial-panel .tutorial-icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch; /* fill header height */
    padding: 0 0.6rem; /* horizontal padding only */
    background: red; /* solid red strip */
}
#tutorial-panel .tutorial-header-icon {
    width: calc(var(--title-size) * 1.2);
    height: calc(var(--title-size) * 1.2);
    display: block;
    object-fit: contain;
}
#tutorial-panel .tutorial-header-tutorial-icon {
    filter: invert(1) brightness(1.6) contrast(1.1);
}
#tutorial-panel .tutorial-header-ruler-logo {
    display: none;
    width: auto;
    max-width: calc(var(--title-size) * 3.5);
    height: calc(var(--title-size) * 1.6);
    filter: none;
}
body:not(.show-tutorial) #tutorial-panel .tutorial-header-tutorial-icon {
    display: none;
}
body:not(.show-tutorial) #tutorial-panel .tutorial-header-ruler-logo {
    display: block;
}
body.show-tutorial #tutorial-panel .tutorial-header-ruler-logo {
    display: none;
}
#tutorial-panel .tutorial-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #000;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
}

.ipad {
    position: relative;
}

/* Left pane with logo on top and grid vertically centered */
.left-pane {
    display: flex;
    flex-direction: column;
}
.logo-row {
    display: flex;
    align-items: center;
    align-self: stretch;
    gap: 1.2rem;
    margin: 2vh 0 1vh 0;
    min-width: 0;
}

.ruler-logo {
    width: min(40vw, 240px);
    margin: 0;
}

.releases-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.45em;
    max-width: min(28ch, 42vw);
    padding: 0.4em 0.7em 0.4em 0.55em;
    font-size: clamp(0.78rem, 1.45vh, 0.95rem);
    font-weight: 600;
    line-height: 1.25;
    color: #1d4d2c;
    background: #fff;
    border-radius: 999px;
    box-shadow: 0 0.12em 0.45em rgba(0, 0, 0, 0.12);
}

.releases-cta[hidden] {
    display: none;
}

.releases-cta__icon {
    width: 0.95em;
    height: 0.95em;
    flex-shrink: 0;
    color: #2a9d4a;
}

.releases-cta__text {
    min-width: 0;
}

.releases-cta::after {
    content: "→";
    flex-shrink: 0;
    font-weight: 700;
    opacity: 0.55;
}

.releases-cta:hover {
    background-color: #2a9d4a;
    color: #fff;
    text-decoration: none;
}

.releases-cta:hover .releases-cta__icon,
.releases-cta:hover::after {
    color: #fff;
    opacity: 1;
}

.releases-cta:focus-visible {
    outline: 2px solid #2a9d4a;
    outline-offset: 3px;
}

@container left-pane (max-width: 540px) {
    .releases-cta {
        gap: 0;
        max-width: none;
        padding: 0.5em;
    }

    .releases-cta__icon {
        width: 1.15em;
        height: 1.15em;
    }

    .releases-cta__text,
    .releases-cta::after {
        display: none;
    }
}

a {
    text-decoration: none;
    color: red;
    transition: color 300ms ease-in-out;
}

a:hover {
    background-color: red;
    color: white;
}

.ipad iframe.grid-frame {
    margin-top: 2vh;
    background: linear-gradient(-45deg, rgb(10, 10, 10) 0%, rgb(50, 50, 50) 100%);
    padding: 3vh;
    border-radius: 3vh;
    border: solid gray 0.5vh;
    box-shadow: 0.2vw 0.2vw 1vw rgba(0, 0, 0, 0.5);
    height: 89vh;
    aspect-ratio: 9 / 14;
    position: relative;
    z-index: 2;
}

#ipad-frontfacing-webcam {
    position: absolute;
    width: 2vh;
    left: 50%;
    translate: -50%;
    top: 2.9vh;
    z-index: 3; /* above iframe and banner */
}

/* Feature grid replacing about-ruler */
.feature-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2vh;
    padding: 0;
    padding-bottom: 5vh;
    margin: auto 0;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    align-content: start;
    align-items: start;
    /* Subtle themed scrollbar (Firefox) */
    scrollbar-width: thin;
    scrollbar-color: #9fb8c8 transparent;
}
.feature-grid::-webkit-scrollbar {
    width: 0.6rem;
}
.feature-grid::-webkit-scrollbar-track {
    background: transparent;
}
.feature-grid::-webkit-scrollbar-thumb {
    background: #9fb8c8;
    border-radius: 999px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.feature-grid::-webkit-scrollbar-thumb:hover {
    background: #8ea9ba;
}

.feature-box {
    grid-column: 1 / -1;
    border: 1px solid #000;
    border-radius: 1vw;
    padding: 0.8rem 1rem;
    background: #E6F3FA;
    color: #2d2d2d;
    display: grid;
    grid-template-columns: 1fr;
}

.feature-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0;
}
.feature-tab {
    background: transparent;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: min(1.1vw, 30px);
    font-weight: 700;
    color: #2d2d2d;
    padding: 0.3vw 0.6vw;
    border-radius: 0.6rem;
    cursor: pointer;
    transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
    white-space: nowrap;
}
.feature-tab:hover {
    border-color: red;
    color: red;
}
.feature-tab:focus-visible {
    outline: 2px solid red;
    outline-offset: 2px;
}
.feature-tab.active {
    background: red;
    border-color: red;
    color: white;
}

.feature-panel {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    align-items: flex-start;
    gap: 1vw;
    padding: 1rem 0 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}
.feature-panel.active {
    opacity: 1;
    visibility: visible;
}
.feature-panel-image {
    position: relative;
    flex: 0 0 35%;
    max-width: min(35%, 12vw);
    border-radius: 1vw;
    overflow: hidden;
}
.feature-panel-image .feature-base {
    display: block;
    width: 100%;
    height: auto;
}
.feature-panel-image .feature-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}
.feature-panel-text {
    flex: 1;
    min-width: 0;
}
.feature-panel-text h3 {
    margin: 0 0 0.6rem 0;
    color: red;
    font-size: calc(var(--title-size) * 1.4);
    font-weight: 700;
}
.feature-panel-text p {
    margin: 0;
    color: rgb(100, 100, 100);
    font-size: min(1vw, 30px);
    line-height: 1.6;
}

/* Stronger portrait overrides placed after base rules to ensure precedence */
@media (max-aspect-ratio: 1/1) {
    .left-pane {
        display: none !important;
    }
    .ipad {
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100dvh;
        background: none;
        z-index: 1000;
    }
    .ipad iframe.grid-frame {
        position: fixed;
        left: 0;
        top: 0;
        width: 100vw;
        height: 100dvh;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        z-index: 1001;
    }
    #ipad-frontfacing-webcam {
        display: none !important;
    }
}

/* Narrow viewport adjustments (final override) */
@media (max-width: 1080px) {
    body {
        padding: 0 1vw;
        gap: 1vw;
    }
}

/* Footer */
.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #D4E8F2;
    color: inherit;
    z-index: 1; /* under iPad (iframe has z-index 2) */
}
.site-footer .footer-inner {
    padding: 1.2vh 3vw;
    text-align: left;
    font-size: var(--body-size);
}

/* Shell pseudo-fullscreen requested by iframe (iOS fallback) */
body.app-pseudo-fullscreen {
    padding: 0;
    gap: 0;
    overflow: hidden;
}
body.app-pseudo-fullscreen .left-pane,
body.app-pseudo-fullscreen .site-footer {
    display: none;
}
body.app-pseudo-fullscreen .ipad {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 1200;
}
body.app-pseudo-fullscreen .ipad iframe.grid-frame {
    position: fixed;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100dvh;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}
body.app-pseudo-fullscreen #ipad-frontfacing-webcam {
    display: none;
}

/* Touch warning popup (shell only) */
.touch-warning-popup {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
}
.touch-warning-popup.show {
    display: flex;
}
.touch-warning-popup-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem;
    background: #E6F3FA;
    border-radius: 0.8rem;
    border: 1px solid #000;
    width: min(90vw, 640px);
}
.touch-warning-popup img {
    max-height: 70vh;
    width: 100%;
    height: auto;
    display: block;
}
.touch-warning-popup-text {
    margin: 0;
    font-size: var(--title-size);
    color: #2d2d2d;
    text-align: center;
}
.touch-warning-popup-actions {
    display: flex;
    gap: 0.8rem;
}
.touch-warning-popup-actions button {
    border: 1px solid red;
    background: red;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: bold;
}
