/* Shared layout for Guildhall in-room overlay bodies (rendered inside AcOverlay/AcPanel).
   Chrome (frame, parchment, scrim, close) comes from the Ac* art system; this is only
   the content layout for Common/Roster/Recruit/Forge/Training/Arcane overlays. */

.gh-overlay-body {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3, 12px);
    width: 100%;
    max-width: 880px;
    margin: 0 auto;
    box-sizing: border-box;
    min-width: 0;
}

/* keep overlay content inside the panel — never let a wide row push off the right edge */
.gh-overlay-body * { box-sizing: border-box; }
.gh-overlay-list,
.gh-recruit-grid { width: 100%; max-width: 100%; }
.gh-overlay-list .ac-list-row { max-width: 100%; min-width: 0; }
.gh-overlay-list .ac-list-row__text { min-width: 0; overflow-wrap: anywhere; }
.gh-overlay-list .ac-list-row__chips { flex-wrap: wrap; justify-content: flex-end; }

.gh-overlay-lead {
    margin: 0;
    color: var(--parch, #e8d9b5);
    font-size: var(--ts-md, 15px);
    line-height: 1.4;
    font-style: italic;
}

.gh-overlay-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3, 12px);
    flex-wrap: wrap;
}

.gh-overlay-head .gh-overlay-lead { flex: 1; min-width: 220px; }

.gh-overlay-subtitle,
.gh-overlay-footnote {
    font-family: var(--font-display, "Cinzel", serif);
    color: var(--gold-bright, #ecc873);
    font-size: var(--ts-sm, 13px);
    letter-spacing: 0.04em;
    border-top: 1px solid rgba(201, 162, 78, 0.25);
    padding-top: var(--sp-2, 8px);
    margin-top: var(--sp-1, 4px);
}

.gh-overlay-footnote {
    color: var(--muted, #9a8f78);
    font-style: italic;
    font-family: inherit;
    letter-spacing: 0;
}

.gh-overlay-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 52vh;
    overflow-y: auto;
    padding-right: 4px;
}

.gh-overlay-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2, 8px);
    justify-content: flex-end;
    margin-top: var(--sp-1, 4px);
}

.gh-overlay-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gh-recruit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--sp-3, 12px);
    max-height: 56vh;
    overflow-y: auto;
    padding: 2px;
}

.gh-recruit-footer {
    display: flex;
    justify-content: center;
    padding-top: 6px;
}

.gh-recruit-card-shell {
    min-width: 0;
    transition: opacity 180ms ease, transform 180ms ease, filter 180ms ease;
}

.gh-recruit-card-shell.is-reveal-source {
    opacity: 0.28;
    transform: translateY(8px) scale(0.965);
    filter: saturate(0.55) brightness(0.72);
}

.gh-recruit-reveal-layer {
    --rarity: var(--gold);
    position: fixed;
    inset: 0;
    z-index: 620;
    display: grid;
    place-items: center;
    padding: 22px;
    pointer-events: auto;
}

.gh-recruit-reveal-layer.rarity-common { --rarity: #8a8170; }
.gh-recruit-reveal-layer.rarity-uncommon { --rarity: #4a9a52; }
.gh-recruit-reveal-layer.rarity-rare { --rarity: #3a72d0; }
.gh-recruit-reveal-layer.rarity-epic { --rarity: #9a46d0; }
.gh-recruit-reveal-layer.rarity-legendary { --rarity: #e8b84a; }

.gh-recruit-reveal-scrim {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 45%, rgba(18, 19, 22, 0.18), rgba(4, 5, 7, 0.72) 68%, rgba(0, 0, 0, 0.84) 100%),
        linear-gradient(180deg, rgba(198, 161, 91, 0.08), rgba(0, 0, 0, 0.18));
    animation: gh-recruit-scrim-in 260ms ease-out both;
}

.gh-recruit-reveal-stage {
    position: relative;
    z-index: 1;
    width: min(330px, calc(100vw - 44px));
    perspective: 1200px;
    animation: gh-recruit-lift 460ms cubic-bezier(0.18, 0.78, 0.22, 1) both;
}

.gh-recruit-reveal-card {
    position: relative;
    z-index: 2;
    transform-style: preserve-3d;
}

.gh-recruit-reveal-card .sc4e {
    width: 100%;
}

.gh-recruit-reveal-flipper {
    display: grid;
    transform-style: preserve-3d;
    transition: transform 620ms cubic-bezier(0.2, 0.86, 0.18, 1);
}

.gh-recruit-reveal-face {
    grid-area: 1 / 1;
    min-width: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.gh-recruit-reveal-back {
    transform: rotateY(180deg);
}

.gh-recruit-reveal-layer.is-flipped .gh-recruit-reveal-flipper {
    transform: rotateY(180deg);
}

.gh-recruit-reveal-layer.is-distinctive .gh-recruit-reveal-card {
    filter: drop-shadow(0 0 18px color-mix(in srgb, var(--rarity) 38%, transparent));
}

.gh-recruit-reveal-copy {
    position: relative;
    z-index: 3;
    margin: 10px auto 0;
    padding: 8px 10px;
    color: var(--parch-dim);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border: 1px solid color-mix(in srgb, var(--rarity) 44%, transparent);
    border-radius: var(--r-sm);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.38);
    font-size: var(--ts-sm);
    line-height: 1.32;
    text-align: center;
    animation: gh-recruit-copy-in 340ms ease-out both;
}

.gh-recruit-reveal-flavor {
    margin-bottom: 4px;
    color: color-mix(in srgb, var(--rarity) 74%, var(--gold-bright));
    font-family: var(--font-display);
    font-size: var(--ts-xs);
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.gh-recruit-reveal-line {
    font-style: italic;
}

.gh-recruit-reveal-beam {
    position: absolute;
    left: 50%;
    top: -22%;
    z-index: 0;
    width: 86%;
    height: 145%;
    transform: translateX(-50%);
    pointer-events: none;
    background: linear-gradient(to top,
        color-mix(in srgb, var(--rarity) 55%, transparent) 0%,
        color-mix(in srgb, var(--rarity) 22%, transparent) 46%,
        transparent 84%);
    clip-path: polygon(35% 100%, 65% 100%, 94% 0, 6% 0);
    filter: blur(9px);
    mix-blend-mode: screen;
    animation: gh-recruit-beam-rise 1.12s ease-out both;
}

.gh-recruit-reveal-flash {
    position: absolute;
    inset: -8%;
    z-index: 4;
    pointer-events: none;
    border-radius: 8px;
    background: radial-gradient(circle at 50% 45%, rgba(255, 248, 224, 0.78) 0%, color-mix(in srgb, var(--rarity) 26%, transparent) 42%, transparent 68%);
    animation: gh-recruit-flash 760ms ease-out both;
}

.gh-recruit-reveal-sparks {
    position: absolute;
    left: 50%;
    top: 42%;
    z-index: 5;
    width: 0;
    height: 0;
    pointer-events: none;
}

.gh-recruit-reveal-spark {
    position: absolute;
    left: 0;
    top: 0;
    width: 2px;
    height: 14px;
    border-radius: 40% 40% 50% 50%;
    background: linear-gradient(to top, transparent 0%, color-mix(in srgb, var(--rarity) 72%, #ffcf7a) 56%, #fff4dc 100%);
    box-shadow: 0 0 7px color-mix(in srgb, var(--rarity) 70%, #ffaa46);
    transform-origin: 50% 100%;
    transform: rotate(calc(var(--i) * 25.714deg));
    animation: gh-recruit-spark-fly 1s ease-out both;
}

@keyframes gh-recruit-scrim-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes gh-recruit-lift {
    0% { opacity: 0; transform: translateY(42px) scale(0.82); }
    58% { opacity: 1; transform: translateY(-5px) scale(1.035); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gh-recruit-copy-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes gh-recruit-beam-rise {
    0% { opacity: 0; transform: translateX(-50%) scaleY(0.38); }
    32% { opacity: 1; }
    100% { opacity: 0; transform: translateX(-50%) scaleY(1.08); }
}

@keyframes gh-recruit-flash {
    0% { opacity: 0; transform: scale(0.62); }
    24% { opacity: 0.86; transform: scale(1.02); }
    100% { opacity: 0; transform: scale(1.12); }
}

@keyframes gh-recruit-spark-fly {
    0% { opacity: 0; transform: rotate(calc(var(--i) * 25.714deg)) translateY(0) scale(0.5); }
    18% { opacity: 1; }
    100% { opacity: 0; transform: rotate(calc(var(--i) * 25.714deg)) translateY(-132px) scale(0.28); }
}

.gh-engrave-row {
    display: flex;
    gap: var(--sp-2, 8px);
    align-items: center;
}

.gh-engrave-input {
    flex: 1;
    min-width: 0;
    background: rgba(8, 6, 4, 0.92);
    border: 1px solid var(--sponsor-accent, var(--gold, #b89255));
    border-radius: var(--r-sm, 6px);
    color: var(--parch, #e8d9b5);
    font-family: var(--font-display, "Cinzel", serif);
    font-size: var(--ts-md, 15px);
    padding: 7px 10px;
}

.gh-engrave-input:focus-visible {
    outline: 2px solid var(--ac-focus, #5b7fb2);
    outline-offset: 1px;
    box-shadow: 0 0 0 3px rgba(91, 127, 178, 0.30), 0 0 12px rgba(91, 127, 178, 0.35);
}

/* Attunement Pool: the single empty black socket centerpiece */
.gh-attune-pool {
    display: flex;
    justify-content: center;
    padding: var(--sp-2, 8px) 0;
}

.gh-attune-socket {
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: radial-gradient(circle at 50% 45%, #05060a, #000 70%);
    border: 1px solid rgba(120, 150, 220, 0.45);
    box-shadow: inset 0 0 26px rgba(40, 70, 150, 0.55), 0 0 18px rgba(60, 90, 190, 0.30);
}

.gh-attune-socket span {
    color: rgba(150, 180, 255, 0.55);
    font-size: 28px;
    animation: gh-attune-shimmer 3.2s ease-in-out infinite;
}

@keyframes gh-attune-shimmer {
    0%, 100% { opacity: 0.4; text-shadow: 0 0 6px rgba(90, 130, 230, 0.4); }
    50% { opacity: 0.85; text-shadow: 0 0 14px rgba(120, 160, 255, 0.8); }
}

@media (prefers-reduced-motion: reduce) {
    .gh-attune-socket span { animation: none; }

    .gh-recruit-card-shell,
    .gh-recruit-reveal-scrim,
    .gh-recruit-reveal-stage,
    .gh-recruit-reveal-flipper,
    .gh-recruit-reveal-copy,
    .gh-recruit-reveal-beam,
    .gh-recruit-reveal-flash,
    .gh-recruit-reveal-spark {
        animation: none !important;
        transition: none !important;
    }

    .gh-recruit-reveal-beam,
    .gh-recruit-reveal-flash,
    .gh-recruit-reveal-spark {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .gh-recruit-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ---- Contract / Adventure board cards ---- */
.gh-contract-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.gh-contract-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    background:
        linear-gradient(160deg, rgba(240, 220, 170, 0.07), rgba(0,0,0,0.22)),
        color-mix(in srgb, var(--panel) 88%, var(--parch-dim) 12%);
    border: 1px solid color-mix(in srgb, var(--gold) 32%, transparent);
    border-left: 3px solid color-mix(in srgb, var(--gold) 60%, transparent);
    border-radius: var(--r-sm);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--gold-bright) 12%, transparent), 0 4px 14px rgba(0,0,0,0.28);
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 100ms ease;
    text-align: left;
}

.gh-contract-card:hover {
    border-color: color-mix(in srgb, var(--gold) 62%, transparent);
    border-left-color: var(--gold-bright);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--gold-bright) 18%, transparent), 0 6px 20px rgba(0,0,0,0.38);
    transform: translateY(-1px);
}

.gh-contract-card:active {
    transform: translateY(0);
}

.gh-contract-name {
    font-family: var(--font-display);
    font-size: var(--ts-md);
    font-weight: 700;
    color: var(--parch);
    letter-spacing: 0;
    line-height: 1.2;
}

.gh-contract-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: var(--ts-xs);
    color: var(--parch-dim);
}

.gh-contract-location {
    font-style: italic;
    color: color-mix(in srgb, var(--parch-dim) 80%, transparent);
}

.gh-contract-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2px;
}

/* Detail dialog overlay */
.gh-contract-detail-scrim {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(4, 5, 8, 0.72);
    display: grid;
    place-items: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}

.gh-contract-detail-panel {
    width: min(640px, calc(100vw - 48px));
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 24px 28px;
    background:
        linear-gradient(160deg, rgba(255,255,255,0.04), rgba(0,0,0,0.32)),
        color-mix(in srgb, var(--panel) 97%, black);
    border: 1px solid color-mix(in srgb, var(--gold) 48%, transparent);
    border-radius: var(--r-md);
    box-shadow:
        inset 0 1px 0 color-mix(in srgb, var(--gold-bright) 20%, transparent),
        0 28px 72px rgba(0, 0, 0, 0.68);
}

.gh-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.gh-detail-title {
    font-family: var(--font-display);
    font-size: 1.18rem;
    font-weight: 800;
    color: var(--gold-bright);
    letter-spacing: 0;
    line-height: 1.2;
    margin: 0;
}

.gh-detail-close {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
    border-radius: 4px;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    transition: color 130ms ease, border-color 130ms ease;
}

.gh-detail-close:hover {
    color: var(--parch);
    border-color: color-mix(in srgb, var(--gold) 60%, transparent);
}

.gh-detail-tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.gh-detail-tile {
    padding: 10px 12px;
    background: color-mix(in srgb, var(--bg) 60%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold) 22%, transparent);
    border-radius: var(--r-sm);
}

.gh-detail-tile-label {
    font-size: var(--ts-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 3px;
}

.gh-detail-tile-value {
    font-family: var(--font-display);
    font-size: var(--ts-sm);
    color: var(--parch);
    font-weight: 700;
}

.gh-detail-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 28%, transparent) 50%, transparent);
    margin: 0;
    border: none;
}

.gh-detail-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.gh-detail-flavor {
    font-style: italic;
    font-size: var(--ts-sm);
    color: var(--parch-dim);
    line-height: 1.45;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--bg) 40%, transparent);
    border-left: 2px solid color-mix(in srgb, var(--gold) 36%, transparent);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.gh-detail-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 4px;
}

.gh-detail-war-table-link {
    font-size: var(--ts-sm);
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-family: inherit;
    transition: color 130ms ease;
}

.gh-detail-war-table-link:hover {
    color: var(--gold);
}

/* Bartender adventure alert indicator */
.bartender-alert {
    position: absolute;
    left: 62%;
    top: 33%;
    z-index: 6;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: radial-gradient(circle, color-mix(in srgb, var(--ward) 28%, transparent), transparent 70%);
    animation: bartender-pulse 2s ease-in-out infinite;
}

.bartender-alert::before {
    content: "!";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--gold-bright) 90%, white);
    color: #1a1206;
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 900;
    box-shadow: 0 0 10px color-mix(in srgb, var(--gold-bright) 72%, transparent), 0 0 22px color-mix(in srgb, var(--gold) 38%, transparent);
}

@keyframes bartender-pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.18); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .bartender-alert { animation: none; }
    .gh-contract-card { transition: none; }
}

/* ---- XCOM2-style Roster rows ---- */
.gh-roster-grid {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-height: 56vh;
    overflow-y: auto;
    padding-right: 4px;
}

.gh-roster-row {
    display: grid;
    grid-template-columns: 22px 1fr auto auto;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.025), rgba(0,0,0,0.18)),
        color-mix(in srgb, var(--panel) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--gold) 22%, transparent);
    border-left: 2px solid transparent;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease, transform 80ms ease;
}

.gh-roster-row:hover {
    background:
        linear-gradient(180deg, rgba(230, 195, 111, 0.05), rgba(0,0,0,0.22)),
        color-mix(in srgb, var(--panel-2) 82%, transparent);
    border-color: color-mix(in srgb, var(--gold) 44%, transparent);
    border-left-color: var(--sponsor-accent, var(--gold));
    transform: translateX(2px);
}

.gh-roster-row:active { transform: translateX(1px); }

.gh-roster-row--ready    { border-left-color: color-mix(in srgb, #4caf7a 70%, transparent); }
.gh-roster-row--mending  { border-left-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.gh-roster-row--afield   { border-left-color: color-mix(in srgb, #d05050 60%, transparent); }
.gh-roster-row--returning{ border-left-color: color-mix(in srgb, #6090b0 50%, transparent); }

.gh-roster-icon {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--sponsor-accent, var(--gold)) 14%, transparent);
    color: var(--sponsor-accent, var(--gold));
}

.gh-roster-identity {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.gh-roster-name {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--parch);
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gh-roster-sub {
    font-size: 0.60rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--muted) 80%, transparent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gh-roster-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.gh-roster-stat {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--parch-dim);
    font-variant-numeric: tabular-nums;
}

.gh-roster-status {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-family: var(--font-display);
    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.gh-roster-status--ready    { color: #4caf7a; background: color-mix(in srgb, #4caf7a 14%, transparent); border: 1px solid color-mix(in srgb, #4caf7a 32%, transparent); }
.gh-roster-status--mending  { color: var(--gold-bright); background: color-mix(in srgb, var(--gold) 12%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent); }
.gh-roster-status--marching { color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 24%, transparent); }
.gh-roster-status--atsite   { color: #d05050; background: color-mix(in srgb, #d05050 14%, transparent); border: 1px solid color-mix(in srgb, #d05050 32%, transparent); }
.gh-roster-status--returning{ color: #7aabcc; background: color-mix(in srgb, #5080aa 12%, transparent); border: 1px solid color-mix(in srgb, #5080aa 28%, transparent); }
.gh-roster-status--injured  { color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
    .gh-roster-row { transition: none; }
}

@media (max-width: 640px) {
    .gh-roster-row { grid-template-columns: 22px 1fr auto; }
    .gh-roster-status { display: none; }
}
