/* ============================================================================
 * Design tokens (lite). Established 2026-05-04 — tactical consistency layer
 * before the full Meta-style token system (doc/design-tokens.md) lands.
 *
 * Scope: ONE canonical primary, ONE neutral surface family, ONE radius scale,
 * ONE shadow scale, ONE typography scale. Domain colors (♥ ★ ● grade pills)
 * keep their existing hexes elsewhere — those are CafeMap's identity.
 * ============================================================================ */
:root {
    /* Surface */
    --c-canvas:        #FFFFFF;
    --c-surface-soft:  #FAFAFA;
    --c-surface-mid:   #F5F5F5;
    --c-hairline:      #E5E5E5;
    --c-hairline-soft: #ECECEC;

    /* Text — 4 tiers only. Retire #333/#444/#666/#777/#999/#aaa. */
    --c-text-strong: #222222;          /* primary headlines, button labels on light bg */
    --c-text:        #555555;          /* default body */
    --c-text-soft:   #888888;          /* secondary body, captions */
    --c-text-mute:   #C0C4CC;          /* disabled, very subtle */

    /* Brand / action — single primary; secondary = neutral surface. */
    --c-primary:        #1F2937;       /* near-black — modern neutral primary */
    --c-primary-hover:  #111827;
    --c-primary-on:     #FFFFFF;
    --c-secondary-bg:   #F5F5F5;
    --c-secondary-on:   #222222;
    --c-secondary-hover:#ECECEC;

    /* Domain (NOT to be unified — CafeMap identity) */
    --c-pretty:    #E74C3C;
    --c-favorite:  #F4D03F;
    --c-cafe:      #8B4513;

    /* Brand identity — the cafe brown is the launcher icon background, the PWA
       theme-color, and the manifest splash. Phase 32 (2026-05-28) introduced
       this as a formal alias of --c-cafe so branded UI surfaces (onboarding
       welcome card, permission-denied primary CTA) share one source of truth
       with the marker pin and the OS-level chrome. */
    --c-brand-primary:  #8B4513;

    /* External brand (길찾기) */
    --c-kakao:     #FEE500;
    --c-naver:     #03C75A;
    --c-google:    #1A73E8;

    /* Semantic */
    --c-success:   #2E7D32;
    --c-warning:   #E65100;
    --c-error:     #C0392B;

    /* Radius — collapse 11 distinct values to 5. */
    --r-sm:    6px;     /* tags, micro-controls */
    --r-md:    8px;     /* default — buttons, inputs */
    --r-lg:    12px;    /* cards, dropdowns */
    --r-xl:    16px;    /* sheets, large cards */
    --r-pill:  999px;   /* pill buttons, chips */

    /* Shadow — 3 tiers. */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.22);

    /* Typography — 5 tiers. Retire 10/15/17/20/26/28. */
    --t-page:    22px;  /* page titles */
    --t-h:       16px;  /* section heading, modal title, cafe name */
    --t-body:    14px;  /* default body, button label */
    --t-small:   13px;  /* secondary body, smaller buttons */
    --t-cap:     12px;  /* caption, label, badge */
    --t-micro:   11px;  /* meta text, fine print */

    /* Spacing — 4px base. */
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 12px;
    --sp-lg: 16px;
    --sp-xl: 24px;

    /* ================================================================
     * v3 prototype tokens (Phase 11+) — added 2026-05-10. v3 prototype
     * (doc/프로토타입v3.pptx) introduces a 4-tab bottom nav, bottom-sheet
     * cafe panel, marker re-architecture, and an FAB color. These tokens
     * keep v3-specific values isolated so the lite tokens above stay clean.
     * ================================================================ */

    /* Layout — bottom nav + bottom sheet sizing. AppLayout reserves the nav
       height so map/page content never sits beneath the bar. The bottom-sheet
       max-width (480px) follows Q14/Q15: only the sheet is constrained on
       PC; the rest of the UI stays full-width. */
    --app-bn-height:        64px;   /* 4-tab bottom nav fixed height */
    --app-sheet-max-w:      480px;  /* bottom sheet PC max-width (Q15 = a) */

    /* Marker palette — v3 marker structure is container + icon + badge.
       Brown container for regular cafes; red container for pretty cafes
       (kept defined for forward compat — pretty UI hidden in Phase 11
       per user instruction, surfaces will reactivate later). White icon
       by default; gold icon when the cafe (or any group member) is a
       favorite. The container hex matches the legacy --c-cafe / --c-pretty
       so pre-existing pin gradients stay coherent during migration. */
    --c-marker-regular:     #8B4513;        /* brown — regular cafe pin body */
    --c-marker-pretty:      #E74C3C;        /* red — pretty cafe pin body (deactivated) */
    --c-marker-icon:        #FFFFFF;        /* default coffee/heart icon */
    --c-marker-icon-fav:    #F5A623;        /* gold — favorite (or group has favorite) */
    --c-marker-badge-bg:    #1F2937;        /* near-black count badge */
    --c-marker-badge-on:    #FFFFFF;

    /* FAB / accents from v3 mockups. Purple FAB (slide 1 "+") reserved
       for future feature; pink-accent kept defined for the "예쁜 카페
       투표하기" surface (deactivated in Phase 11). */
    --c-fab-accent:         #6E5CE6;        /* purple FAB */
    --c-vote-accent:        #FF4D7E;        /* pink — pretty-cafe vote (deactivated) */

    /* Typography — Pretendard (v3 mockup font). Falls through to
       system stack if Pretendard isn't loaded; we ship without bundling
       the font in Phase 11 to avoid a 200KB+ payload until the rest of
       the v3 surface is ready. Phase 17 will revisit. */
    --font-app: 'Pretendard', 'Pretendard Variable', -apple-system, BlinkMacSystemFont,
                'Apple SD Gothic Neo', 'Noto Sans KR', 'Helvetica Neue', Helvetica, Arial,
                sans-serif;
}

html, body {
    font-family: var(--font-app);
    color: var(--c-text-strong);
    /* Prevent the browser from interpreting an over-drag at the edge of the map as
       pull-to-refresh / chained scroll. Map drag should never escape the map. */
    overscroll-behavior: none;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--c-google);
}

/* Default button sizing baseline — components can override but should match shape. */
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ============================================================================
 * .cm-btn — canonical button. Components opt in by adding this class alongside
 *   their domain-specific class (e.g. `class="cm-btn cm-btn-primary"`). Existing
 *   components get migrated incrementally; this file owns the canonical look.
 * ============================================================================ */
.cm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-xs);
    height: 36px;
    padding: 0 var(--sp-lg);
    border: none;
    border-radius: var(--r-md);
    font-size: var(--t-body);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.06s ease;
    white-space: nowrap;
}
.cm-btn:active { transform: translateY(1px); }
.cm-btn:disabled { opacity: 0.45; cursor: wait; transform: none; }

.cm-btn-primary {
    background: var(--c-primary);
    color: var(--c-primary-on);
}
.cm-btn-primary:hover:not(:disabled) { background: var(--c-primary-hover); }

.cm-btn-secondary {
    background: var(--c-secondary-bg);
    color: var(--c-secondary-on);
}
.cm-btn-secondary:hover:not(:disabled) { background: var(--c-secondary-hover); }

.cm-btn-ghost {
    background: transparent;
    color: var(--c-text-strong);
    border: 1px solid var(--c-hairline);
}
.cm-btn-ghost:hover:not(:disabled) { background: var(--c-surface-soft); }

.cm-btn-sm { height: 28px; padding: 0 var(--sp-md); font-size: var(--t-small); }
.cm-btn-lg { height: 44px; padding: 0 var(--sp-xl); }
.cm-btn-pill { border-radius: var(--r-pill); }
.cm-btn-block { width: 100%; }

/* Hidden file-picker input that pairs with a custom-styled label. Lives in app.css
   (not scoped) so it works through Blazor CSS isolation when used inside InputFile. */
.cm-file-input {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Legacy bootstrap-template button kept for backward-compat with default Blazor scaffolding. */
.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG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1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

/* Auth-required / 404 fallback rendered by App.razor inside AppLayout. Lives
   in app.css (not scoped) because App.razor sits above the Blazor CSS
   isolation boundary. Kept tiny — just enough to look intentional inside
   the 4-tab shell. */
.auth-required {
    max-width: 480px;
    margin: 64px auto 0;
    padding: 24px 24px 40px;
    text-align: center;
}
.auth-required-title {
    margin: 0 0 8px;
    font-size: var(--t-page);
    font-weight: 800;
    color: var(--c-text-strong);
}
.auth-required-sub {
    margin: 0 0 24px;
    font-size: var(--t-body);
    color: var(--c-text-soft);
    line-height: 1.55;
}
.auth-required-cta {
    display: inline-block;
    padding: 12px 24px;
    background: var(--c-primary);
    color: var(--c-primary-on);
    border-radius: var(--r-pill);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--t-body);
}
.auth-required-cta:hover {
    background: var(--c-primary-hover);
}

/* ============================================================================
 * Cluster popover (Phase 12.3, 2026-05-10) — replaces ClusterCafeListModal for
 * same-coordinate cafe groups. Lives in app.css (global scope) because it's
 * injected into a Kakao CustomOverlay HTML node, which sits outside Blazor's
 * scoped-CSS boundary. Visual reference: doc/프로토타입v3.pptx slide 3 — small
 * card floating above the marker, list of cafes with mark + name, downward
 * arrow pointing at the marker tip.
 * ============================================================================ */
.cluster-popover {
    width: 240px;
    max-width: calc(100vw - 32px);
    background: var(--c-canvas);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--c-hairline);
    color: var(--c-text-strong);
    font-family: var(--font-app);
    font-size: var(--t-body);
    /* Slight overlap with the marker tip so the arrow visually connects. */
    margin-bottom: 8px;
    position: relative;
    /* The list scrolls; the head + arrow do not. Total max-height keeps the
       popover from blowing past mid-screen when a cluster has 50+ rows. */
    max-height: 360px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Above markers (zIndex 1000 on the overlay), below modals (z-index ≥ 1500). */
    z-index: 0;
}

.cluster-popover .cp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-sm);
    padding: 10px 12px;
    border-bottom: 1px solid var(--c-hairline-soft);
    flex-shrink: 0;
}

.cluster-popover .cp-title {
    font-size: var(--t-small);
    font-weight: 700;
    color: var(--c-text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cluster-popover .cp-close {
    background: none;
    border: none;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: var(--r-sm);
    color: var(--c-text-soft);
    font-size: 18px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.cluster-popover .cp-close:hover {
    background: var(--c-surface-soft);
    color: var(--c-text-strong);
}

.cluster-popover .cp-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0;
}

.cluster-popover .cp-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s ease;
}
.cluster-popover .cp-row:hover {
    background: var(--c-surface-soft);
}

.cluster-popover .cp-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    flex-shrink: 0;
    line-height: 1;
}
.cluster-popover .cp-mark.reg { background: var(--c-cafe);     color: #FFFFFF; }
.cluster-popover .cp-mark.fav { background: var(--c-favorite); color: #FFFFFF; }

.cluster-popover .cp-name {
    font-size: var(--t-small);
    color: var(--c-text-strong);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Downward arrow that points at the marker tip. Two stacked triangles —
   the outer one is the border color, the inner one matches the canvas so
   the popover looks like one continuous shape. */
.cluster-popover .cp-arrow {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--c-hairline);
}
.cluster-popover .cp-arrow::after {
    content: '';
    position: absolute;
    left: -7px;
    top: -9px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 7px solid var(--c-canvas);
}

/* Search-result pulse: 2 expanding red rings centered on the picked cafe. */
.cafemap-pulse {
    position: relative;
    width: 18px;
    height: 18px;
    pointer-events: none;
}
.cafemap-pulse::before,
.cafemap-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid #E74C3C;
    opacity: 0;
    animation: cafemapPulse 1.6s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
.cafemap-pulse::after { animation-delay: 0.7s; }

@keyframes cafemapPulse {
    0%   { transform: scale(0.4); opacity: 0.95; }
    70%  { transform: scale(2.6); opacity: 0.20; }
    100% { transform: scale(3.2); opacity: 0; }
}

/* Selected-cafe highlight: ring/halo overlay retired (Phase 13.5 v2,
   2026-05-13). The selected marker is now rendered as a distinct SVG
   variant in kakaoMap.js (purple container + heavier shadow + thicker
   white stroke), so the highlight lives inside the marker layer and
   gets clustered along with everything else on zoom-out — no separate
   CSS overlay needed. See buildV3MarkerSvg() `state.isSelected` branch. */

/* Phase 22 — locale-bootstrap loading state in AppLayout. While LocaleState fetches
   the active dictionary the layout shows just an empty div to avoid the FOUC where
   @L[key] resolves to raw key strings. Animation is intentionally subtle: a 200ms
   bootstrap usually completes before the user notices. */
.app-locale-loading {
    width: 100%;
    height: 100vh;
    background: var(--c-canvas);
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-locale-loading::after {
    content: "";
    width: 28px;
    height: 28px;
    border: 3px solid var(--c-hairline);
    border-top-color: var(--c-text-soft);
    border-radius: 50%;
    animation: app-locale-spin 700ms linear infinite;
}
@keyframes app-locale-spin {
    to { transform: rotate(360deg); }
}
