/* ============================================================
   Leaf & Lush: app-mode CSS
   Loaded only when body has .leaflush-app.
   No CSS dependencies. No backdrop-filter. Safe-area aware.
   ============================================================ */

body.leaflush-app {
    /* Localised design tokens so this stylesheet doesn't rely on any other. */
    --lla-ink: #14201A;
    --lla-ink-soft: #2D3A30;
    --lla-muted: #6B7869;
    --lla-line: #D8D2C0;
    --lla-paper: #FBF8F1;
    --lla-paper-2: #F4EFE0;
    --lla-cream: #ECE5D0;
    --lla-leaf: #2D5A3D;
    --lla-leaf-dk: #1F4129;
    --lla-leaf-lt: #A8B9A0;
    --lla-earth: #B45D3A;
    --lla-gold: #C8A44A;
    --lla-serif: 'Fraunces', Georgia, 'Times New Roman', serif;
    --lla-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --lla-bar-h: 64px;
    --lla-bar-total: calc(var(--lla-bar-h) + env(safe-area-inset-bottom, 0px));

    /* Guard against fixed-position break-glass ancestors. */
    transform: none !important;
    filter: none !important;
    perspective: none !important;
}

/* ============================================================
   Bottom navigation bar
   ============================================================ */

.leaflush-app-shell {
    /* Wrapper is here mostly so JS has a single re-parent target. */
    display: contents;
}

.leaflush-appbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: var(--lla-bar-h);
    align-items: stretch;
    background: var(--lla-paper);
    border-top: 1px solid var(--lla-line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    font-family: var(--lla-sans);
    box-shadow: 0 -6px 16px rgba(20, 32, 26, 0.05);
    /* No backdrop-filter. iOS Safari detaches. */
}

/* Every bar item: bulletproof reset so link/button styling can't drift. */
.leaflush-appbar__item,
.leaflush-appbar__center {
    all: unset;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: var(--lla-bar-h);
    padding: 6px 4px 8px;
    gap: 3px;
    color: var(--lla-muted);
    font-family: var(--lla-sans);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.leaflush-appbar__item.is-active {
    color: var(--lla-leaf);
}

.leaflush-appbar__item.is-pressed,
.leaflush-appbar__item:focus-visible {
    background-color: var(--lla-paper-2);
    outline: none;
}
.leaflush-appbar__item.is-pressed .leaflush-appbar__icon {
    transform: scale(0.94);
}

.leaflush-appbar__icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease;
}
.leaflush-appbar__icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

.leaflush-appbar__label {
    display: block;
    font-size: 10.5px;
    line-height: 1.1;
    color: inherit;
}

/* Raised centre button */
.leaflush-appbar__center {
    align-self: end;
    position: relative;
    width: 58px;
    height: 58px;
    margin: 0 auto;
    background: var(--lla-leaf);
    color: var(--lla-paper);
    border-radius: 50%;
    transform: translateY(-14px);
    box-shadow: 0 6px 16px rgba(20, 32, 26, 0.18), 0 1px 2px rgba(20, 32, 26, 0.14);
    transition: transform 0.2s ease, background-color 0.15s ease;
}
.leaflush-appbar__center-icon svg {
    width: 26px;
    height: 26px;
    color: currentColor;
    transition: transform 0.25s ease;
}
.leaflush-appbar__center.is-pressed {
    background: var(--lla-leaf-dk);
    transform: translateY(-14px) scale(0.96);
}
.leaflush-appbar__center.is-open {
    background: var(--lla-leaf-dk);
}
.leaflush-appbar__center.is-open .leaflush-appbar__center-icon svg {
    transform: rotate(45deg);
}

/* ============================================================
   Quick actions arc
   ============================================================ */

.leaflush-appbar-arc {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--lla-bar-total) + 6px);
    z-index: 9989;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 14px;
    padding: 0 16px 12px;
    pointer-events: none;
}
.leaflush-appbar-arc[hidden] { display: none; }

.leaflush-appbar-arc__item {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    color: var(--lla-ink);
    font-family: var(--lla-sans);
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.2, 0.7, 0.3, 1.1);
}

.leaflush-appbar-arc.is-open .leaflush-appbar-arc__item {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.leaflush-appbar-arc.is-open .leaflush-appbar-arc__item:nth-child(1) { transition-delay: 40ms; }
.leaflush-appbar-arc.is-open .leaflush-appbar-arc__item:nth-child(2) { transition-delay: 80ms; }
.leaflush-appbar-arc.is-open .leaflush-appbar-arc__item:nth-child(3) { transition-delay: 120ms; }

.leaflush-appbar-arc__icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--lla-paper);
    color: var(--lla-leaf);
    border: 1px solid var(--lla-line);
    border-radius: 50%;
    box-shadow: 0 6px 14px rgba(20, 32, 26, 0.12);
}
.leaflush-appbar-arc__icon svg { width: 22px; height: 22px; }
.leaflush-appbar-arc__label {
    display: block;
    padding: 3px 10px;
    background: var(--lla-ink);
    color: var(--lla-paper);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.02em;
}
.leaflush-appbar-arc__item.is-pressed .leaflush-appbar-arc__icon {
    transform: scale(0.92);
    transition: transform 0.1s ease;
}

/* Backdrop while arc open (subtle) */
.leaflush-app-shell.arc-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(20, 32, 26, 0.25);
    z-index: 9988;
    animation: leaflush-arc-backdrop 0.2s ease;
}
@keyframes leaflush-arc-backdrop {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   Bottom sheet
   ============================================================ */

.leaflush-sheet {
    padding: 0;
    border: 0;
    background: transparent;
    max-width: none;
    max-height: none;
    width: 100%;
    height: 100%;
    margin: 0;
    inset: 0;
}
.leaflush-sheet::backdrop {
    background: rgba(20, 32, 26, 0.4);
    animation: leaflush-sheet-backdrop 0.2s ease;
}
@keyframes leaflush-sheet-backdrop {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.leaflush-sheet:not([open]) { display: none; }

.leaflush-sheet__panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--lla-paper);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 -10px 40px rgba(20, 32, 26, 0.24);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    transform: translateY(0);
    animation: leaflush-sheet-slide 0.28s cubic-bezier(0.2, 0.7, 0.3, 1);
    font-family: var(--lla-sans);
    will-change: transform;
    touch-action: pan-y;
}
@keyframes leaflush-sheet-slide {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
.leaflush-sheet__panel.is-dragging {
    animation: none;
    transition: none;
}
.leaflush-sheet__panel.is-closing {
    transform: translateY(100%);
    transition: transform 0.24s ease;
}

.leaflush-sheet__handle {
    all: unset;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0 4px;
    cursor: grab;
    touch-action: none;
}
.leaflush-sheet__handle:active { cursor: grabbing; }
.leaflush-sheet__handle-bar {
    display: block;
    width: 44px;
    height: 4px;
    background: var(--lla-line);
    border-radius: 999px;
}
.leaflush-sheet__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 20px 12px;
    border-bottom: 1px solid var(--lla-line);
}
.leaflush-sheet__title {
    margin: 0;
    font-family: var(--lla-serif);
    font-size: 20px;
    font-weight: 600;
    color: var(--lla-ink);
    letter-spacing: -0.01em;
}
.leaflush-sheet__close {
    all: unset;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lla-muted);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s ease;
}
.leaflush-sheet__close:hover,
.leaflush-sheet__close:focus-visible,
.leaflush-sheet__close.is-pressed {
    background: var(--lla-paper-2);
    color: var(--lla-ink);
    outline: none;
}

.leaflush-sheet__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 18px 12px 8px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.leaflush-sheet__link {
    all: unset;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 8px;
    border-radius: 12px;
    cursor: pointer;
    color: var(--lla-ink);
    text-align: center;
    transition: background-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.leaflush-sheet__link:hover,
.leaflush-sheet__link:focus-visible,
.leaflush-sheet__link.is-pressed {
    background: var(--lla-paper-2);
    outline: none;
}
.leaflush-sheet__link--muted { color: var(--lla-muted); }
.leaflush-sheet__icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--lla-paper-2);
    border-radius: 50%;
    color: var(--lla-leaf);
}
.leaflush-sheet__icon svg { width: 22px; height: 22px; }
.leaflush-sheet__label {
    font-family: var(--lla-sans);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
}

/* ============================================================
   Dashboard (rendered by [leaflush_app_dashboard])
   ============================================================ */

.leaflush-app-dashboard {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 20px;
    font-family: var(--lla-sans);
    color: var(--lla-ink);
}
.leaflush-app-dashboard__greeting {
    font-family: var(--lla-serif);
    font-size: 30px;
    font-weight: 600;
    line-height: 1.1;
    margin: 8px 0 6px;
    letter-spacing: -0.01em;
}
.leaflush-app-dashboard__greeting em {
    font-style: italic;
    color: var(--lla-leaf);
    font-weight: 500;
}
.leaflush-app-dashboard__intro {
    font-size: 15px;
    color: var(--lla-muted);
    margin: 0 0 24px;
    line-height: 1.5;
}

.leaflush-app-dashboard__section {
    margin: 24px 0;
}
.leaflush-app-dashboard__section-title {
    font-family: var(--lla-sans);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--lla-leaf);
    margin: 0 0 12px;
}

.leaflush-app-dashboard__tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.leaflush-app-dashboard__tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 18px;
    background: var(--lla-paper);
    border: 1px solid var(--lla-line);
    border-radius: 14px;
    text-decoration: none;
    color: var(--lla-ink);
    min-height: 132px;
    transition: transform 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.leaflush-app-dashboard__tile.is-pressed {
    transform: scale(0.97);
    border-color: var(--lla-leaf-lt);
}
.leaflush-app-dashboard__tile-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lla-paper-2);
    color: var(--lla-leaf);
    border-radius: 50%;
}
.leaflush-app-dashboard__tile-icon svg { width: 18px; height: 18px; }
.leaflush-app-dashboard__tile-title {
    font-family: var(--lla-serif);
    font-size: 17px;
    font-weight: 600;
    margin: 12px 0 4px;
    line-height: 1.2;
}
.leaflush-app-dashboard__tile-desc {
    font-size: 12.5px;
    color: var(--lla-muted);
    line-height: 1.4;
    margin: 0;
}

.leaflush-app-dashboard__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.leaflush-app-dashboard__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--lla-paper);
    border: 1px solid var(--lla-line);
    border-radius: 12px;
    text-decoration: none;
    color: var(--lla-ink);
    font-size: 14px;
}
.leaflush-app-dashboard__row-title {
    font-weight: 600;
    line-height: 1.2;
}
.leaflush-app-dashboard__row-meta {
    display: block;
    font-size: 12px;
    color: var(--lla-muted);
    font-weight: 400;
    margin-top: 2px;
}
.leaflush-app-dashboard__row-chevron {
    color: var(--lla-muted);
    font-size: 18px;
    line-height: 1;
}
.leaflush-app-dashboard__empty {
    padding: 16px;
    background: var(--lla-paper-2);
    border-radius: 12px;
    font-size: 13.5px;
    color: var(--lla-muted);
    text-align: center;
    line-height: 1.5;
}

/* ============================================================
   In-app dedup: hide things that a bottom bar makes redundant.
   Only applied in app mode.
   ============================================================ */

body.leaflush-app .back-to-dashboard,
body.leaflush-app .home-link,
body.leaflush-app a[href="/dashboard/"]:not(.leaflush-appbar__item):not(.leaflush-sheet__link):not(.leaflush-app-dashboard__tile) {
    /* Note: this doesn't hide in-feature "back" links because those don't
       point at /dashboard/; they point at parent listings, etc. */
    display: none !important;
}

/* Any theme-supplied floating action button often collides with the bar. */
body.leaflush-app .floating-action-button,
body.leaflush-app .fab {
    bottom: calc(var(--lla-bar-total) + 12px) !important;
}
