/* ============================================================
   IN-PHONE APP UI — Lighting Buddy
   ------------------------------------------------------------
   Everything in this file is authored in true iOS logical
   points against a 390 × 844 screen, so `17px` really is the
   iOS body size and `44px` really is a tap target.

   The whole screen is then scaled into whatever frame it sits
   in via --app-scale, which app-demo.js measures and sets.
   The static fallbacks below keep it correct without JS.
   ============================================================ */

.app-screen {
    /* Fallback for the no-JS case: (frame width − 2×2px border − 2×padding)
       over 390. app-demo.js measures the real width and overwrites it. */
    --app-scale: 0.6769;

    --ios-blue: #0a84ff;
    --ios-blue-soft: #4da2ff;
    --ios-orange: #ff9f0a;
    --ios-green: #30d158;
    --ios-purple: #d76ee0;
    --ios-yellow: #ffd60a;

    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.62);
    --label-3: rgba(235, 235, 245, 0.32);
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.16);
    --card: #131315;
    --card-blue: rgba(10, 132, 255, 0.1);
    --card-blue-edge: rgba(10, 132, 255, 0.16);

    position: absolute;
    top: 0;
    left: 0;
    width: 390px;
    height: 844px;
    transform: scale(var(--app-scale));
    transform-origin: top left;
    background: #000;
    color: var(--label);
    font-family: -apple-system, "SF Pro Text", "SF Pro Display", "Helvetica Neue",
        system-ui, sans-serif;
    font-size: 17px;
    line-height: 1.2;
    letter-spacing: -0.01em;
    /* the page centres text at narrow widths — the app must not inherit that */
    text-align: left;
    overflow: hidden;
    /* the phone is decorative chrome — never let it eat a real click */
    pointer-events: none;
    user-select: none;
}

.phone-frame-sm .app-screen {
    --app-scale: 0.5436;
}

/* keep the no-JS fallbacks in step with the frame widths in style.css */
@media (max-width: 900px) {
    .phone-frame-sm .app-screen { --app-scale: 0.5949; }
}

@media (max-width: 600px) {
    .app-screen { --app-scale: 0.5641; }
    .phone-frame-sm .app-screen { --app-scale: 0.5538; }
}

/* ============================================================
   STATUS BAR
   ============================================================ */
.app-statusbar {
    height: 50px;
    padding: 14px 26px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0;
}

.app-statusbar-icons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sb-signal {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 11px;
}

.sb-signal i {
    width: 3px;
    background: #fff;
    border-radius: 1px;
    display: block;
}

.sb-signal i:nth-child(1) { height: 4px; }
.sb-signal i:nth-child(2) { height: 6px; }
.sb-signal i:nth-child(3) { height: 8.5px; }
.sb-signal i:nth-child(4) { height: 11px; }

.sb-wifi { width: 16px; height: 12px; color: #fff; }

.sb-battery {
    width: 27px;
    height: 13px;
    border-radius: 4px;
    background: var(--ios-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #000;
    position: relative;
    letter-spacing: -0.02em;
}

.sb-battery::after {
    content: "";
    position: absolute;
    right: -3px;
    width: 2px;
    height: 5px;
    border-radius: 0 1px 1px 0;
    background: rgba(255, 255, 255, 0.45);
}

/* ============================================================
   PAGE STAGE — holds one or more screens, slides between them
   ============================================================ */
.app-stage {
    position: absolute;
    inset: 50px 0 0;
    overflow: hidden;
    transition: opacity 0.45s ease;
}

/* The loop's cut point: fade out, snap everything back with transitions
   suppressed, fade in. Without this the pages visibly rewind. */
.app-screen.is-cutting .app-stage { opacity: 0; }

.app-screen.is-cutting .app-page,
.app-screen.is-cutting .app-scroll-inner,
.app-screen.is-cutting .app-slider-fill,
.app-screen.is-cutting .app-slider-knob {
    transition: none;
}

.app-page {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    transform: translateX(var(--page-x, 0));
    transition: transform 0.52s cubic-bezier(0.32, 0.72, 0, 1);
}

/* the scrolling content column inside a page */
.app-scroll {
    flex: 1;
    overflow: hidden;
    position: relative;
    /* soften where mid-scroll content meets the nav bar */
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 16px);
    mask-image: linear-gradient(to bottom, transparent 0, #000 16px);
}

.app-scroll-inner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    transform: translateY(calc(var(--scroll-y, 0px) * -1));
    transition: transform 0.75s cubic-bezier(0.32, 0.72, 0, 1);
}

/* ============================================================
   TAB BAR — floating pill
   ============================================================ */
.app-tabbar {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 24px;
    height: 58px;
    border-radius: 29px;
    background: rgba(28, 28, 30, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 6px;
    z-index: 5;
}

.app-tab {
    flex: 1;
    height: 46px;
    border-radius: 23px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--label);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0;
}

.app-tab svg {
    width: 21px;
    height: 21px;
}

.app-tab.is-active {
    background: var(--fill);
    color: var(--ios-blue);
}

/* ============================================================
   SHARED BUILDING BLOCKS
   ============================================================ */
.app-h1 {
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.028em;
    padding: 10px 20px 0;
}

.app-navbar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.app-navbar-title {
    font-size: 19px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.app-nav-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--fill-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--label);
}

.app-nav-circle svg { width: 17px; height: 17px; }

.app-nav-pill {
    height: 38px;
    padding: 0 18px;
    border-radius: 19px;
    background: var(--fill-2);
    display: flex;
    align-items: center;
    font-size: 17px;
    font-weight: 400;
}

.app-section-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.022em;
    margin: 20px 20px 12px;
}

.app-card {
    margin: 0 20px 18px;
    padding: 16px;
    border-radius: 14px;
    background: var(--card);
}

.app-card--blue {
    background: var(--card-blue);
    border: 1px solid var(--card-blue-edge);
}

.app-divider {
    height: 1px;
    background: var(--separator);
    margin: 14px 0;
}

/* ============================================================
   SCREEN — LIGHTING LIBRARY
   ============================================================ */
.app-searchrow {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px 12px;
}

.app-search {
    flex: 1;
    height: 40px;
    border-radius: 11px;
    background: var(--fill);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    color: var(--label-2);
    font-size: 17px;
}

.app-search svg { width: 17px; height: 17px; flex-shrink: 0; }

.app-filter { color: var(--ios-blue); }
.app-filter svg { width: 27px; height: 27px; display: block; }

.app-list { padding: 0 20px; }

.app-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 0;
    border-bottom: 1px solid var(--separator);
    position: relative;
    border-radius: 8px;
}

.app-row::before {
    content: "";
    position: absolute;
    inset: 2px -10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.09);
    opacity: 0;
    transition: opacity 0.14s ease;
}

.app-row.is-pressed::before { opacity: 1; }

.app-row-icon {
    width: 46px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--ios-blue);
}

.app-row-icon svg { width: 25px; height: 25px; }

.app-row-watts {
    font-size: 11px;
    color: var(--label-2);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.app-row-main { flex: 1; min-width: 0; }

.app-row-name {
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.022em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.app-row-meta {
    font-size: 14px;
    color: var(--label-2);
    margin-bottom: 2px;
    white-space: nowrap;
}

.app-row-brand { color: var(--ios-blue); }

.app-row-sub {
    font-size: 12.5px;
    color: var(--label-3);
}

.app-row-stats {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.app-row-fc {
    font-size: 14.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.app-row-at,
.app-row-lbs {
    font-size: 12px;
    color: var(--label-3);
    font-variant-numeric: tabular-nums;
}

.app-row-chev { color: var(--label-3); flex-shrink: 0; }
.app-row-chev svg { width: 12px; height: 12px; display: block; }

/* Stagger-in for the feature-section library phone.
   Note the .is-armed gate on every hidden-by-default rule in this file:
   app-demo.js adds it, so with JS off (or reduced motion on) the screens
   render in their finished state instead of staying invisible. */
.app-anim.is-armed .app-row {
    opacity: 0;
    transform: translateY(14px);
}

.app-anim.is-armed.is-live .app-row {
    opacity: 1;
    transform: none;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--i, 0) * 55ms);
}

/* ============================================================
   SCREEN — LIGHT DETAIL / PHOTOMETRICS
   ============================================================ */
.app-spec-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 12px;
}

.app-spec-label {
    font-size: 13px;
    color: var(--label-2);
    margin-bottom: 3px;
}

.app-spec-value {
    font-size: 18px;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.app-attach {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
}

.app-attach-value {
    color: var(--ios-blue);
    font-size: 18px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 12px;
}

.app-attach-value svg { width: 16px; height: 16px; }

.app-measured {
    font-size: 13px;
    color: var(--label-2);
    margin-bottom: 12px;
}

.app-chart { display: block; width: 100%; height: 200px; }

.app-chart-grid { stroke: rgba(235, 235, 245, 0.14); stroke-width: 1; }
.app-chart-grid--dash { stroke-dasharray: 3 4; }
.app-chart-axis { fill: var(--label-2); font-size: 11px; }

.app-chart-curve {
    fill: none;
    stroke: var(--ios-blue);
    stroke-width: 3;
    stroke-linecap: round;
}

.app-chart-dot { fill: var(--ios-blue-soft); }

/* draw-in, triggered by .is-live */
.app-anim.is-armed .app-chart-curve {
    stroke-dasharray: var(--len, 400);
    stroke-dashoffset: var(--len, 400);
}

.app-anim.is-armed.is-live .app-chart-curve {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.4s cubic-bezier(0.4, 0, 0.2, 1) 0.2s;
}

.app-anim.is-armed .app-chart-dot { opacity: 0; transform: scale(0.2); transform-box: fill-box; transform-origin: center; }

.app-anim.is-armed.is-live .app-chart-dot {
    opacity: 1;
    transform: none;
    transition: opacity 0.3s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition-delay: calc(0.55s + var(--i, 0) * 0.28s);
}

.app-datapoint {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 5px 0;
    font-size: 19px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.app-datapoint .dp-ft { width: 72px; }
.app-datapoint .dp-fc { width: 66px; }
.app-datapoint .dp-beam { font-size: 14px; color: var(--label-2); }

/* ============================================================
   SCREEN — FOOTCANDLE CALCULATOR
   ============================================================ */
.app-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-selected-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 3px;
}

.app-selected-sub { font-size: 13.5px; color: var(--label-2); }

.app-chip {
    padding: 6px 14px;
    border-radius: 15px;
    background: rgba(10, 132, 255, 0.16);
    color: var(--ios-blue);
    font-size: 14px;
    font-weight: 500;
    flex-shrink: 0;
}

.app-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 20px;
    font-size: 17px;
}

.app-field-label { color: var(--label); }

.app-field-control {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--label-2);
    font-size: 15px;
}

.app-input {
    width: 96px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--separator);
    background: #000;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px;
    font-size: 17px;
    color: var(--label);
    font-variant-numeric: tabular-nums;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.app-input.is-focused {
    border-color: var(--ios-blue);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

.app-caret {
    width: 2px;
    height: 20px;
    background: var(--ios-blue);
    margin-left: 2px;
    opacity: 0;
}

.app-input.is-focused .app-caret {
    opacity: 1;
    animation: appCaret 1.05s steps(1) infinite;
}

@keyframes appCaret {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.app-picker {
    color: var(--ios-blue);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 17px;
}

.app-picker svg { width: 15px; height: 15px; }

.app-hint {
    font-size: 12.5px;
    color: var(--label-3);
    padding: 2px 20px 10px;
    font-variant-numeric: tabular-nums;
}

/* slider */
.app-slider-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 4px 20px 8px;
    font-size: 17px;
}

.app-slider-value {
    color: var(--label-2);
    font-variant-numeric: tabular-nums;
}

.app-slider {
    position: relative;
    height: 30px;
    margin: 0 20px;
    display: flex;
    align-items: center;
}

.app-slider-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: 2px;
    background: var(--fill);
}

.app-slider-fill {
    position: absolute;
    left: 0;
    height: 4px;
    border-radius: 2px;
    background: var(--ios-blue);
    width: var(--pct, 100%);
}

.app-slider-knob {
    position: absolute;
    left: var(--pct, 100%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
    transform: translateX(-50%);
}

.app-slider--wide .app-slider-knob {
    width: 30px;
    height: 30px;
}

.app-slider-ends {
    display: flex;
    justify-content: space-between;
    padding: 6px 20px 0;
    font-size: 13px;
    color: var(--label-2);
}

/* results */
.app-result-fstop {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.app-fstop {
    font-size: 42px;
    font-weight: 700;
    color: var(--ios-blue);
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.app-fstop-vs {
    font-size: 13px;
    color: var(--label-2);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

.app-stops {
    font-size: 22px;
    font-weight: 600;
    color: var(--ios-orange);
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.app-stops-sub {
    font-size: 14px;
    color: var(--label-2);
    margin-top: 3px;
}

.app-coverage-label {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.app-coverage-value {
    font-size: 19px;
    text-align: center;
    margin-top: 4px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.app-camera-used {
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 14px;
    color: var(--label-2);
    font-variant-numeric: tabular-nums;
}

.app-reverse-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.app-reverse-input .rv-f { font-size: 22px; color: var(--label-2); }

.app-reverse-box {
    min-width: 118px;
    height: 56px;
    border-radius: 8px;
    border: 1px solid var(--separator);
    background: #000;
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -0.03em;
}

.app-reverse-hint {
    text-align: center;
    font-size: 13px;
    color: var(--label-2);
    margin-top: 7px;
}

.app-moveto-label {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
}

.app-moveto-value {
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    color: var(--ios-blue);
    margin-top: 3px;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.app-metric {
    display: flex;
    justify-content: space-between;
    padding: 4px 20px;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.app-metric span:last-child { color: var(--label-2); }

/* results reveal, used by both the hero beat 3 and the feature phone */
.is-armed .app-reveal {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
}

.is-armed.is-live .app-reveal,
.is-armed .app-page.is-showing-results .app-reveal {
    opacity: 1;
    transform: none;
    transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: calc(var(--i, 0) * 130ms);
}

/* ============================================================
   CURSOR DOT
   ============================================================ */
.app-cursor {
    position: absolute;
    top: 0;
    left: 0;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.25),
        0 0 18px 4px rgba(255, 255, 255, 0.35),
        0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 20;
    opacity: 0;
    transform: translate(var(--cx, 195px), var(--cy, 700px)) scale(1);
    transition:
        transform 0.85s cubic-bezier(0.5, 0.05, 0.15, 1),
        opacity 0.4s ease;
}

.app-cursor.is-visible { opacity: 1; }

.app-cursor.is-tapping {
    transform: translate(var(--cx, 195px), var(--cy, 700px)) scale(0.62);
    transition:
        transform 0.13s cubic-bezier(0.4, 0, 0.6, 1),
        opacity 0.4s ease;
}

/* While dragging, app-demo.js drives --cx frame by frame off the same
   clock as the slider, so a CSS transition here would only add lag. */
.app-cursor.is-dragging {
    transition: opacity 0.4s ease;
}

.app-cursor-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    opacity: 0;
}

.app-cursor.is-tapping .app-cursor-ring {
    animation: appTapRing 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes appTapRing {
    0% { opacity: 0.85; transform: scale(0.55); }
    100% { opacity: 0; transform: scale(2.4); }
}

/* ============================================================
   REDUCED MOTION
   app-demo.js never adds .is-armed here, so every screen already
   renders in its finished state. All that's left is to silence
   the cursor and the transitions that aren't gated on arming.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    .app-cursor { display: none; }

    .app-page,
    .app-scroll-inner {
        transition: none;
    }

    .app-input.is-focused .app-caret { animation: none; opacity: 0; }
}
