/* ================= EXP Calculator — page-specific styles =================
   Everything shared with the rest of the site (header, hamburger, lang
   selector, page-grid/side-rail layout, .container, .btn, mobile
   breakpoints, etc.) lives in Css/index.css and is reused as-is here.
   This file only adds the bits unique to the calculator itself. */

:root {
    --green: #2AF527;
}

/* Page-specific background (overrides the shared body background from index.css) */
body {
    background-color: #0b0704;
    background-image: url('https://img.itch.zone/aW1hZ2UvMzk1ODQ1Ny8yNDI2NjgzOS5wbmc=/original/5pZPAE.png');
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment: fixed;
    background-size: cover;
}

/* iOS/Android browsers handle fixed backgrounds poorly (glitches, wrong sizing
   on address-bar show/hide) — use scroll attachment on touch devices so the
   image still fills the screen cleanly everywhere. */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
    body {
        background-attachment: scroll;
    }
}

/* ---- Page (main) scrollbar — same styling as the exp-table scrollbar ---- */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) rgba(0, 0, 0, 0.3);
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background-color: var(--gold); }

/* ---- Form fields (skill picker, level inputs, monster select, etc.) ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: #ffd8a8; margin-bottom: 6px; font-weight: 600; }
.field .hint { font-size: 11px; color: #c9a06a; margin-top: 5px; line-height: 1.5; }
.field .badge { text-transform: none; color: #f87171; }
.field .badge-optional { text-transform: none; color: #c9a06a; }

select, input[type="number"] {
    width: 100%;
    padding: 10px 11px;
    background: #1a120b;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 13px;
    outline: none;
}
select:focus, input[type="number"]:focus {
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

/* The real <select id="monster-select"> stays in the DOM as the source of
   truth for value/change-event handling, but is visually replaced by the
   .custom-select widget below (which has a themeable dropdown scrollbar). */
.visually-hidden-select { display: none; }

.custom-select { position: relative; }
.custom-select-trigger {
    width: 100%;
    padding: 10px 11px;
    background: #1a120b;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 13px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
}
.custom-select-trigger span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.custom-select-trigger:hover { border-color: var(--highlight); }
.custom-select-trigger:focus,
.custom-select-trigger.open {
    outline: none;
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}
.custom-select-arrow { color: #c9a06a; font-size: 11px; transition: transform 0.15s ease; flex-shrink: 0; }
.custom-select-trigger.open .custom-select-arrow { transform: rotate(180deg); }

.custom-select-panel {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 320px;
    background: #1a120b;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    flex-direction: column;
    overflow: hidden;
}
.custom-select-panel.open { display: flex; }

/* Search box pinned at the top of the panel, list scrolls beneath it */
.custom-select-search-wrap {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.custom-select-search {
    width: 100%;
    padding: 9px 10px;
    background: #0b0704;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
    /* 16px avoids iOS Safari auto-zooming the page when this field is focused */
    font-size: 16px;
    outline: none;
}
.custom-select-search:focus {
    border-color: var(--highlight);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}

.custom-select-options {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0;
}

/* Themed scrollbar for the dropdown results list — same styling used
   elsewhere on this page (e.g. the exp-table scroll box). */
.custom-select-options::-webkit-scrollbar { width: 6px; }
.custom-select-options::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
.custom-select-options::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 3px; }
.custom-select-options::-webkit-scrollbar-thumb:hover { background-color: var(--gold); }
.custom-select-options { scrollbar-width: thin; scrollbar-color: var(--border-color) rgba(0, 0, 0, 0.3); }

.custom-select-no-results {
    padding: 14px 11px;
    font-size: 12.5px;
    color: #c9a06a;
    text-align: center;
    flex-shrink: 0;
}

.custom-select-group-label {
    padding: 8px 11px 4px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--highlight);
    background: rgba(120, 53, 15, 0.3);
}
.custom-select-option {
    padding: 8px 11px;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-select-option:hover,
.custom-select-option.highlighted { background: rgba(180, 83, 9, 0.25); }
.custom-select-option.selected { background: var(--accent); color: #fff; }
.custom-select-option.disabled { color: #6b5a48; cursor: not-allowed; }
.custom-select-option.disabled:hover { background: transparent; }

.row-2 { display: flex; gap: 10px; }
.row-2 > div { flex: 1; }

.skill-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.skill-btn {
    position: relative;
    background: #1a120b;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    padding: 10px 6px;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.skill-btn:hover { border-color: var(--highlight); }
.skill-btn.active { background: var(--accent); border-color: var(--highlight); color: #fff; box-shadow: 0 0 8px rgba(251, 191, 36, 0.35); }

/* Small numbered badge shown on a selected skill button — "1" = your main
   trained skill, "2" = the secondary skill (for dual-training weapons).
   Health gets its own marker instead, since it's always single-select. */
.skill-btn-badge {
    display: none;
    position: absolute;
    top: -7px;
    right: -7px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--highlight);
    color: #1a120b;
    font-size: 10px;
    font-weight: 800;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #1a120b;
    line-height: 1;
}
.skill-btn-badge.show { display: flex; }
.skill-btn-badge.health { background: var(--green); }

/* ---- Training summary tables: selected skill(s) + Health, kept visually
   separate so it's obvious Health is a different, always-on thing. ---- */
.training-summary { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.training-table-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--highlight); font-weight: 600; margin-bottom: 6px; }
.training-table-title.health { color: var(--green); }
table.training-table { width: 100%; border-collapse: collapse; font-size: 12.5px; text-align: left; }
table.training-table th { background: rgba(120, 53, 15, 0.3); color: var(--highlight); padding: 7px 9px; border: 1px solid var(--border-color); }
table.training-table td { padding: 7px 9px; border: 1px solid var(--border-color); border-top: none; }
table.training-table.health-table th { background: rgba(42, 245, 39, 0.12); color: var(--green); border-color: rgba(42, 245, 39, 0.35); }
table.training-table.health-table td { border-color: rgba(42, 245, 39, 0.35); border-top: none; }
.role-badge { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: 50%; background: var(--highlight); color: #1a120b; font-size: 9px; font-weight: 800; margin-right: 6px; vertical-align: -2px; }
.role-badge.health { background: var(--green); }
.role-badge.secondary { background: #c9a06a; }

.warn { color: #f87171; font-size: 12px; margin-top: 8px; }

/* ---- Results ---- */
.note { background: rgba(180, 83, 9, 0.15); border: 1px solid var(--border-color); border-radius: 8px; padding: 14px 16px; font-size: 12.5px; line-height: 1.6; color: #ffd8a8; margin-bottom: 20px; }
.note strong { color: var(--highlight); }

.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border-color); border-radius: 8px; padding: 16px; }
.stat-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #c9a06a; margin-bottom: 6px; }
.stat-card .value { font-size: 22px; font-weight: 700; color: var(--highlight); font-family: 'Cinzel', Georgia, serif; }
.stat-card .value.green { color: var(--green); }
.stat-card .sub { font-size: 11px; color: #ffd8a8; margin-top: 6px; }

.progress-wrap { background: #1a120b; border: 1px solid var(--border-color); border-radius: 8px; padding: 16px; margin-bottom: 4px; }
.progress-bar-bg { width: 100%; height: 14px; background: rgba(0, 0, 0, 0.5); border-radius: 7px; overflow: hidden; border: 1px solid var(--border-color); margin-top: 10px; }
.progress-bar-fill { height: 100%; background: linear-gradient(to right, var(--accent), var(--highlight)); border-radius: 7px 0 0 7px; transition: width 0.3s ease; }
.progress-label { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; font-size: 12px; color: #ffd8a8; }

/* ---- Cumulative EXP table ---- */
table.exp-table { width: 100%; border-collapse: collapse; font-size: 0.82em; text-align: left; margin-top: 6px; }
table.exp-table th { background: rgba(120, 53, 15, 0.3); color: var(--highlight); padding: 8px; border: 1px solid var(--border-color); position: sticky; top: 0; }
table.exp-table td { padding: 6px 8px; border-bottom: 1px solid rgba(120, 53, 15, 0.2); }
table.exp-table tr:hover td { background: rgba(180, 83, 9, 0.12); }

.exp-table-scroll { max-height: 360px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: 8px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.exp-table-scroll::-webkit-scrollbar { width: 6px; }
.exp-table-scroll::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
.exp-table-scroll::-webkit-scrollbar-thumb { background-color: var(--border-color); border-radius: 3px; }
.exp-table-scroll::-webkit-scrollbar-thumb:hover { background-color: var(--gold); }
.exp-table-scroll { scrollbar-width: thin; scrollbar-color: var(--border-color) rgba(0, 0, 0, 0.3); }

/* Momentary highlight on the row matching the required level, after Calculate */
.exp-row-highlight { outline: 2px solid var(--highlight); }

@media (max-width: 768px) {
    .results-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .results-grid { grid-template-columns: 1fr; }
    .skill-grid { grid-template-columns: 1fr 1fr; }
}

/* Larger tap targets for the monster dropdown on touch devices */
@media (hover: none) and (pointer: coarse) {
    .custom-select-option { padding: 11px; }
    .custom-select-panel { max-height: 45vh; }
}

@media (max-width: 380px) {
    table.training-table { font-size: 11.5px; }
    table.training-table th, table.training-table td { padding: 6px 6px; }
}
