/* Palette and type follow the Plant Identifier design: Lora for headings, Mulish for text,
   and a warm green-tinted paper background. */
:root {
    --ink: oklch(0.28 0.03 140);
    --ink-soft: oklch(0.45 0.03 140);
    --ink-faint: oklch(0.55 0.02 130);
    --ground: oklch(0.97 0.015 110);
    --ground-top: oklch(0.955 0.025 120);
    --card: #fff;
    --field: oklch(0.985 0.008 110);
    --line: oklch(0.9 0.02 130);
    --line-strong: oklch(0.87 0.02 130);
    --leaf: oklch(0.5 0.1 155);
    --leaf-deep: oklch(0.44 0.09 155);
    --leaf-wash: oklch(0.95 0.025 135);
    --leaf-tint: oklch(0.975 0.012 130);
    --badge-bg: oklch(0.92 0.05 145);
    --badge-ink: oklch(0.38 0.08 150);
    --water-bg: oklch(0.94 0.03 220 / 0.5);
    --water-line: oklch(0.88 0.04 220);
    --water-dot: oklch(0.62 0.11 230);
    --water-label: oklch(0.5 0.07 230);
    --water-ink: oklch(0.4 0.03 200);
    --warn-bg: oklch(0.97 0.03 85);
    --warn-line: oklch(0.85 0.06 85);
    --warn-ink: oklch(0.45 0.08 70);
    --error-bg: oklch(0.96 0.03 25);
    --error-line: oklch(0.85 0.07 25);
    --error-ink: oklch(0.45 0.13 25);
    --serif: Lora, Georgia, serif;
    --sans: Mulish, system-ui, -apple-system, "Segoe UI", sans-serif;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: translateY(0) } }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--sans);
    line-height: 1.55;
}

button, input { font: inherit; color: inherit; }
::placeholder { color: oklch(0.62 0.02 120); }
:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }
[tabindex="-1"]:focus, h1:focus { outline: none; }

/* ---- shell ---------------------------------------------------------------- */

.shell {
    min-height: 100vh;
    background: linear-gradient(180deg, var(--ground-top) 0%, var(--ground) 320px);
}

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 1080px;
    margin: 0 auto;
    padding: 22px 28px;
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    flex: none;
    color: var(--leaf-deep);
}

.brand-name { font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: 0.2px; }

.masthead-tag {
    font-size: 13px; font-weight: 600;
    color: oklch(0.5 0.05 145);
    letter-spacing: 0.6px; text-transform: uppercase;
}

.stage { animation: fadeUp .4s ease; }

/* ---- search --------------------------------------------------------------- */

.search { max-width: 680px; margin: 0 auto; padding: 52px 28px 80px; }

.search h1 {
    font-family: var(--serif);
    font-size: clamp(2rem, 6vw, 46px);
    font-weight: 500; line-height: 1.15;
    margin: 0 0 14px; text-align: center; text-wrap: pretty;
}

.search-lede {
    font-size: 17px; line-height: 1.6; color: var(--ink-soft);
    text-align: center; margin: 0 0 36px; text-wrap: pretty;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 8px 30px oklch(0.5 0.06 145 / 0.08);
    padding: 24px;
}

.ask { display: flex; gap: 10px; flex-wrap: wrap; }

.ask-input {
    flex: 1 1 16rem; min-width: 0;
    font-size: 16px; padding: 13px 16px;
    border: 1.5px solid var(--line-strong);
    border-radius: 12px;
    background: var(--field);
    outline: none;
}

.ask-input:focus { border-color: var(--leaf); }

.ask-button {
    flex: 0 0 auto;
    font-size: 15px; font-weight: 700;
    padding: 13px 24px;
    border: none; border-radius: 12px;
    background: var(--leaf); color: #fff;
    cursor: pointer;
}

.ask-button:hover:not(:disabled) { background: var(--leaf-deep); }
.ask-button:disabled { opacity: .45; cursor: not-allowed; }

.rule { display: flex; align-items: center; gap: 12px; margin: 18px 0; }
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: oklch(0.91 0.015 130); }
.rule span { font-size: 12px; font-weight: 600; color: oklch(0.6 0.02 130); letter-spacing: .8px; }

.photo-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 12px; }

.photo-action {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    padding: 14px;
    border: 1.5px solid oklch(0.8 0.04 145);
    border-radius: 12px;
    background: var(--leaf-tint);
    color: oklch(0.42 0.06 150);
    font-size: 15px; font-weight: 600;
    cursor: pointer;
}

.photo-action:hover:not(:disabled) { background: var(--leaf-wash); border-color: oklch(0.6 0.08 150); }
.photo-action:disabled { opacity: .5; cursor: not-allowed; }
.photo-action .glyph { font-size: 18px; line-height: 1; }

/* InputFile renders a real file input; it covers the label so the whole tile is clickable. */
.photo-action input[type="file"] {
    position: absolute; inset: 0;
    opacity: 0; cursor: pointer; font-size: 0;
}

.photo-action-file { position: relative; overflow: hidden; }

.chosen-photo { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.chosen-photo img { width: 56px; height: 56px; object-fit: cover; border-radius: 12px; border: 2px solid var(--card); box-shadow: 0 3px 10px oklch(0.5 0.06 145 / .15); }
.chosen-photo span { font-size: 14px; color: var(--ink-soft); }
.chosen-photo button { margin-left: auto; background: none; border: none; color: var(--leaf); font-size: 13px; font-weight: 700; cursor: pointer; }

/* ---- environment ---------------------------------------------------------- */

.environment-details {
    margin-top: 20px;
    padding-top: 4px;
    border-top: 1px solid oklch(0.94 0.01 130);
}

/* list-style removes the disclosure triangle in Firefox; the ::-webkit-details-marker rule below
   does the same in Safari. The chevron is drawn instead so it can sit on the right and turn. */
.environment-summary {
    display: flex;
    align-items: baseline;
    gap: .75rem;
    padding: 14px 2px;
    cursor: pointer;
    list-style: none;
    border-radius: 8px;
}

.environment-summary::-webkit-details-marker { display: none; }
.environment-summary:hover .environment-heading { color: var(--leaf-deep); }
.environment-summary:focus-visible { outline: 2px solid var(--leaf); outline-offset: 2px; }

.environment-summary::after {
    content: "";
    flex: none;
    margin-left: auto;
    align-self: center;
    width: 7px; height: 7px;
    border-right: 2px solid var(--ink-faint);
    border-bottom: 2px solid var(--ink-faint);
    transform: rotate(45deg);
    transition: transform .18s ease;
}

.environment-details[open] .environment-summary::after { transform: rotate(-135deg); }

/* Amber rather than the error red: nothing has gone wrong, there is just a setting to turn on. */
.digest-alert { color: var(--warn-ink); font-weight: 700; }

/* The values the panel holds, readable without opening it. */
.environment-digest {
    min-width: 0;
    font-size: 13px;
    color: var(--ink-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.environment {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem 1.25rem;
    padding: 6px 2px 10px;
}

.environment-heading {
    font-size: 12px; font-weight: 800;
    letter-spacing: .8px; text-transform: uppercase;
    color: oklch(0.5 0.05 145);
    margin: 0;
}

.field { display: flex; flex-direction: column; gap: .4rem; min-width: 0; }

.field-label {
    font-size: 12px; font-weight: 700;
    letter-spacing: .7px; text-transform: uppercase;
    color: var(--ink-faint);
}

.field-label:empty { display: none; }

.segmented { display: flex; padding: 3px; background: var(--field); border: 1px solid var(--line-strong); border-radius: 12px; }

.segment {
    flex: 1 1 0;
    padding: 8px 6px;
    font-size: 14px;
    background: none; border: none; border-radius: 9px;
    color: var(--ink-soft);
    cursor: pointer; white-space: nowrap;
}

.segment:hover:not(:disabled):not(.is-selected) { color: var(--ink); }
.segment.is-selected { background: var(--card); color: var(--leaf-deep); font-weight: 700; box-shadow: 0 1px 3px oklch(0.5 0.06 145 / .15); }
.segment:disabled { opacity: .5; cursor: not-allowed; }

.temperature { display: flex; flex-direction: column; gap: .55rem; }
.celsius { display: flex; align-items: center; gap: .85rem; }
.celsius input[type="range"] { flex: 1; accent-color: var(--leaf); min-width: 0; }
.celsius-value { flex: 0 0 3.5rem; text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---- provider ------------------------------------------------------------- */

.chips { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.chips-label { font-size: 13px; color: var(--ink-faint); }
.chip { font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 999px; border: 1px solid oklch(0.87 0.03 140); background: var(--card); color: oklch(0.42 0.06 150); cursor: pointer; }
.chip:hover:not(:disabled) { background: var(--leaf-wash); }

/* ---- loading -------------------------------------------------------------- */

.loading { max-width: 520px; margin: 0 auto; padding: 90px 28px; text-align: center; animation: fadeUp .3s ease; }
/* ---- plant loader --------------------------------------------------------- */

/* Paint and motion for PlantLoader.razor. The exported SVG names b-leaf1..3 but ships no
   keyframes, so they are defined here; keeping the designer's names means a corrected re-export
   drops straight in. currentColor is what lets the loader track the palette. */
.plant-loader { display: block; width: 108px; height: 108px; margin: 0 auto 28px; color: var(--leaf); }

.pl-stem, .pl-stalk { fill: none; stroke: currentColor; stroke-linecap: round; }
.pl-stem { stroke-width: 2.6; }
.pl-stalk { stroke-width: 2.4; }

/* 67.18 is the measured length of the stem path, so the dash can hide and reveal it exactly. */
.pl-stem { stroke-dasharray: 67.18; animation: b-stem 2.6s ease-in-out infinite; }

/* Each group's own origin sits where its leaf meets the stem, so scaling about 0 0 unfurls the
   leaf outward. The slight overshoot in the timing function gives the growth a bit of spring. */
.pl-leaf {
    fill: currentColor;
    transform-box: view-box;
    transform-origin: 0 0;
    animation-duration: 2.6s;
    animation-timing-function: cubic-bezier(.34, 1.4, .5, 1);
    animation-iteration-count: infinite;
}

.pl-leaf-1 { animation-name: b-leaf1; }
.pl-leaf-2 { animation-name: b-leaf2; }
.pl-leaf-3 { animation-name: b-leaf3; }

@keyframes b-stem { 0% { stroke-dashoffset: 67.18 } 26%, 82% { stroke-dashoffset: 0 } 100% { stroke-dashoffset: 67.18 } }
@keyframes b-leaf1 { 0%, 10% { opacity: 0; transform: scale(.15) rotate(-12deg) } 30%, 78% { opacity: 1; transform: scale(1) rotate(0) } 92%, 100% { opacity: 0; transform: scale(.85) rotate(5deg) } }
@keyframes b-leaf2 { 0%, 24% { opacity: 0; transform: scale(.15) rotate(12deg) } 44%, 80% { opacity: 1; transform: scale(1) rotate(0) } 93%, 100% { opacity: 0; transform: scale(.85) rotate(-5deg) } }
@keyframes b-leaf3 { 0%, 38% { opacity: 0; transform: scale(.15) rotate(-14deg) } 58%, 84% { opacity: 1; transform: scale(1) rotate(0) } 95%, 100% { opacity: 0; transform: scale(.85) rotate(6deg) } }

/* An infinite grow-and-reset loop is exactly what this setting is for: hold the grown plant. */
@media (prefers-reduced-motion: reduce) {
    .pl-stem, .pl-leaf { animation: none; }
    .pl-stem { stroke-dashoffset: 0; }
    .pl-leaf { opacity: 1; transform: none; }
}
.loading img { width: 120px; height: 120px; object-fit: cover; border-radius: 16px; border: 3px solid var(--card); box-shadow: 0 6px 20px oklch(0.5 0.06 145 / .15); margin-bottom: 24px; }
.loading-step { font-family: var(--serif); font-size: 24px; font-weight: 500; margin-bottom: 10px; }
.loading-note { font-size: 14px; color: var(--ink-faint); margin: 0; }

/* ---- result --------------------------------------------------------------- */

.result { max-width: 1080px; margin: 0 auto; padding: 16px 28px 90px; }

.back { font-size: 14px; font-weight: 600; color: var(--leaf); background: none; border: none; cursor: pointer; padding: 8px 0; margin-bottom: 8px; }
.back:hover { text-decoration: underline; }

.result-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.result-head h1 { font-family: var(--serif); font-size: clamp(1.9rem, 5vw, 42px); font-weight: 500; margin: 0; }
.latin { font-family: var(--serif); font-style: italic; font-size: 19px; color: oklch(0.5 0.03 140); }

.badge { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: var(--badge-bg); color: var(--badge-ink); white-space: nowrap; }
.badge-muted { background: oklch(0.95 0.01 130); color: var(--ink-faint); border: 1px solid var(--line); }

.result-lede { font-size: 16px; line-height: 1.6; color: var(--ink-soft); max-width: 640px; margin: 0 0 32px; text-wrap: pretty; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 28px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 28px; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; }
.panel h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; margin: 0 0 16px; }

.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.gallery figure { margin: 0; position: relative; }
.gallery img { width: 100%; height: 160px; object-fit: cover; border-radius: 14px; display: block; }
.gallery .hero { grid-column: 1 / -1; }
.gallery .hero img { height: 220px; }
.gallery figcaption { font-size: 11px; color: var(--ink-faint); margin-top: 5px; line-height: 1.35; }
.gallery .tag { position: absolute; top: 10px; left: 10px; font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: oklch(0.28 0.03 140 / .75); color: #fff; }

/* The typed-name gallery sits below both columns rather than inside one: it is the answer to
   "is this the plant I meant?", which is worth the full width once the advice has been read. */
.related { margin-top: 28px; }
.related-lede { font-size: 14px; color: var(--ink-faint); margin: -8px 0 16px; }
.gallery-wide { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.gallery-wide img { height: 190px; }
.gallery figcaption a { color: inherit; }
.gallery figcaption a:hover { color: var(--leaf-deep); }

.watering { background: var(--water-bg); border: 1px solid var(--water-line); border-radius: 18px; padding: 22px 24px; }
.watering-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.watering-dot { width: 44px; height: 44px; border-radius: 50%; background: var(--water-dot); display: flex; align-items: center; justify-content: center; font-size: 20px; color: #fff; flex: none; }
.watering-label { font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; color: var(--water-label); }
.watering-title { font-family: var(--serif); font-size: 23px; font-weight: 600; }
.watering p { font-size: 14.5px; line-height: 1.6; margin: 0; color: var(--water-ink); }

.tips { display: flex; flex-direction: column; gap: 13px; }
.tip { display: flex; gap: 11px; align-items: flex-start; }
.tip-mark { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--badge-bg); color: var(--badge-ink); display: flex; align-items: center; justify-content: center; font-size: 12px; margin-top: 1px; }
.tip span:last-child { font-size: 14.5px; line-height: 1.55; color: oklch(0.35 0.03 140); }

.candidates { display: flex; flex-direction: column; }
.candidate { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid oklch(0.94 0.01 130); background: none; border-left: none; border-right: none; border-bottom: none; width: 100%; text-align: left; cursor: pointer; }
.candidate:hover { background: oklch(0.98 0.01 130); }
.candidate img { width: 44px; height: 44px; border-radius: 12px; object-fit: cover; flex: none; }
.candidate-body { flex: 1; min-width: 0; }
.candidate-name { font-size: 15px; font-weight: 700; }
.candidate-latin { font-family: var(--serif); font-style: italic; font-size: 13px; color: var(--ink-faint); }

/* ---- notices -------------------------------------------------------------- */

.notice { border-radius: 14px; padding: 14px 18px; font-size: 14px; border: 1px solid; }
.notice ul { margin: .4rem 0 0; padding-left: 1.15rem; }
.notice-error { background: var(--error-bg); border-color: var(--error-line); color: var(--error-ink); }
.notice-warning { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); margin-top: 16px; }
.stage > .notice { max-width: 680px; margin: 20px auto 0; }

/* ---- camera --------------------------------------------------------------- */

.camera-backdrop { position: fixed; inset: 0; background: oklch(0.2 0.02 140 / .7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.camera { background: var(--card); border-radius: 20px; padding: 20px; width: min(560px, 92vw); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.camera-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.camera-head h2 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 0; }
.camera-close { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--ink-faint); }
.camera-stage { border-radius: 14px; overflow: hidden; background: oklch(0.25 0.02 140); aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; }
.camera-stage p { color: #fff; font-size: 14px; padding: 20px; text-align: center; margin: 0; }
.camera-shoot { width: 100%; margin-top: 16px; font-size: 15px; font-weight: 700; padding: 14px; border: none; border-radius: 12px; background: var(--leaf); color: #fff; cursor: pointer; }
.camera-shoot:hover:not(:disabled) { background: var(--leaf-deep); }
.camera-shoot:disabled { opacity: .5; cursor: not-allowed; }

#blazor-error-ui { position: fixed; inset: auto 0 0 0; display: none; padding: .75rem 1.25rem; background: var(--warn-bg); color: var(--warn-ink); box-shadow: 0 -1px 4px rgb(0 0 0 / .2); }
#blazor-error-ui .dismiss { cursor: pointer; float: right; }
/* The Blazor boot indicator, shown until the runtime takes over #app. An SVG <circle> with no
   fill declared paints solid black, so both circles are given one explicitly — without it the
   two here flash as a black disc over the page while the download starts. */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 0;
}

.loading-progress circle {
    fill: none;
    stroke: var(--leaf-wash);
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

/* blazor.webassembly.js sets --blazor-load-percentage on #app as the payload arrives, so the
   second circle draws over the first as a progress arc. Before the script runs the fallback
   of 0% leaves an empty track rather than anything jarring. */
.loading-progress circle:last-child {
    stroke: var(--leaf);
    stroke-linecap: round;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    margin-top: 1rem;
    text-align: center;
    font-family: var(--sans);
    font-weight: 600;
    color: var(--ink-faint);
}

/* A ~10 MB first load is long enough that a bare spinner reads as a hang. */
.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ---- name suggestions ------------------------------------------------------ */

.ask-field { position: relative; flex: 1 1 16rem; min-width: 0; }
.ask-field .ask-input { width: 100%; }

.suggestions {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    z-index: 20;
    margin: 0; padding: 4px;
    list-style: none;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 30px oklch(0.5 0.06 145 / 0.14);
    max-height: 18rem;
    overflow-y: auto;
}

.suggestion {
    display: flex; align-items: baseline; gap: 12px;
    padding: 9px 12px;
    border-radius: 9px;
    cursor: pointer;
}

.suggestion.is-highlighted { background: var(--leaf-wash); }
.suggestion-name { font-size: 15px; font-weight: 600; min-width: 0; }
.suggestion-known { display: inline-flex; margin-right: 6px; color: var(--leaf); vertical-align: -2px; }
.suggestion-detail { margin-left: auto; font-size: 12.5px; color: var(--ink-faint); text-align: right; white-space: nowrap; }
