/* Character concept page (templates/chargen.html, drawn by static/chargen.js).
   Classes start with cg- so they never collide with site CSS. Every color
   comes from the scheme tokens. */
.cg {
    /* Secondary text that stays at AA on the page and panel grounds. */
    --meta: color-mix(in srgb, var(--text) 40%, var(--text-dim));
    --wash: color-mix(in srgb, var(--highlight) 12%, transparent);
    width: 100%;
    max-width: 1080px;
}
.cg [hidden] { display: none !important; }
.cg :focus-visible { outline: 2px solid var(--highlight); outline-offset: 2px; }
.cg h2 { margin: 0; padding: 0; border: 0; letter-spacing: -.01em; color: var(--text-bright); }
.cg p { margin: 0; }

/* page head */
.cg-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin: 0 0 22px; }
.cg .cg-head h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.02em; color: var(--text-bright); }
.cg .cg-deck { margin: 6px 0 0; max-width: 64ch; font-size: 14.5px; line-height: 1.6; color: var(--meta); text-wrap: pretty; }
.cg .cg-note {
    margin: 0 0 18px; padding: 10px 14px; max-width: 78ch;
    border-left: 3px solid var(--warn); border-radius: 0 6px 6px 0; background: var(--bg-secondary);
    font-size: 13px; line-height: 1.55; color: var(--text);
}
.cg-note span { display: block; font-family: var(--font-mono); font-size: 12px; color: var(--meta); }

/* the sheet on the left, the choices on the right, the cabals under the sheet */
.cg-grid {
    display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .9fr); gap: 16px 20px; align-items: start;
    grid-template-areas: "sheet choices" "cabals choices";
}
.cg-sheet { grid-area: sheet; }
.cg-choices { grid-area: choices; position: sticky; top: 16px; }
.cg-cabals { grid-area: cabals; }
.cg-sheet, .cg-choices, .cg-cabals {
    min-width: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-secondary);
}

/* the character */
.cg-sheet { padding: 24px 28px 22px; }
.cg-name-row { display: flex; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.cg-name-acts { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.cg .cg-name {
    flex: 1 1 150px; width: auto; min-width: 0; margin: 0 0 0 -2px; padding: 0 2px 2px;
    border: 0; border-bottom: 1px dashed transparent; border-radius: 0; background: none; box-shadow: none;
    font-family: 'FuzzyHand', Georgia, serif; font-size: clamp(36px, 5vw, 50px); line-height: 1.15;
    color: var(--text-bright);
}
.cg .cg-name:hover { border-bottom-color: var(--border-hover); }
.cg .cg-name:focus { border-bottom-color: var(--highlight); box-shadow: none; outline: 0; }
.cg .cg-line { margin: 4px 0 0; font-size: 15px; line-height: 1.5; color: var(--text); }
.cg-part { margin-top: 24px; }
.cg-part-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
.cg .cg-part-head h2 { font-size: 13.5px; font-weight: 600; }
.cg .cg-story { max-width: 62ch; font-size: 15.5px; line-height: 1.7; color: var(--text-bright); text-wrap: pretty; }
.cg ul.cg-quirks { margin: 0; padding: 0 0 0 18px; list-style: disc; }
.cg-quirks li { margin: 0; padding: 2px 0; font-size: 15px; line-height: 1.55; color: var(--text-bright); }
.cg-quirks li::marker { color: var(--text-fade); }
.cg-acts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.cg-said { font-size: 13px; color: var(--meta); }

/* the lock that keeps a choice through a roll */
.cg-lock {
    appearance: none; flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0;
    border: 1px solid var(--border); border-radius: 6px; background: none; color: var(--text-fade); cursor: pointer;
}
.cg-lock:hover { border-color: var(--border-hover); color: var(--text-bright); }
.cg-lock svg { width: 15px; height: 15px; }
.cg-lock .cg-shut { display: none; }
.cg-lock[aria-pressed="true"] { border-color: var(--highlight); background: var(--wash); color: var(--highlight); }
.cg-lock[aria-pressed="true"] .cg-shut { display: inline; }
.cg-lock[aria-pressed="true"] .cg-open { display: none; }

/* the traits and what the character starts with: a name and a line */
.cg dl.cg-traits { margin: 0; padding: 0; }
.cg-trait { display: grid; grid-template-columns: 104px minmax(0, 1fr) auto; align-items: baseline; gap: 0 12px; padding: 7px 0; border-top: 1px solid var(--border); }
.cg-trait:first-child { border-top: 0; padding-top: 2px; }
.cg-trait dt, .cg-trait dd { margin: 0; font-size: 15px; line-height: 1.55; }
.cg-trait dt { font-size: 13px; font-weight: 400; color: var(--meta); }
.cg-trait dd { color: var(--text-bright); }
.cg-again {
    appearance: none; align-self: center; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0;
    border: 0; border-radius: 6px; background: none; color: var(--text-fade); cursor: pointer;
}
.cg-again:hover { background: var(--bg-hover); color: var(--text-bright); }
.cg-again svg { width: 14px; height: 14px; }

/* the details and the looks: a name over a list, with its lock */
.cg-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 16px; }
.cg-fields-one { margin-top: 12px; grid-template-columns: minmax(0, 320px); }
.cg-field { min-width: 0; }
.cg-field label { display: block; margin: 0 0 4px; font-size: 12.5px; font-weight: 400; color: var(--meta); }
.cg-ctl { display: flex; align-items: center; gap: 6px; }
.cg .cg-ctl select, .cg .cg-ctl input { flex: 1 1 auto; width: 100%; min-width: 0; max-width: none; margin: 0; font-size: 14px; }
.cg .cg-ctl select:disabled { opacity: 1; color: var(--text); background-image: none; cursor: default; }
.cg .cg-fine { margin-top: 8px; font-size: 12.5px; line-height: 1.55; color: var(--meta); }
.cg-fine:empty { display: none; }
.cg .cg-perk-text { margin-top: 10px; max-width: 62ch; font-size: 14px; line-height: 1.6; color: var(--text); text-wrap: pretty; }
.cg .cg-looks-text { margin: 0 0 12px; max-width: 62ch; font-size: 15.5px; line-height: 1.6; color: var(--text-bright); }
.cg-looks-text:empty { display: none; }

/* the choices */
.cg-choices { padding: 20px 22px 14px; }
.cg .cg-choices h2, .cg .cg-cabals h2 { font-size: 16px; font-weight: 700; }
.cg .cg-sub { margin: 4px 0 0; font-size: 13px; line-height: 1.55; color: var(--meta); text-wrap: pretty; }
#cg-rows { margin-top: 12px; }
.cg-row {
    display: grid; grid-template-columns: 84px minmax(0, 1fr) 32px; align-items: center; gap: 4px 10px;
    padding: 9px 0; border-top: 1px solid var(--border);
}
.cg-row label { margin: 0; font-size: 13.5px; font-weight: 500; color: var(--text); }
.cg .cg-row select { width: 100%; max-width: none; margin: 0; font-size: 14px; }
.cg .cg-row select:disabled { opacity: 1; color: var(--text); background-image: none; cursor: default; }
.cg .cg-hint { grid-column: 2 / -1; font-size: 12.5px; line-height: 1.5; color: var(--meta); }
.cg-hint:empty { display: none; }
.cg-hint a { color: var(--meta); text-decoration: underline; text-decoration-color: var(--border-hover); text-underline-offset: 2px; }
.cg-hint a:hover { color: var(--highlight); }

/* the cabals */
.cg-cabals { padding: 20px 22px 10px; }
.cg ul.cg-cabal-list { list-style: none; margin: 12px 0 0; padding: 0; }
.cg-cabal-list li {
    display: flex; align-items: baseline; justify-content: space-between; gap: 6px 16px; flex-wrap: wrap;
    margin: 0; padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.4;
}
.cg-cabal { font-weight: 600; color: var(--text-bright); text-decoration: none; }
.cg-cabal::before {
    content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 10px; border-radius: 50%;
    background: var(--accent); vertical-align: 1px;
}
a.cg-cabal:hover { color: var(--highlight); }
.cg-why { font-size: 13px; color: var(--meta); text-align: right; }
.cg-cabal-list .is-closed .cg-cabal { font-weight: 500; color: var(--text-dim); }
.cg-cabal-list .is-closed .cg-cabal::before { background: none; box-shadow: inset 0 0 0 1px var(--text-fade); }

/* a roll brings the new character in */
@keyframes cg-in { from { opacity: 0; transform: translateY(5px); } }
.cg-sheet.is-new .cg-name, .cg-sheet.is-new .cg-line, .cg-sheet.is-new .cg-story, .cg-sheet.is-new .cg-quirks, .cg-sheet.is-new .cg-traits {
    animation: cg-in .26s ease-out backwards;
}
.cg-sheet.is-new .cg-line { animation-delay: .04s; }
.cg-sheet.is-new .cg-story { animation-delay: .08s; }
.cg-sheet.is-new .cg-quirks { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) {
    .cg-sheet.is-new * { animation: none !important; }
}

@media (max-width: 860px) {
    .cg-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "sheet" "choices" "cabals"; }
    .cg-choices { position: static; }
    .cg-sheet { padding: 20px 18px 18px; }
    .cg-choices, .cg-cabals { padding-left: 18px; padding-right: 18px; }
    .cg-head .btn { width: 100%; }
    .cg-why { text-align: left; }
    .cg-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .cg-fields-one { grid-template-columns: minmax(0, 1fr); }
    .cg-trait { grid-template-columns: 92px minmax(0, 1fr) auto; }
}
