/* Resource & rest tracker - page styles. Reuses base.css tokens. */
.res { max-width: 60rem; margin-inline: auto; }
.res-intro { color: var(--muted); max-width: 56ch; }

/* Content links track the theme accent (and stay accent when visited, not the UA purple).
   Scoped with :not(.crumb-back) so the shared "Back to tools" breadcrumb keeps its gray. */
.res a:not(.crumb-back) { color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; transition: color .2s, border-color .2s; }
.res a:not(.crumb-back):visited { color: var(--accent); }
.res a:not(.crumb-back):hover { color: var(--accent-strong); border-color: currentColor; }

.res-setup { display: flex; flex-direction: column; gap: 0.85rem; align-items: stretch; margin-block: 1rem; }

/* Rules edition lives on its own row, introduced by a label. */
.res-rules { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.res-rules-label { color: var(--muted); font-size: 0.95rem; }
.res-edition { display: inline-flex; border: 1px solid var(--border); border-radius: 0.5rem; overflow: hidden; }
.res-ed-btn { font: inherit; padding: 0.5rem 0.85rem; background: transparent; border: 0; cursor: pointer; color: var(--text); }
.res-ed-btn.is-active { background: var(--accent); color: var(--bg); }

/* Add-class form: a full-width surface card, set apart from the rest of the page. */
.res-addclass-box { background: var(--surface); border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.85rem 1rem; }
.res-addclass-title { display: block; margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.res-addclass { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.res-addclass .res-btn { margin-left: auto; }
.res-level-input { width: 4.5rem; }
.res-inline { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); font-size: 0.95rem; }

.res-rest { display: flex; gap: 1rem; flex-wrap: wrap; margin-block: 1rem; }
.res-btn { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 0.4em; padding: 0.5rem 0.9rem; border: 1px solid var(--accent); border-radius: 8px; background: var(--accent); cursor: pointer; color: var(--bg); }
.res-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.res-btn:focus-visible { outline-color: var(--bg); }
.res-rest-long { font-weight: 600; }

/* Rest feedback: a brief pulse on the pressed button + a transient status message. */
@keyframes res-rest-pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 var(--accent-weak); }
    40% { transform: scale(1.05); box-shadow: 0 0 0 0.4rem var(--accent-weak); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 transparent; }
}
.res-btn.is-resting { animation: res-rest-pulse 0.55s ease-out; }

/* Toast slides open by animating the grid row from 0fr to 1fr, so content below
   is pushed down smoothly instead of jumping. The clip element hides the overflow. */
.res-toast { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .32s ease; }
.res-toast.is-show { grid-template-rows: 1fr; }
.res-toast-clip { overflow: hidden; min-height: 0; }
.res-toast-banner {
    margin: 0.6rem 0 0.85rem; padding: 0.55rem 0.85rem; border-radius: 0.5rem;
    background: var(--accent-weak); color: var(--accent-strong); border: 1px solid var(--accent);
    font-size: 0.9rem;
    opacity: 0; transition: opacity .32s ease;
}
.res-toast.is-show .res-toast-banner { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .res-btn.is-resting { animation: none; }
    .res-toast, .res-toast-banner { transition: none; }
}

/* Clear is destructive: pushed to the far right (away from the rest buttons) and de-emphasized. */
.res-btn-ghost { margin-left: auto; background: transparent; border-color: var(--border); color: var(--muted); }
.res-btn-ghost:hover { background: transparent; border-color: var(--bad); color: var(--bad); }

.res-list { display: grid; gap: 1.25rem; }
.res-empty { color: var(--muted); }
.res-group { border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.75rem 1rem; }
.res-group-title { margin: 0 0 0.5rem; font-size: 1.05rem; }

/* Per-class box header: title left, level control + remove pushed right. */
.res-group-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.res-group-head .res-group-title { margin: 0; }
/* Class icon (community D&D 5e vector set): masked so it inherits the heading's theme color. */
.res-class-icon {
    flex: none; width: 1.6rem; height: 1.6rem; display: inline-block;
    background-color: currentColor;
    -webkit-mask: var(--class-icon) center / contain no-repeat;
    mask: var(--class-icon) center / contain no-repeat;
}
.res-levellabel { margin-left: auto; display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
.res-levelinput { width: 3.25rem; font: inherit; font-size: 0.95rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 0.15rem 0.3rem; text-align: center; }
.res-levelinput:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.res-group-x { background: transparent; border: 0; cursor: pointer; font-size: 1.25rem; line-height: 1; color: var(--muted); padding: 0 0.15rem; }
.res-group-x:hover { color: var(--bad); }
.res-none { margin: 0; color: var(--muted); font-size: 0.9rem; }
.res-sub { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; text-transform: uppercase; letter-spacing: 0.03em; }

.res-row { padding: 0.4rem 0; border-top: 1px solid var(--border); }
.res-row:first-of-type { border-top: 0; }
.res-row-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.res-row-label { font-weight: 500; }
/* Row notes are tucked behind a small "i" badge that reveals a tooltip on hover/focus. */
.res-info {
    appearance: none; -webkit-appearance: none; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    width: 1.15rem; height: 1.15rem; padding: 0;
    border: 1px solid var(--border-strong); border-radius: 50%;
    background: transparent; color: var(--muted);
    font-size: 0.72rem; font-weight: 700; line-height: 1; cursor: help; position: relative;
}
.res-info:hover, .res-info:focus-visible, .res-info.is-open { color: var(--accent); border-color: var(--accent); }
.res-info:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.res-info::after {
    content: attr(data-tip);
    position: absolute; left: 50%; bottom: calc(100% + 0.45rem); transform: translateX(-50%);
    z-index: 20; width: max-content; max-width: 15rem;
    padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 0.5rem;
    background: var(--surface); color: var(--text);
    font-size: 0.8rem; font-weight: 400; line-height: 1.45; text-align: left; white-space: normal;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
    opacity: 0; visibility: hidden; transition: opacity .15s ease; pointer-events: none;
}
.res-info:hover::after, .res-info:focus-visible::after, .res-info.is-open::after { opacity: 1; visibility: visible; }
.res-tag { font-size: 0.7rem; padding: 0.05rem 0.4rem; border-radius: 1rem; border: 1px solid var(--border); color: var(--muted); }
.res-tag-short { border-color: var(--accent); }
.res-maxedit { font-size: 0.75rem; background: transparent; border: 1px dashed var(--border); border-radius: 0.4rem; cursor: pointer; color: var(--muted); }

.res-row-body { margin-top: 0.35rem; }
.res-pips { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.res-pip { width: 1.25rem; height: 1.25rem; border: 2px solid var(--border); border-radius: 0.3rem; background: transparent; cursor: pointer; padding: 0; }
.res-pip.is-on { background: var(--accent); border-color: var(--accent); }
.res-death-fail.is-on { background: var(--bad); border-color: var(--bad); }

.res-counter { display: inline-flex; align-items: center; gap: 0.6rem; }
.res-step { width: 1.8rem; height: 1.8rem; border: 1px solid var(--border); border-radius: 0.4rem; background: var(--surface); cursor: pointer; font-size: 1.1rem; color: var(--text); }
.res-count { min-width: 4rem; text-align: center; font-variant-numeric: tabular-nums; }
.res-count-cur { font-weight: 600; }

.res-death-rows { display: grid; gap: 0.35rem; margin-top: 0.35rem; }
.res-death-line { display: flex; align-items: center; gap: 0.6rem; }
.res-death-cap { width: 5.5rem; font-size: 0.85rem; color: var(--muted); }

/* General notes: a full-width surface box holding a free-text area. */
.res-notes-box { margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.85rem 1rem; }
.res-notes-title { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.res-notes { display: block; width: 100%; min-height: 6rem; resize: vertical; line-height: 1.5; }

/* Add custom resource: a full-width surface box, mirroring the add-class box. */
.res-custom { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 0.75rem; padding: 0.85rem 1rem; }
.res-custom-title { width: 100%; margin: 0; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.res-custom .res-btn { margin-left: auto; }
