/*
 * Tapestry: bands woven across the page. A shield-shaped portrait heads the
 * crest, the six abilities stand in a row of columns under lozenge modifiers,
 * combat and vitals share one tinted band, and the notes run full width.
 */

.tapestry-page {
    display: flex;
    flex-direction: column;
    gap: 5mm;
}

.tapestry-page .sheet-toggle-mark {
    border-radius: 0.7mm;
    transform: none;
}

.tapestry-page .sheet-input {
    border-radius: 0;
}

.tapestry-page .sheet-textarea {
    border-radius: 0;
}

/* The band is woven: two fine diagonal threads over the tint. */
.tapestry-band {
    padding: 3.4mm 4mm;
    background-color: var(--card-accent-soft);
    background-image:
        repeating-linear-gradient(45deg, var(--card-accent-soft) 0 0.25mm, transparent 0.25mm 1.6mm),
        repeating-linear-gradient(-45deg, var(--card-accent-soft) 0 0.25mm, transparent 0.25mm 1.6mm);
}

.tapestry-band .sheet-input,
.tapestry-band .sheet-textarea {
    background: transparent;
    box-shadow: inset 0 0 0 0.25mm var(--card-rule);
}

.tapestry-cells {
    display: flex;
    gap: 3mm;
}

.tapestry-cells .sheet-slot {
    flex: 1;
}

.tapestry-cells .sheet-slot-label {
    text-align: center;
}

.tapestry-cells .sheet-input {
    text-align: center;
}

/* ---------- the crest ---------- */

.tapestry-crest {
    display: grid;
    grid-template-columns: 44mm 1fr;
    column-gap: 8mm;
    align-items: start;
}

.tapestry-crest-plain {
    grid-template-columns: 1fr auto;
    align-items: end;
}

.tapestry-crest-plain .tapestry-cells {
    width: 70mm;
}

.tapestry-shield {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2mm;
}

.tapestry-shield .sheet-portrait {
    position: relative;
}

.tapestry-shield .sheet-portrait::before {
    content: "";
    position: absolute;
    inset: -0.7mm;
    background: var(--card-rule);
    clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
}

.tapestry-page .sheet-portrait-frame {
    position: relative;
    z-index: 1;
    width: 44mm;
    height: 50mm;
    border: none;
    border-radius: 0;
    clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
}

.tapestry-title {
    display: flex;
    flex-direction: column;
    gap: 3.5mm;
    padding-top: 2mm;
}

.tapestry-identity {
    display: flex;
    gap: 4mm;
}

.tapestry-identity .sheet-slot {
    flex: 1;
}

.tapestry-identity .identity-level {
    flex: none;
    width: 12mm;
}

/* ---------- six ability columns ---------- */

.tapestry-abilities {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    column-gap: 2.5mm;
    align-items: start;
}

.tapestry-abilities .ability-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.6mm;
    min-width: 0;
}

.tapestry-lozenge {
    display: grid;
    place-items: center;
    width: 13mm;
    height: 13mm;
    margin: 3mm 0;
    background: var(--card-accent-soft);
    box-shadow: inset 0 0 0 0.3mm var(--card-rule);
    transform: rotate(45deg);
}

.tapestry-lozenge .sheet-slot {
    width: 100%;
    height: 100%;
    justify-content: center;
}

.tapestry-lozenge .ability-modifier .sheet-input {
    padding: 0;
    font-size: 16pt;
    background: transparent;
    box-shadow: none;
    transform: rotate(-45deg);
}

.tapestry-abilities .ability-name {
    font-size: 7pt;
    text-align: center;
    white-space: nowrap;
}

.tapestry-ability-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1mm;
}

.tapestry-ability-foot .ability-score {
    width: 10mm;
}

.tapestry-ability-foot .ability-score .sheet-input {
    box-shadow: inset 0 0 0 0.22mm var(--card-rule);
}

.tapestry-ability-foot .ability-save {
    gap: 1mm;
}

.tapestry-ability-foot .ability-save-value {
    width: 8mm;
}

.tapestry-abilities .skill-list {
    width: 100%;
    gap: 1mm;
}

.tapestry-abilities .skill-row {
    gap: 0.8mm;
}

.tapestry-abilities .skill-marks {
    flex-direction: column;
    gap: 0.5mm;
}

.tapestry-abilities .sheet-toggle,
.tapestry-abilities .sheet-toggle-mark {
    width: 2.6mm;
    height: 2.6mm;
}

.tapestry-abilities .skill-modifier {
    width: 6.5mm;
}

.tapestry-abilities .skill-name {
    font-size: 6.8pt;
}

.tapestry-abilities .ability-aside {
    width: 100%;
    gap: 1.6mm;
    padding-top: 1mm;
}

.tapestry-abilities .aside-slot .sheet-slot-label {
    text-align: center;
    white-space: normal;
    line-height: 1.2;
}

/* ---------- the combat band ---------- */

.tapestry-combat {
    display: grid;
    grid-template-columns: 1fr 58mm;
    column-gap: 5mm;
    align-items: stretch;
}

.tapestry-combat .tapestry-cells {
    grid-column: 1;
}

.tapestry-combat .tapestry-cells + .tapestry-cells {
    margin-top: 2.4mm;
}

.tapestry-combat .damage-log {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.tapestry-combat .armor-class .sheet-input,
.tapestry-combat .hit-points .sheet-input {
    font-family: var(--card-title-font);
    font-weight: var(--card-title-weight);
    font-size: 14pt;
    color: var(--card-accent);
}

.tapestry-combat .conditions {
    flex: 1.6;
}

.tapestry-page > .sheet-area {
    flex: 1;
}

.tapestry-page .sheet-area-title {
    text-align: center;
}

/* ---------- page two ---------- */

.tapestry-treasury {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 10mm;
    align-items: center;
}

.tapestry-treasury .attunement {
    gap: 2mm;
}

.tapestry-treasury .attunement-slots {
    flex-direction: column;
    gap: 2mm;
}

.tapestry-treasury .attunement-name .sheet-input {
    text-align: left;
}

.tapestry-page > .tapestry-stores {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 8mm;
    flex: 1;
    min-height: 0;
}

.tapestry-equipment > .sheet-area:first-of-type {
    flex: 1.5;
}

.tapestry-equipment > .sheet-area:last-of-type {
    flex: 0.8;
}

/* ---------- page three: pennants ---------- */

.tapestry-pennants {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    column-gap: 2.5mm;
}

.tapestry-pennants .spell-slot {
    position: relative;
    flex-direction: column;
    gap: 1.6mm;
}

.tapestry-pennants .spell-slot::before {
    content: "";
    position: absolute;
    top: -0.7mm;
    left: -0.7mm;
    right: -0.7mm;
    height: 15.4mm;
    background: var(--card-rule);
    clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%);
}

.tapestry-pennants .spell-slot-level {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 100%;
    height: 14mm;
    padding-bottom: 2mm;
    font-size: 13pt;
    background: var(--card-accent-soft);
    clip-path: polygon(0 0, 100% 0, 100% 68%, 50% 100%, 0 68%);
}

.tapestry-pennants .spell-slot-total {
    width: 10mm;
}

.tapestry-pennants .spell-slot-total .sheet-input {
    box-shadow: inset 0 0 0 0.25mm var(--card-rule);
}

.tapestry-pennants .spell-slot-expended {
    width: 100%;
    flex: none;
}

.tapestry-pennants .spell-slot-expended .sheet-input {
    text-align: center;
}

.tapestry-page .spell-table-head,
.tapestry-page .spell-row {
    grid-template-columns: 11mm 48mm 1fr;
}
