/* =========================================================
   Secondary Metabolites Search — styles
   Visual language shared with the PlantData frontend:
   white surfaces, hairline borders, DM Sans, green accent.
   ========================================================= */

:root {
    --background: #ffffff;
    --foreground: #19251e;
    --primary: #203b2b;
    --primary-foreground: #ffffff;
    --secondary: #edf3ee;
    --muted: #f8faf8;
    --muted-foreground: #435247;
    --subtle-foreground: #6b7a70;
    --green: #29a36a;
    --green-soft: #c7ead4;
    --line: #e2e8e3;
    --input: #dde5df;
    --radius: 0.5rem;
    --container: 1400px;
    --header-h: 64px;
    color-scheme: light;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + 24px);
}

body {
    font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    font-optical-sizing: auto;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--foreground);
    background: var(--background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

::selection {
    background: var(--green-soft);
    color: #173922;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

h1, h2, h3, h4 {
    font-weight: 450;
    line-height: 1.15;
}

.icon {
    width: 1em;
    height: 1em;
    flex: none;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: 1rem;
}

@media (min-width: 640px) {
    .container { padding-inline: 2rem; }
}

/* ---------------------------------------------------------
   Header
   --------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header-h);
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid var(--line);
}

@supports (backdrop-filter: blur(8px)) {
    .site-header {
        background: rgba(255, 255, 255, 0.7);
        backdrop-filter: saturate(1.4) blur(12px);
        -webkit-backdrop-filter: saturate(1.4) blur(12px);
    }
}

.header-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
}

.brand-logo {
    height: 58px;
    width: auto;
    flex: none;
}

@media (max-width: 760px) {
    .brand-logo { height: 50px; }
}

.brand-sub {
    font-size: 1rem;
    color: var(--muted-foreground);
    padding-left: 14px;
    border-left: 1px solid var(--line);
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-links a {
    height: 40px;
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    font-weight: 450;
    color: var(--foreground);
    transition: background-color 0.15s, color 0.15s;
}

.nav-links a:hover {
    background: rgba(237, 243, 238, 0.6);
}

.nav-links a.active {
    color: var(--green);
}

.nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 0;
    background: transparent;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 1.5px;
    background: var(--foreground);
    transition: transform 0.2s, opacity 0.2s;
}

.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

@media (max-width: 1000px) {
    .brand-sub { display: none; }
}

@media (max-width: 760px) {
    :root { --header-h: 56px; }

    .nav-toggle { display: inline-flex; }

    /* absolute, not fixed: the header's backdrop-filter becomes the containing block */
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: calc(100vh - var(--header-h));
        height: calc(100dvh - var(--header-h));
        background: var(--background);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 16px;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s, visibility 0.2s;
    }

    .nav-open .nav-links {
        opacity: 1;
        visibility: visible;
    }

    .nav-links a {
        height: 56px;
        font-size: 1.4rem;
        letter-spacing: -0.03em;
        border-radius: 0;
        padding: 0 4px;
    }
}

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */

.pill {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 14px;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    border: 1px solid transparent;
    transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
}

.pill .icon {
    width: 17px;
    height: 17px;
    transition: transform 0.2s;
}

.pill:hover .icon {
    transform: translate(2px, -2px);
}

.pill-primary {
    background: var(--primary);
    color: var(--primary-foreground);
}

.pill-primary:hover {
    opacity: 0.9;
}

.pill-outline {
    background: transparent;
    border-color: var(--line);
    color: var(--foreground);
}

.pill-outline:hover {
    background: var(--muted);
    border-color: var(--green);
}

.pill-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    margin-right: -4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    opacity: 0.9;
}

/* ---------------------------------------------------------
   Search field + autocomplete
   --------------------------------------------------------- */

.search-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 52px;
    padding: 0 4px 0 16px;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: 999px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-field:focus-within {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(41, 163, 106, 0.18);
}

.search-field > .icon {
    width: 18px;
    height: 18px;
    color: var(--subtle-foreground);
}

.search-field.is-loading > .icon {
    color: var(--green);
}

.search-field input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 1rem;
    color: var(--foreground);
}

.search-field input::placeholder {
    color: #8a978e;
}

.search-field input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.search-field .btn {
    height: 42px; /* 52px field - 2px border - 2 x 4px: an even ring around the button */
    border-radius: 999px;
    padding: 0 20px;
}

.ac-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 15;
    list-style: none;
    background: var(--background);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(21, 36, 27, 0.08);
    padding: 6px;
    max-height: 340px;
    overflow-y: auto;
}

.ac-list li a {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 12px;
    border-radius: 6px;
    font-size: 0.925rem;
}

.ac-list li a mark {
    background: transparent;
    color: var(--green);
    font-weight: 600;
}

.ac-list li small {
    flex: none;
    font-size: 0.75rem;
    color: var(--subtle-foreground);
}

.ac-list li.is-active a,
.ac-list li a:hover {
    background: var(--secondary);
}

.ac-list .ac-empty {
    padding: 10px 12px;
    font-size: 0.875rem;
    color: var(--subtle-foreground);
}

/* ---------------------------------------------------------
   Home
   --------------------------------------------------------- */

.home-hero {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    align-items: center;
    gap: clamp(32px, 5vw, 80px);
    min-height: calc(92vh - var(--header-h));
    padding-top: 40px;
    padding-bottom: 60px;
}

.hero-title {
    font-size: clamp(2.7rem, 6vw, 3.6rem);
    font-weight: 450;
    line-height: 1.01;
    letter-spacing: -0.055em;
}

.hero-title span {
    display: block;
}

/* when the hero is stacked (phones), centre the whole text block */
@media (max-width: 720px) {
    .hero-copy {
        text-align: center;
    }

    .hero-title {
        font-size: clamp(3.1rem, 9vw, 3.6rem);
    }

    .hero-copy .hero-description {
        font-size: 1rem;
        line-height: 1.55;
        margin: 20px auto 26px;
    }

    .hero-description,
    .hero-search {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-search .search-field {
        text-align: left;
    }

    .hero-actions {
        justify-content: center;
    }
}

.hero-description {
    max-width: 540px;
    margin: 26px 0 30px;
    font-size: 1.075rem;
    color: var(--muted-foreground);
}

.hero-search {
    max-width: 560px;
}

.hero-actions {
    display: flex;
    flex-wrap: nowrap; /* the two buttons always stay on one line */
    gap: 12px;
    margin-top: 22px;
}

.hero-visual {
    display: flex;
    justify-content: center;
}

.hero-logo {
    width: min(520px, 100%);
    height: auto;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.stat {
    padding: 34px 24px 40px;
    border-left: 1px solid var(--line);
    text-align: center;
}

.stat:first-child {
    border-left: 0;
}

.stat-value {
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    font-weight: 450;
    letter-spacing: -0.055em;
    line-height: 1;
}

.stat-label {
    margin-top: 10px;
    font-size: 0.875rem;
    color: var(--subtle-foreground);
}

.home-section {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    gap: clamp(32px, 6vw, 90px);
    padding-top: 95px;
    padding-bottom: 95px;
    border-top: 1px solid var(--line);
}

.stats + .home-section {
    border-top: 0;
}

.home-section.stacked {
    grid-template-columns: 1fr;
    gap: 40px;
}

.section-copy h2,
.section-head h2 {
    font-size: clamp(1.5rem, 2.4vw, 2rem);
    letter-spacing: -0.03em;
    margin-bottom: 22px;
}

.section-head h2 {
    margin-bottom: 0;
}

.section-copy p {
    max-width: 520px;
    color: var(--muted-foreground);
    margin-bottom: 28px;
}

.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}

.entry-list,
.result-list {
    border-top: 1px solid var(--line);
}

.entry,
.result-row {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 26px 4px;
    border-bottom: 1px solid var(--line);
    transition: background-color 0.15s;
}

.entry:hover,
.result-row:hover {
    background: var(--muted);
}

.entry-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--green);
    font-size: 22px;
    transition: border-color 0.15s;
}

.entry:hover .entry-icon {
    border-color: var(--green);
}

.entry-text,
.result-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.entry-title {
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.entry-desc {
    color: var(--muted-foreground);
    font-size: 0.95rem;
}

.entry-arrow {
    color: var(--subtle-foreground);
    font-size: 20px;
    display: inline-flex;
    transition: transform 0.2s, color 0.2s;
}

.entry:hover .entry-arrow,
.result-row:hover .entry-arrow {
    color: var(--green);
    transform: translate(2px, -2px);
}

.prose p {
    color: var(--muted-foreground);
    font-size: 1.05rem;
    margin-bottom: 20px;
    max-width: 680px;
}

.prose p:last-of-type {
    margin-bottom: 28px;
}

/* medium screens: keep text and logo side by side, just tighter */
@media (max-width: 1000px) {
    .home-hero {
        min-height: 0;
        padding-top: 56px;
        padding-bottom: 64px;
        gap: 32px;
    }
}

/* phones: stack text, then logo */
@media (max-width: 720px) {
    .home-hero {
        grid-template-columns: 1fr;
        padding-top: 48px;
    }

    .hero-logo {
        width: min(340px, 78vw);
    }
}

@media (max-width: 1000px) {
    .home-section {
        grid-template-columns: 1fr;
        padding-top: 64px;
        padding-bottom: 64px;
    }


}

@media (max-width: 480px) {
    .stat {
        padding: 24px 14px 28px;
    }

    .entry {
        gap: 16px;
        padding: 20px 2px;
    }

    .entry-icon {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

/* ---------------------------------------------------------
   Inner page layout
   --------------------------------------------------------- */

.site-main {
    flex: 1;
    padding-bottom: 96px;
}

.site-main.home {
    padding-bottom: 0;
}

.grid-container,
.grid-container2,
.grid-container-mono-centered {
    width: 100%;
    margin-inline: auto;
    padding-inline: 1rem;
    display: grid;
}

@media (min-width: 640px) {
    .grid-container,
    .grid-container2,
    .grid-container-mono-centered {
        padding-inline: 2rem;
    }
}

/* compound and class pages: content + sticky "on this page" */
.grid-container {
    max-width: var(--container);
    grid-template-columns: minmax(0, 1fr) 240px;
    grid-template-areas: "title title" "main menu";
    column-gap: clamp(32px, 5vw, 80px);
}

/* plant pages */
.grid-container2 {
    max-width: var(--container);
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "title" "main";
}

/* search, results, info */
.grid-container-mono-centered {
    max-width: 1000px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "title" "main";
}

@media (max-width: 1000px) {
    .grid-container {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "title" "menu" "main";
    }
}

.title-grid {
    grid-area: title;
}

.top-tite-container {
    padding: 48px 0 28px;
}

.top-tite-container h1 {
    font-size: clamp(1.75rem, 3vw, 2.4rem);
    font-weight: 450;
    line-height: 1.15;
    letter-spacing: -0.03em;
    overflow-wrap: anywhere;
}

/* long compound names */
.top-tite-container h1.title-long {
    font-size: clamp(1.4rem, 2.2vw, 1.9rem);
}

.top-tite-container h1.title-xlong {
    font-size: clamp(1.15rem, 1.6vw, 1.45rem);
    line-height: 1.3;
}

.page-intro {
    max-width: 660px;
    margin-top: 20px;
    font-size: 1.05rem;
    color: var(--muted-foreground);
}

.page-intro a,
.search-panel a:not(.pill),
.empty-state a,
.prose a:not(.pill) {
    color: var(--green);
    text-decoration: underline;
    text-decoration-color: rgba(41, 163, 106, 0.35);
    text-underline-offset: 3px;
}

.page-intro a:hover,
.empty-state a:hover {
    text-decoration-color: var(--green);
}

.main-grid {
    grid-area: main;
    min-width: 0;
}

/* "On this page" */
.nav-menu-grid {
    grid-area: menu;
}

.nav-menu-container {
    position: sticky;
    top: calc(var(--header-h) + 32px);
    padding-top: 28px;
}

.nav-menu-container h2 {
    font-size: 0.9rem;
    font-weight: 550;
    color: var(--foreground);
    margin-bottom: 12px;
}

.menu-list {
    list-style: none;
    border-left: 1px solid var(--line);
}

.menu-list li a {
    display: block;
    padding: 6px 0 6px 16px;
    margin-left: -1px;
    border-left: 1px solid transparent;
    font-size: 0.9rem;
    color: var(--muted-foreground);
    transition: color 0.15s, border-color 0.15s;
}

.menu-list li a:hover {
    color: var(--green);
}

/* section currently in view (set by app.js) */
.menu-list li a.is-active {
    color: var(--green);
    border-left-color: var(--green);
    font-weight: 500;
}

@media (max-width: 1000px) {
    .nav-menu-container {
        position: static;
        padding-top: 20px;
        margin-bottom: 8px;
    }

    .menu-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        border-left: 0;
    }


    .menu-list li a {
        padding: 6px 14px;
        margin: 0;
        border: 1px solid var(--line);
        border-radius: 999px;
        font-size: 0.85rem;
    }

    .menu-list li a:hover,
    .menu-list li a.is-active {
        border-color: var(--green);
    }
}

a.anchor {
    display: block;
    position: relative;
    top: calc(-1 * var(--header-h) - 24px);
    visibility: hidden;
}

/* ---------------------------------------------------------
   Content sections (compound / class / plant pages)
   --------------------------------------------------------- */

.id-box,
.structure-box,
.chem-info-box,
.classification-box,
.plant-with-compound-box {
    position: relative;
    padding: 40px 0 48px;
    background: transparent;
}

.box-title h2,
.box-title-1 h2 {
    font-size: 1.35rem;
    letter-spacing: -0.025em;
    margin-bottom: 26px;
    padding-right: 48px;
}

.box-subtitle,
.box-subtitle h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--foreground);
}

.text-box,
.text-box-1 {
    margin: 6px 0 22px;
    font-size: 1rem;
}

.costrained-box {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.85rem;
    word-break: break-all;
    padding: 12px 14px;
    background: var(--muted);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.list-link,
.tab-link {
    color: var(--primary);
    text-decoration: underline;
    text-decoration-color: #b9cfc1;
    text-underline-offset: 3px;
    transition: color 0.15s, text-decoration-color 0.15s;
}

.list-link:hover,
.tab-link:hover {
    color: var(--green);
    text-decoration-color: var(--green);
}

/* class page lists: multi-column link lists */
.chem-info-box:has(.list-link) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    column-gap: 32px;
}

.chem-info-box:has(.list-link) .box-title {
    grid-column: 1 / -1;
}

.chem-info-box:has(.list-link) .text-box {
    margin: 0;
    padding: 10px 0;
}

.chem-info-box:has(.list-link) .list-link {
    text-decoration: none;
}

/* structure */
.smile-structure-container {
    display: grid;
    grid-template-columns: 340px 1fr;
    grid-template-areas: "twod slink";
    gap: 32px;
    align-items: center;
}

.bidimensional-structure {
    grid-area: twod;
}

.structure-image-box {
    width: 340px;
    height: 340px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.link-structure {
    grid-area: slink;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.link-structure .button {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 22px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, border-color 0.15s;
}

.link-structure .button:hover {
    background: var(--muted);
    border-color: var(--green);
}

@media (max-width: 640px) {
    .smile-structure-container {
        grid-template-columns: 1fr;
        grid-template-areas: "twod" "slink";
    }

    .structure-image-box {
        width: 100%;
        max-width: 340px;
    }

    .link-structure {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* classification */
.classification-container {
    display: grid;
    grid-template-columns: 160px 1fr;
    grid-template-areas:
        "k kdesc"
        "sp spdesc"
        "c cdesc"
        "sb sbdesc"
        "lvf lvfdesc"
        "lvs lvsdesc";
}

.kingdom { grid-area: k; }
.kingdom-desc { grid-area: kdesc; }
.superclass { grid-area: sp; }
.superclass-desc { grid-area: spdesc; }
.class { grid-area: c; }
.class-desc { grid-area: cdesc; }
.subclass { grid-area: sb; }
.subclass-desc { grid-area: sbdesc; }
.level-five { grid-area: lvf; }
.level-five-desc { grid-area: lvfdesc; }
.level-six { grid-area: lvs; }
.level-six-desc { grid-area: lvsdesc; }

.kingdom, .superclass, .class, .subclass, .level-five, .level-six,
.kingdom-desc, .superclass-desc, .class-desc, .subclass-desc, .level-five-desc, .level-six-desc {
    padding: 8px 0;
    display: flex;
    align-items: center;
}

.classification-container .text-box {
    margin: 0;
}

@media (max-width: 640px) {
    .classification-container {
        grid-template-columns: 1fr;
        grid-template-areas: "k" "kdesc" "sp" "spdesc" "c" "cdesc" "sb" "sbdesc" "lvf" "lvfdesc" "lvs" "lvsdesc";
    }

    .kingdom, .superclass, .class, .subclass, .level-five, .level-six {
        border-bottom: 0;
        padding-bottom: 0;
    }

    .kingdom-desc, .superclass-desc, .class-desc, .subclass-desc, .level-five-desc, .level-six-desc {
        padding-top: 2px;
    }
}

/* ---------------------------------------------------------
   Tables
   --------------------------------------------------------- */

.table-container {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th, td {
    text-align: left;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    height: 42px;
    background: var(--muted);
    font-weight: 500;
    color: var(--muted-foreground);
    white-space: nowrap;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: 0;
}

tr:hover td {
    background: rgba(248, 250, 248, 0.8);
}

td {
    max-width: 550px;
    min-width: 140px;
}

td:first-child {
    min-width: 200px;
}

.th-clickable {
    cursor: pointer;
    user-select: none;
}

.th-clickable::after {
    content: "↕";
    margin-left: 6px;
    font-size: 0.75rem;
    opacity: 0.4;
}

.th-clickable:hover {
    color: var(--green);
}

.reference-container,
.reference-box {
    min-width: 420px;
    color: var(--muted-foreground);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* fullscreen table */
.modal-btn {
    position: absolute;
    top: 42px;
    right: 0;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--background) url("images/fullscreen.png") center / 16px no-repeat;
    cursor: pointer;
    transition: border-color 0.15s;
}

.modal-btn:hover {
    border-color: var(--green);
    background-image: url("images/fullscreen_green.png");
}

@media (max-width: 1000px) {
    .modal-btn { display: none; }
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    overflow: auto;
    background: rgba(25, 37, 30, 0.35);
    backdrop-filter: blur(3px);
}

.modal-content {
    position: relative;
    margin: 32px;
    padding: 56px 24px 24px;
    background: var(--background);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.close,
.close2 {
    position: absolute;
    top: 12px;
    right: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 26px;
    line-height: 1;
    color: var(--muted-foreground);
    cursor: pointer;
}

.close:hover,
.close2:hover {
    background: var(--secondary);
    color: var(--foreground);
}

/* ---------------------------------------------------------
   Plant page
   --------------------------------------------------------- */

.plant-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    gap: clamp(32px, 5vw, 80px);
    align-items: center;
    padding: 56px 0 64px;
}

.plant-hero h1 {
    font-size: clamp(1.75rem, 3vw, 2.4rem);
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.plant-hero h1 i {
    font-weight: 450;
}

.plant-hero-meta {
    margin-top: 18px;
    color: var(--muted-foreground);
    font-size: 1.05rem;
}

.plant-hero .hero-actions {
    margin-top: 30px;
}

.plant-hero-figure figcaption {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--subtle-foreground);
    text-align: center;
    text-wrap: balance;
}

.img-box {
    aspect-ratio: 4 / 3;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--muted);
}

.img-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
    transition: transform 0.4s;
}

.img-box img:hover {
    transform: scale(1.02);
}

.img-box-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #9fb5a7;
    font-size: 0.875rem;
}

.img-box-empty .icon {
    width: 36px;
    height: 36px;
}

.modal2 {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: rgba(25, 37, 30, 0.82);
}

.modal-content2 {
    position: relative;
    max-width: 100%;
    max-height: 100%;
}

.modal-content2 img {
    max-width: 100%;
    max-height: calc(100vh - 64px);
    border-radius: 8px;
}

.modal-content2 .close2 {
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
}

@media (max-width: 800px) {
    .plant-hero {
        grid-template-columns: 1fr;
        gap: 24px;
        padding-top: 32px;
    }

    .plant-hero-figure {
        max-width: 420px;
    }
}

/* ---------------------------------------------------------
   Plants list
   --------------------------------------------------------- */

.filter-bar {
    position: sticky;
    top: var(--header-h);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 0;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.filter-bar .search-field {
    flex: 1;
    max-width: 560px;
}

.filter-count {
    font-size: 0.875rem;
    color: var(--subtle-foreground);
    white-space: nowrap;
}

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--muted-foreground);
    border: 1px dashed var(--line);
    border-radius: 12px;
}

/* ---------------------------------------------------------
   Search page
   --------------------------------------------------------- */

.search-panel {
    padding: 32px 0 48px;
}

.segmented {
    display: inline-flex;
    padding: 4px;
    margin-bottom: 20px;
    background: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.segmented button {
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 18px;
    border-radius: 999px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.segmented button.is-active {
    background: var(--background);
    color: var(--foreground);
    box-shadow: 0 0 0 1px var(--line);
}

.search-hint {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--subtle-foreground);
}

.browse-section {
    padding-top: 40px;
}

.browse-section h2 {
    font-size: 1.35rem;
    letter-spacing: -0.025em;
    margin-bottom: 20px;
}

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

.chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 0.9rem;
    transition: border-color 0.15s, background-color 0.15s;
}

.chip span {
    font-size: 0.75rem;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--secondary);
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

.chip:hover {
    border-color: var(--green);
    background: var(--muted);
}

/* results */
.result-group {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 1.25rem;
    letter-spacing: -0.04em;
    margin: 40px 0 16px;
}

.result-group:first-child {
    margin-top: 0;
}

.result-group span {
    font-size: 0.875rem;
    letter-spacing: 0;
    color: var(--subtle-foreground);
}

.result-row {
    padding: 18px 4px;
}

.result-title {
    font-size: 1.05rem;
    font-weight: 500;
}

.result-sub {
    font-size: 0.85rem;
    color: var(--subtle-foreground);
}

/* ---------------------------------------------------------
   Footer
   --------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--line);
    background: rgba(248, 250, 248, 0.6);
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 4fr 2fr;
    gap: 48px;
    padding-top: 56px;
    padding-bottom: 48px;
}

.footer-logo {
    width: 150px;
    height: auto;
}

.footer-brand p {
    max-width: 380px;
    margin-top: 16px;
}

.footer-col h4 {
    font-size: 0.9rem;
    font-weight: 550;
    color: var(--foreground);
    margin-bottom: 14px;
}

.footer-col ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-col a:hover {
    color: var(--green);
}

.footer-bottom {
    padding-top: 20px;
    padding-bottom: 28px;
    font-size: 0.8rem;
}

@media (max-width: 760px) {
    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    .footer-brand {
        grid-column: 1 / -1;
    }
}

/* ---------------------------------------------------------
   Structure / photo thumbnails and source credits
   --------------------------------------------------------- */

.result-thumb {
    width: 76px;
    height: 76px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(1.15);
}

.result-thumb img[src*="media/plants/"] {
    object-fit: cover;
    transform: none;
}

.result-thumb.is-icon {
    background: var(--muted);
    color: #9fb5a7;
    font-size: 22px;
}

.ac-list li a {
    align-items: center;
}

.search-panel .ac-list a {
    color: inherit;
    text-decoration: none;
}

.ac-thumb {
    width: 44px;
    height: 44px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
}

.ac-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(1.2);
}

.ac-thumb img[src*="media/plants/"] {
    object-fit: cover;
    transform: none;
}

.ac-label {
    flex: 1;
    min-width: 0;
}

.structure-image-box img {
    width: 300px;
    height: 300px;
    object-fit: contain;
}

.structure-missing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #9fb5a7;
    font-size: 0.875rem;
}

.structure-missing .icon {
    width: 36px;
    height: 36px;
}

.link-structure .button {
    gap: 12px;
}

.link-structure .button .icon {
    width: 15px;
    height: 15px;
}

.source-note {
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--subtle-foreground);
}

.source-note a {
    text-decoration: underline;
    text-decoration-color: var(--line);
    text-underline-offset: 2px;
}

.source-note a:hover {
    color: var(--green);
}

.classification-box .source-note {
    margin-top: 16px;
}

.source-list {
    list-style: none;
    margin-bottom: 24px;
}

.source-list li {
    padding: 18px 0;
    color: var(--muted-foreground);
}

.source-list strong {
    font-weight: 550;
    color: var(--foreground);
}

.source-list cite {
    display: block;
    margin-top: 6px;
    font-style: normal;
    font-size: 0.875rem;
    color: var(--subtle-foreground);
}


@media (max-width: 480px) {
    .result-thumb {
        width: 52px;
        height: 52px;
    }
}

/* ---------------------------------------------------------
   Load-on-scroll
   --------------------------------------------------------- */

.list-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 32px 0;
    font-size: 0.875rem;
    color: var(--subtle-foreground);
}

.list-loader[hidden] {
    display: none;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--secondary);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.result-list.is-refreshing {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.count-badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 6px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--secondary);
    color: var(--muted-foreground);
    font-size: 0.85rem;
    letter-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.browse-section .result-list {
    margin-top: 4px;
}

/* ---------------------------------------------------------
   Compound structure: 2D drawing + 3D model side by side
   --------------------------------------------------------- */

.smile-structure-container {
    grid-template-columns: repeat(2, minmax(0, 340px));
    grid-template-areas: none;
    align-items: start;
}

.structure-panel figcaption {
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--foreground);
    text-align: center;
}

.structure-3d-box {
    position: relative;
    padding: 0;
}

.viewer-3d {
    position: absolute;
    inset: 0;
    cursor: grab;
}

.viewer-3d:active {
    cursor: grabbing;
}

.viewer-hint {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 8px;
    text-align: center;
    font-size: 0.75rem;
    color: var(--subtle-foreground);
    pointer-events: none;
}

.structure-box > .source-note {
    margin-top: 18px;
}

@media (max-width: 640px) {
    .smile-structure-container {
        grid-template-columns: minmax(0, 340px);
        justify-content: center;
    }

    .structure-image-box {
        width: 100%;
        max-width: 340px;
        height: auto;
        aspect-ratio: 1;
    }
}

/* hero buttons: compact wherever the hero text column is narrow, so they never wrap */
@media (max-width: 1000px) {
    .hero-actions {
        gap: 8px;
    }

    .hero-actions .pill {
        padding: 10px 14px;
        gap: 8px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .hero-actions .pill .icon {
        width: 15px;
        height: 15px;
    }
}

@media (max-width: 360px) {
    .hero-actions .pill .icon {
        display: none;
    }
}
