/*
    Player archetype layout — shared by Person / Place / Object / Document panels.
    Tokens mirror the design canvas (Shared Entity Views.html, const T).
*/

:root {
    --pa-parchment: #f0e8d4;
    --pa-cream: #fdf8f0;
    --pa-ink: #1a1209;
    --pa-ink-mid: #3a2214;
    --pa-muted: #7a6a50;
    --pa-gold: #b8920c;
    --pa-gold-faint: rgba(184, 146, 12, 0.32);
    --pa-crimson: #730000;
    --pa-spine: #5c0000;
    --pa-rule: rgba(0, 0, 0, 0.07);
    --pa-border: rgba(0, 0, 0, 0.09);
    --pa-note-bg: #fbf3df;
    --pa-note-border: rgba(184, 146, 12, 0.45);
    --pa-note-ink: #3a2214;
    --pa-font-cin: 'Cinzel', Georgia, serif;
    --pa-font-lor: 'Lora', Georgia, serif;
}

/* ── Top-level split ──────────────────────────────────────────────────── */
.player-archetype {
    background: var(--pa-cream);
    color: var(--pa-ink);
    font-family: var(--pa-font-lor);
    /*
        Fill remaining viewport so the notes-panel scroll lives inside the editor.
        The 180px offset accounts for the layout's top nav (~64px), page padding,
        and the back-button row above the archetype. Tweak if those change.
    */
    height: calc(100vh - 180px);
    min-height: 540px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.player-archetype__split {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.player-archetype__content {
    flex: 0 1 42%;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    padding: 22px 28px 36px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.player-archetype__notes {
    flex: 1 1 58%;
    min-width: 0;
    align-self: stretch;
}

/* Phase 12: `.player-archetype--unshared` removed. Post-unification a player either has
   the entity (mode=PlayerEditOwn / PlayerReadShared) or can't reach it (server 404s on
   unshared). The orphaned-with-notes state is unreachable, so no desaturation rule is
   needed. */

/* ── Hero treatments ──────────────────────────────────────────────────── */

/* Person — portrait + meta grid */
.hero-portrait {
    display: flex;
    gap: 22px;
    align-items: flex-start;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--pa-rule);
}

.hero-portrait__image {
    width: 140px;
    height: 170px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid var(--pa-gold-faint);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    background: var(--pa-parchment);
}

.hero-portrait__placeholder {
    width: 140px;
    height: 170px;
    border-radius: 2px;
    border: 1px solid var(--pa-gold-faint);
    background: var(--pa-parchment);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--pa-muted);
}

.hero-portrait__main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hero-portrait__name {
    font-family: var(--pa-font-cin);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--pa-ink);
    margin: 0;
}

.hero-portrait__chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Place / Document — full-bleed banner */
.hero-banner {
    position: relative;
    flex-shrink: 0;
    height: 220px;
    background: linear-gradient(135deg, #2a0800 0%, #5c1000 50%, #3a0647 100%);
    overflow: hidden;
    border-radius: 2px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.hero-banner__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.88;
}

.hero-banner__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.65) 100%);
    pointer-events: none;
}

.hero-banner__content {
    position: absolute;
    left: 22px;
    right: 22px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1;
}

.hero-banner__name {
    font-family: var(--pa-font-cin);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    margin: 0;
}

.hero-banner__subtitle {
    font-family: var(--pa-font-cin);
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    margin: 0;
    max-width: 80ch;
    line-height: 1.35;
}

.hero-banner__chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Object — compact one-liner */
.hero-compact {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 0;
    border-bottom: 1px solid var(--pa-rule);
}

.hero-compact__main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}

.hero-compact__name {
    font-family: var(--pa-font-cin);
    font-size: 22px;
    font-weight: 700;
    color: var(--pa-ink);
    margin: 0;
}

.hero-compact__image {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 2px;
    border: 1px solid var(--pa-gold-faint);
    flex-shrink: 0;
    background: var(--pa-parchment);
}

/* ── Ornamental rule ──────────────────────────────────────────────────── */
.ed-orn-rule {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 10px;
    color: var(--pa-gold);
    font-family: var(--pa-font-cin);
    font-size: 12px;
}

.ed-orn-rule::before,
.ed-orn-rule::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--pa-gold-faint));
}

.ed-orn-rule::after {
    background: linear-gradient(to left, transparent, var(--pa-gold-faint));
}

.ed-orn-rule__diamond {
    color: var(--pa-gold);
    font-size: 10px;
}

/* ── Sections ─────────────────────────────────────────────────────────── */
.ed-section {
    display: flex;
    flex-direction: column;
}

.ed-section__title {
    font-family: var(--pa-font-cin);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pa-crimson);
    margin: 0 0 4px;
    text-align: center;
}

.ed-prose {
    font-family: var(--pa-font-lor);
    font-size: 14px;
    line-height: 1.7;
    color: var(--pa-ink-mid);
}

.ed-prose p {
    margin: 0 0 10px;
}

.ed-prose h1,
.ed-prose h2,
.ed-prose h3 {
    font-family: var(--pa-font-cin);
    color: var(--pa-crimson);
    letter-spacing: 0.04em;
    margin: 14px 0 6px;
}

.ed-prose ul,
.ed-prose ol {
    margin: 0 0 10px;
    padding-left: 22px;
}

.ed-prose strong {
    color: var(--pa-ink);
}

.ed-prose em {
    color: var(--pa-ink-mid);
}

/* ── Meta grid (Person hero, Item stats) ─────────────────────────────── */
.meta-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px 18px;
}

.meta-grid--two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meta-grid__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-grid__label {
    font-family: var(--pa-font-cin);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pa-muted);
}

.meta-grid__value {
    font-family: var(--pa-font-lor);
    font-size: 13.5px;
    color: var(--pa-ink);
    line-height: 1.45;
}

/* ── Chip strip (banner meta, faction leader etc.) ───────────────────── */
.chip-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.chip-strip__chip {
    padding: 3px 10px;
    background: rgba(184, 146, 12, 0.18);
    color: #fdf0d0;
    border: 1px solid var(--pa-gold-faint);
    border-radius: 2px;
    font-family: var(--pa-font-cin);
    font-size: 9.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.chip-strip__chip--light {
    background: rgba(115, 0, 0, 0.07);
    color: var(--pa-crimson);
    border-color: rgba(115, 0, 0, 0.22);
}

/* ── Traits row (NPC speech / personality pills) ─────────────────────── */
.traits-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.traits-row__pill {
    display: inline-block;
    padding: 3px 11px;
    background: rgba(115, 0, 0, 0.07);
    border: 1px solid rgba(115, 0, 0, 0.22);
    border-radius: 12px;
    font-family: var(--pa-font-lor);
    font-size: 11.5px;
    color: var(--pa-crimson);
}

.traits-row__group {
    margin-bottom: 10px;
}

.traits-row__label {
    font-family: var(--pa-font-cin);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pa-muted);
    margin-bottom: 4px;
}

/* ── Linked entities (Faction roster, City inns, etc.) ───────────────── */
.linked-entities {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.linked-entities__chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    background: var(--pa-parchment);
    border: 1px solid var(--pa-gold-faint);
    border-radius: 2px;
    font-family: var(--pa-font-lor);
    font-size: 12px;
    color: var(--pa-ink-mid);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s ease;
}

.linked-entities__chip:hover {
    background: rgba(184, 146, 12, 0.14);
}

.linked-entities__chip--inert {
    cursor: default;
    opacity: 0.7;
}

.linked-entities__chip--inert:hover {
    background: var(--pa-parchment);
}

/* ── Faction PEOPLE rows (Temple-style label + value grid) ────────────── */
.faction-people-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    align-items: start;
    gap: 8px 16px;
    padding: 6px 0;
    border-bottom: 1px dashed rgba(184, 146, 12, 0.18);
}

.faction-people-row:last-child {
    border-bottom: none;
}

.faction-people-row__label {
    font-family: var(--pa-font-cin);
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pa-crimson);
    padding-top: 4px;
}

.faction-people-row__value {
    min-width: 0;
}

/* ── Shared-removed banner ────────────────────────────────────────────── */
.shared-removed-banner {
    background: rgba(115, 0, 0, 0.06);
    border-top: 2px solid var(--pa-crimson);
    border-bottom: 1px solid rgba(115, 0, 0, 0.18);
    padding: 9px 22px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.shared-removed-banner__icon {
    font-family: var(--pa-font-cin);
    font-size: 14px;
    color: var(--pa-crimson);
}

.shared-removed-banner__title {
    font-family: var(--pa-font-cin);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--pa-crimson);
}

.shared-removed-banner__sub {
    font-family: var(--pa-font-lor);
    font-size: 11.5px;
    color: var(--pa-muted);
    font-style: italic;
}

/* ── Notes panel (right column) ───────────────────────────────────────── */
.player-notes-panel {
    background: var(--pa-note-bg);
    border-left: 1px solid var(--pa-gold-faint);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.player-notes-panel__header {
    padding: 14px 18px 10px;
    border-bottom: 1px solid var(--pa-gold-faint);
    background: rgba(115, 0, 0, 0.04);
    position: sticky;
    top: 0;
    z-index: 2;
}

.player-notes-panel__header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 5px;
}

.player-notes-panel__title {
    font-family: var(--pa-font-cin);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pa-crimson);
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-notes-panel__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a89880;
    transition: background 0.2s ease;
}

.player-notes-panel__dot--dirty {
    background: #e0a020;
}

.player-notes-panel__dot--saving {
    background: #e0a020;
    animation: pa-pulse 1s ease-in-out infinite;
}

.player-notes-panel__dot--saved {
    background: #2d8a4f;
}

@keyframes pa-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.player-notes-panel__save {
    padding: 4px 14px;
    background: var(--pa-crimson);
    color: #fff;
    border: none;
    border-radius: 2px;
    font-family: var(--pa-font-cin);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.07em;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.12s ease;
}

.player-notes-panel__save:hover:not(:disabled) {
    background: #8a1010;
}

.player-notes-panel__save:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.player-notes-panel__status {
    font-family: var(--pa-font-lor);
    font-size: 10.5px;
    font-style: italic;
    color: var(--pa-muted);
}

.player-notes-panel__body {
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/*
    RTE-internal scroll: the rich-text editor itself becomes the scroll container,
    not the panel body. Matches the DM campaign-notes layout where scrolling occurs
    inside the editor and the toolbar stays anchored at the top.
*/
.player-notes-panel__body .rte-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.player-notes-panel__body .rte-editor {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.player-notes-panel__body .rte-editor .ProseMirror {
    min-height: 100%;
}

.player-notes-panel__empty {
    font-family: var(--pa-font-lor);
    font-size: 12.5px;
    font-style: italic;
    color: var(--pa-muted);
}

/* ── Bookmark / heading-nav popover ───────────────────────────────────── */
.player-notes-panel__bookmark {
    background: transparent;
    border: 1px solid var(--pa-gold-faint);
    border-radius: 2px;
    color: var(--pa-crimson);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 6px;
    transition: background 0.12s ease, border-color 0.12s ease;
}

.player-notes-panel__bookmark:hover:not(:disabled) {
    background: rgba(184, 146, 12, 0.14);
    border-color: var(--pa-gold);
}

.player-notes-panel__bookmark:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.player-notes-panel__bookmark svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.player-notes-panel__bookmark-count {
    margin-left: 4px;
    font-family: var(--pa-font-cin);
    font-size: 9.5px;
    font-weight: 600;
    color: var(--pa-crimson);
    letter-spacing: 0.04em;
}

.notes-nav-popover {
    background: var(--pa-cream);
    border: 1px solid var(--pa-gold-faint);
    border-radius: 2px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    min-width: 260px;
    max-width: 360px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 6px 0;
}

.notes-nav-popover__header {
    padding: 4px 14px 8px;
    border-bottom: 1px solid var(--pa-gold-faint);
    font-family: var(--pa-font-cin);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pa-crimson);
    font-weight: 600;
    margin-bottom: 4px;
}

.notes-nav-popover__empty {
    padding: 12px 14px;
    font-family: var(--pa-font-lor);
    font-size: 12px;
    font-style: italic;
    color: var(--pa-muted);
}

.notes-nav-popover__item {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 6px 14px;
    font-family: var(--pa-font-lor);
    font-size: 13px;
    color: var(--pa-ink-mid);
    cursor: pointer;
    line-height: 1.4;
    border-left: 3px solid transparent;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.notes-nav-popover__item:hover {
    background: rgba(184, 146, 12, 0.1);
    border-left-color: var(--pa-gold);
    color: var(--pa-ink);
}

.notes-nav-popover__item--h1 {
    font-family: var(--pa-font-cin);
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--pa-crimson);
    text-transform: uppercase;
    padding-left: 14px;
}

.notes-nav-popover__item--h2 {
    padding-left: 28px;
    font-weight: 600;
}

.notes-nav-popover__item--h3 {
    padding-left: 42px;
    font-size: 12px;
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1279px) {
    .player-archetype__split {
        flex-direction: column;
    }

    .player-archetype__notes {
        border-left: none;
        border-top: 1px solid var(--pa-gold-faint);
    }
}

@media (max-width: 899px) {
    .player-archetype__notes {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        height: 40vh;
        z-index: 50;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.18);
    }

    .player-archetype__content {
        padding-bottom: calc(40vh + 24px);
    }
}

/* ── Services section (Store / Inn / Temple shared services) ──────────── */
.services-section__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.services-section__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 10px;
    border: 1px solid var(--pa-rule);
    border-radius: 4px;
    background: var(--pa-cream);
}

.services-section__name {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.services-section__entity {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--pa-crimson);
    text-decoration: underline dotted;
    cursor: pointer;
}

.services-section__request {
    background: var(--pa-note-bg);
    border: 1px solid var(--pa-note-border);
    color: var(--pa-note-ink);
    font-family: var(--pa-font-cin);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 3px;
    cursor: pointer;
}

.services-section__price {
    font-family: var(--pa-font-cin);
    color: var(--pa-gold);
    font-weight: 600;
    white-space: nowrap;
}
