/*
 * Forest sections — shared structure for the wsf-* blocks rendered by
 * resources/views/website/forest/. Every template uses this file; a template restyles
 * the blocks by overriding the custom properties below (and, where it wants a different
 * layout, the rules themselves) in its own stylesheet.
 */

/* Both languages are in the markup (wsText helper); the root's data-lang picks one. */
.ws-np { display: none; }
[data-lang="np"] .ws-np { display: inline; }
[data-lang="np"] .ws-en { display: none; }

#ws-root .wsf {
    --wsf-ink: #1c2b22;
    --wsf-muted: #5b6b61;
    --wsf-line: rgba(28, 43, 34, 0.14);
    --wsf-surface: #ffffff;
    --wsf-tint: color-mix(in srgb, var(--ws-primary, #2f6b3f) 9%, #ffffff);
    --wsf-accent: var(--ws-primary, #2f6b3f);
    --wsf-accent-ink: #ffffff;
    --wsf-radius: 12px;
    --wsf-display: inherit;
    --wsf-seg-1: var(--ws-primary, #2f6b3f);
    --wsf-seg-2: var(--ws-accent, #d99a1c);
    --wsf-seg-3: color-mix(in srgb, var(--ws-primary, #2f6b3f) 45%, #ffffff);
    --wsf-seg-4: color-mix(in srgb, var(--ws-accent, #d99a1c) 45%, #ffffff);

    color: var(--wsf-ink);
    display: grid;
    gap: clamp(1.75rem, 4vw, 3rem);
}

#ws-root.ws-dark .wsf {
    --wsf-ink: #e6ece7;
    --wsf-muted: #9fb0a5;
    --wsf-line: rgba(230, 236, 231, 0.16);
    --wsf-surface: #18241d;
    --wsf-tint: color-mix(in srgb, var(--ws-primary, #2f6b3f) 22%, #101913);
}

#ws-root .wsf-lede {
    font-family: var(--wsf-display);
    font-size: clamp(1.15rem, 2.4vw, 1.5rem);
    color: var(--wsf-accent);
    font-weight: 600;
}

#ws-root .wsf-empty {
    padding: 2.5rem 1.5rem;
    border: 1.5px dashed var(--wsf-line);
    border-radius: var(--wsf-radius);
    color: var(--wsf-muted);
    text-align: center;
}

/* ── Figures ─────────────────────────────────────────────────────────── */
#ws-root .wsf-figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
    gap: 0;
    margin: 0;
    border-top: 1px solid var(--wsf-line);
    border-left: 1px solid var(--wsf-line);
}
#ws-root .wsf-figure {
    padding: 1.1rem 1.25rem 1.25rem;
    border-right: 1px solid var(--wsf-line);
    border-bottom: 1px solid var(--wsf-line);
    background: var(--wsf-surface);
}
#ws-root .wsf-figure dt {
    font-size: 0.875rem;
    color: var(--wsf-muted);
}
#ws-root .wsf-figure dd {
    margin: 0.25rem 0 0;
    font-family: var(--wsf-display);
    font-size: clamp(1.75rem, 4.5vw, 2.5rem);
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
#ws-root .wsf-figure dd small {
    font-size: 0.4em;
    font-weight: 600;
    color: var(--wsf-muted);
}

/* ── Blocks ──────────────────────────────────────────────────────────── */
#ws-root .wsf-block { min-width: 0; }
#ws-root .wsf-block__title {
    font-family: var(--wsf-display);
    font-size: clamp(1.2rem, 2.6vw, 1.55rem);
    font-weight: 700;
    line-height: 1.25;
    margin: 0 0 1rem;
}

/* ── Proportion bars ─────────────────────────────────────────────────── */
#ws-root .wsf-splits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
    gap: 1.5rem 2rem;
}
#ws-root .wsf-splits:empty { display: none; }
#ws-root .wsf-split__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.6rem;
}
#ws-root .wsf-split__bar {
    display: flex;
    gap: 3px;
    height: 0.9rem;
    border-radius: 999px;
    overflow: hidden;
}
#ws-root .wsf-seg { display: block; min-width: 4px; }
#ws-root .wsf-seg--1 { background: var(--wsf-seg-1); }
#ws-root .wsf-seg--2 { background: var(--wsf-seg-2); }
#ws-root .wsf-seg--3 { background: var(--wsf-seg-3); }
#ws-root .wsf-seg--4 { background: var(--wsf-seg-4); }
#ws-root .wsf-split__legend {
    display: grid;
    gap: 0.35rem;
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
}
#ws-root .wsf-split__legend li {
    display: grid;
    grid-template-columns: auto 1fr auto 3.2rem;
    align-items: center;
    gap: 0.5rem;
}
#ws-root .wsf-split__legend i {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 3px;
}
#ws-root .wsf-split__legend b { font-variant-numeric: tabular-nums; }
#ws-root .wsf-split__legend em {
    font-style: normal;
    color: var(--wsf-muted);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Tables ──────────────────────────────────────────────────────────── */
#ws-root .wsf-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--wsf-line);
    border-radius: var(--wsf-radius);
    background: var(--wsf-surface);
    -webkit-overflow-scrolling: touch;
}
#ws-root .wsf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
#ws-root .wsf-table th,
#ws-root .wsf-table td {
    padding: 0.7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--wsf-line);
    vertical-align: top;
}
#ws-root .wsf-table th {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--wsf-muted);
    background: var(--wsf-tint);
    white-space: nowrap;
}
#ws-root .wsf-table tbody tr:last-child td { border-bottom: 0; }
#ws-root .wsf-table .wsf-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ── Boundaries ──────────────────────────────────────────────────────── */
#ws-root .wsf-compass {
    display: grid;
    grid-template-columns: 1fr minmax(8rem, 1.1fr) 1fr;
    grid-template-areas:
        ". north ."
        "west core east"
        ". south .";
    gap: 0.75rem;
    max-width: 44rem;
}
#ws-root .wsf-compass__side {
    display: grid;
    gap: 0.15rem;
    align-content: center;
    padding: 0.85rem 1rem;
    border: 1px solid var(--wsf-line);
    border-radius: var(--wsf-radius);
    background: var(--wsf-surface);
    text-align: center;
    min-width: 0;
}
#ws-root .wsf-compass__side--north { grid-area: north; }
#ws-root .wsf-compass__side--east  { grid-area: east; }
#ws-root .wsf-compass__side--south { grid-area: south; }
#ws-root .wsf-compass__side--west  { grid-area: west; }
#ws-root .wsf-compass__dir {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--wsf-accent);
}
#ws-root .wsf-compass__land {
    font-weight: 600;
    overflow-wrap: anywhere;
}
#ws-root .wsf-compass__core {
    grid-area: core;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.35rem;
    padding: 1.25rem 0.75rem;
    border-radius: var(--wsf-radius);
    background: var(--wsf-accent);
    color: var(--wsf-accent-ink);
    text-align: center;
}
#ws-root .wsf-compass__core svg { width: 2.5rem; height: 2.5rem; opacity: 0.9; }
#ws-root .wsf-compass__core strong { font-family: var(--wsf-display); font-size: 1.05rem; }

/* ── Activities ──────────────────────────────────────────────────────── */
#ws-root .wsf-activities {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
#ws-root .wsf-activity {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "icon title"
        "icon blurb"
        "icon count";
    column-gap: 0.9rem;
    row-gap: 0.2rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--wsf-line);
    border-radius: var(--wsf-radius);
    background: var(--wsf-surface);
}
#ws-root .wsf-activity__icon {
    grid-area: icon;
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: var(--wsf-tint);
    color: var(--wsf-accent);
}
#ws-root .wsf-activity__icon svg { width: 1.5rem; height: 1.5rem; }
#ws-root .wsf-activity h3 {
    grid-area: title;
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0;
}
#ws-root .wsf-activity p {
    grid-area: blurb;
    margin: 0;
    font-size: 0.9rem;
    color: var(--wsf-muted);
}
#ws-root .wsf-activity__count {
    grid-area: count;
    margin-top: 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--wsf-accent);
}

/* ── Rates ───────────────────────────────────────────────────────────── */
#ws-root .wsf-rates {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
    gap: 0 2.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
#ws-root .wsf-rate {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0;
    border-bottom: 1px dashed var(--wsf-line);
}
#ws-root .wsf-rate__what { display: grid; min-width: 0; }
#ws-root .wsf-rate__what strong { font-weight: 600; overflow-wrap: anywhere; }
#ws-root .wsf-rate__what small { color: var(--wsf-muted); font-size: 0.85rem; }
#ws-root .wsf-rate__price {
    font-family: var(--wsf-display);
    font-weight: 700;
    font-size: 1.1rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
#ws-root .wsf-note {
    margin: 0;
    font-size: 0.9rem;
    color: var(--wsf-muted);
    max-width: 60ch;
}

/* ── Offices and factories ───────────────────────────────────────────── */
#ws-root .wsf-places {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
#ws-root .wsf-place {
    display: grid;
    gap: 0.3rem;
    align-content: start;
    justify-items: start;
    padding: 1rem 1.1rem;
    border: 1px solid var(--wsf-line);
    border-radius: var(--wsf-radius);
    background: var(--wsf-surface);
    min-width: 0;
}
#ws-root .wsf-place h3 { font-size: 1.05rem; font-weight: 700; margin: 0; overflow-wrap: anywhere; }
#ws-root .wsf-place p { margin: 0; color: var(--wsf-muted); font-size: 0.92rem; }
#ws-root .wsf-place a {
    color: var(--wsf-accent);
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    overflow-wrap: anywhere;
}
#ws-root .wsf-tag {
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    background: var(--wsf-tint);
    color: var(--wsf-accent);
}

#ws-root .wsf-next { margin: 0; }
#ws-root .wsf-next a {
    display: inline-block;
    padding: 0.65rem 1.2rem;
    border-radius: 999px;
    background: var(--wsf-accent);
    color: var(--wsf-accent-ink);
    font-weight: 600;
}
#ws-root .wsf-next a:hover { filter: brightness(0.92); }
#ws-root .wsf a:focus-visible { outline: 2px solid var(--wsf-accent); outline-offset: 3px; }

/* ── Small screens ───────────────────────────────────────────────────── */
@media (max-width: 34rem) {
    #ws-root .wsf-compass {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "core core"
            "north east"
            "south west";
    }
    #ws-root .wsf-table th,
    #ws-root .wsf-table td { padding: 0.6rem 0.75rem; }
}

/* ── Fallback page chrome (templates without their own forest page) ──── */
#ws-root .wsf-page__head {
    background: var(--ws-primary-dark, #1f3d2b);
    color: #ffffff;
    padding: clamp(2rem, 6vw, 3.5rem) 1rem;
}
#ws-root .wsf-page__inner {
    max-width: var(--ws-container, 1400px);
    margin: 0 auto;
    padding: 0 clamp(0rem, 2vw, 1.5rem);
}
#ws-root .wsf-page__head h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    line-height: 1.15;
}
#ws-root .wsf-page__head p { margin-top: 0.5rem; max-width: 60ch; color: rgba(255, 255, 255, 0.8); }
#ws-root .wsf-page__crumbs { font-size: 0.875rem; color: rgba(255, 255, 255, 0.7); margin-bottom: 0.75rem; }
#ws-root .wsf-page__crumbs a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
#ws-root .wsf-page__body { padding: clamp(1.5rem, 5vw, 3rem) 1rem clamp(2.5rem, 7vw, 4.5rem); }
#ws-root .wsf-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
    scrollbar-width: thin;
}
#ws-root .wsf-tabs a {
    flex: none;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(28, 43, 34, 0.18);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    color: inherit;
    background: #ffffff;
}
#ws-root .wsf-tabs a[aria-current="page"] {
    background: var(--ws-primary, #2f6b3f);
    border-color: var(--ws-primary, #2f6b3f);
    color: #ffffff;
}
#ws-root.ws-dark .wsf-tabs a:not([aria-current="page"]) {
    background: #18241d;
    border-color: rgba(230, 236, 231, 0.18);
    color: #e6ece7;
}

/* ── Home block for the general templates ────────────────────────────── */
#ws-root .wsf-home {
    padding: clamp(2rem, 6vw, 3.5rem) 1rem;
    background: color-mix(in srgb, var(--ws-primary, #2f6b3f) 6%, #ffffff);
}
#ws-root.ws-dark .wsf-home { background: #101913; }
#ws-root .wsf-home__title {
    font-size: clamp(1.4rem, 3.5vw, 1.9rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1.25rem;
    color: var(--wsf-ink, #1c2b22);
}
#ws-root .wsf-home__links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1.5rem;
}
#ws-root .wsf-home__links a {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--ws-primary, #2f6b3f);
    color: var(--ws-primary, #2f6b3f);
    font-size: 0.9rem;
    font-weight: 600;
    background: transparent;
}
#ws-root .wsf-home__links a:hover {
    background: var(--ws-primary, #2f6b3f);
    color: #ffffff;
}
#ws-root.ws-dark .wsf-home__links a {
    border-color: color-mix(in srgb, var(--ws-primary, #2f6b3f) 60%, #ffffff);
    color: color-mix(in srgb, var(--ws-primary, #2f6b3f) 45%, #ffffff);
}

/* ── Paged tables (partials/pager-data + partials/pager) ─────────────── */
#ws-root .wsf-paged { min-width: 0; }
#ws-root .wsf-paged .wsf-table-wrap { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
#ws-root .wsf-paged .wsf-table-wrap:last-child { border-radius: var(--wsf-radius); }
#ws-root .wsf-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    padding: 0.7rem 1rem;
    border: 1px solid var(--wsf-line);
    border-top: 0;
    border-radius: 0 0 var(--wsf-radius) var(--wsf-radius);
    background: var(--wsf-surface);
    font-size: 0.9rem;
    color: var(--wsf-muted);
}
#ws-root .wsf-pager__info { margin: 0; font-variant-numeric: tabular-nums; }
#ws-root .wsf-pager__nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
#ws-root .wsf-pager__slot { display: inline-flex; }
#ws-root .wsf-pager__btn,
#ws-root .wsf-pager__num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    height: 2.25rem;
    padding: 0 0.5rem;
    border: 1px solid var(--wsf-line);
    border-radius: calc(var(--wsf-radius) * 0.6);
    background: var(--wsf-surface);
    color: var(--wsf-ink);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
}
#ws-root .wsf-pager__btn svg { width: 1.1rem; height: 1.1rem; }
#ws-root .wsf-pager__btn:hover:not(:disabled),
#ws-root .wsf-pager__num:hover { border-color: var(--wsf-accent); }
#ws-root .wsf-pager__btn:disabled { opacity: 0.4; cursor: default; }
#ws-root .wsf-pager__num.is-current {
    background: var(--wsf-accent);
    border-color: var(--wsf-accent);
    color: var(--wsf-accent-ink);
}
#ws-root .wsf-pager__gap { padding: 0 0.25rem; color: var(--wsf-muted); }

/* ── Home-page section tabs (partials/tabs-data + partials/tabs-panel) ── */
#ws-root .wsf-home__links a.is-on {
    background: var(--ws-primary, #2f6b3f);
    border-color: var(--ws-primary, #2f6b3f);
    color: #ffffff;
}
#ws-root .wsf-tabs-panel { margin-top: clamp(1.25rem, 3vw, 2rem); min-width: 0; }
#ws-root .wsf-tabs-panel__skeleton { display: grid; gap: 0.75rem; }
#ws-root .wsf-tabs-panel__skeleton span {
    display: block;
    height: 1.1rem;
    border-radius: 999px;
    background: var(--wsf-line, rgba(28, 43, 34, 0.14));
    animation: wsf-pulse 1.4s ease-in-out infinite;
}
#ws-root .wsf-tabs-panel__skeleton span:nth-child(1) { width: 40%; height: 1.6rem; }
#ws-root .wsf-tabs-panel__skeleton span:nth-child(2) { width: 90%; }
#ws-root .wsf-tabs-panel__skeleton span:nth-child(3) { width: 70%; }
@keyframes wsf-pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
#ws-root .wsf-tabs-panel__failed {
    margin: 0;
    padding: 1rem 1.25rem;
    border: 1px dashed var(--wsf-line, rgba(28, 43, 34, 0.14));
    border-radius: var(--wsf-radius, 12px);
    color: var(--wsf-muted, #5b6b61);
}
#ws-root .wsf-tabs-panel__failed button {
    margin-left: 0.5rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--ws-primary, #2f6b3f);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
#ws-root .wsf-tabs-panel__body > .wsf { margin-top: 0; }
#ws-root .wsf-tabs-panel__more { margin: 1.25rem 0 0; font-size: 0.95rem; }
#ws-root .wsf-tabs-panel__more a {
    color: var(--ws-primary, #2f6b3f);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 4px;
}
#ws-root.ws-dark .wsf-tabs-panel__more a,
#ws-root.ws-dark .wsf-tabs-panel__failed button { color: color-mix(in srgb, var(--ws-primary, #2f6b3f) 50%, #ffffff); }
@media (prefers-reduced-motion: reduce) {
    #ws-root .wsf-tabs-panel__skeleton span { animation: none; }
}
