/* "Classic" character sheet template. Every measure is the template's own
   pixel geometry on a 210 x 297 mm page; boxes keep the browser's content-box
   sizing on purpose. */

:where(.sheet-page input, .sheet-page textarea, .sheet-page button) {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    outline: 0;
    margin: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    resize: none;
    border-radius: 0;
}

:where(.sheet-page textarea) {
    overflow: hidden;
    display: block;
}

.sheet-page input:focus-visible,
.sheet-page textarea:focus-visible {
    background-color: oklch(0.7 0.085 78 / 0.14);
}

.cl-shape {
    position: absolute;
    inset: 0;
    overflow: visible;
}

.cl-fill-paper { fill: var(--paper); }
.cl-stroke-muted { stroke: var(--ink-muted); }
.cl-stroke-rule { stroke: var(--rule); }
.cl-stroke-red { stroke: var(--red); }
.cl-stroke-red-soft { stroke: oklch(0.52 0.12 32 / 0.45); }
.cl-stroke-blue { stroke: var(--blue); }
.cl-stroke-blue-soft { stroke: oklch(0.47 0.07 255 / 0.4); }

/* Shared pieces -------------------------------------------------------------- */

.cl-label {
    font-family: "IM Fell English SC", serif;
    font-size: 11.5px;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
}

.cl-label--small {
    font-size: 11px;
    letter-spacing: 0.05em;
}

.cl-label--centered {
    text-align: center;
    line-height: 1.15;
}

.cl-label--tight {
    line-height: 1.1;
}

.cl-label--speed {
    font-size: 12.5px;
}

.cl-label--nowrap {
    white-space: nowrap;
}

.cl-initial {
    font-family: "UnifrakturMaguntia", serif;
}

.cl-initial--red { color: var(--red); }
.cl-initial--blue { color: var(--blue); }

.cl-initial-rest {
    font-family: "IM Fell English SC", serif;
}

.cl-legend-text .cl-initial {
    font-size: 25px;
}

.cl-legend-text .cl-initial-rest {
    font-size: 15px;
    letter-spacing: 0.04em;
}

.cl-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cl-field--shrink {
    min-width: 0;
}

.cl-name-input {
    width: 100%;
    font-size: 30px;
    font-weight: 600;
    font-style: italic;
    line-height: 1.15;
    border-bottom: 1px solid var(--rule);
    padding: 0 2px;
}

.cl-box {
    min-height: 0;
    margin: 0;
    border: 1px solid var(--rule);
    border-radius: 6px;
    padding: 2px 14px 12px;
    display: flex;
    flex-direction: column;
}

.cl-legend {
    width: max-content;
    padding: 0 6px;
    line-height: 1;
    white-space: nowrap;
}

.cl-ruled {
    flex: 1;
    width: 100%;
    margin-top: 6px;
    font-size: 17.5px;
    line-height: 29px;
    background-image: repeating-linear-gradient(to bottom, transparent 0 28px, var(--ruling) 28px 29px);
    background-attachment: local;
}

.cl-toggle {
    flex: none;
    cursor: pointer;
    border: 1px solid var(--ink-muted);
    box-shadow: inset 0 0 0 1.5px var(--paper);
    --toggle-on: var(--red);
}

.cl-toggle[aria-pressed="true"] {
    background: var(--toggle-on);
}

.cl-centered-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.cl-shield {
    box-sizing: border-box;
    border-radius: 8px 8px 50% 50% / 8px 8px 58% 58%;
    background: var(--paper);
    display: grid;
    place-items: center;
}

.cl-shield--red {
    width: 62px;
    height: 72px;
    border: 1.5px solid var(--red);
    box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px oklch(0.52 0.12 32 / 0.4);
    padding-bottom: 8px;
}

.cl-shield--blue {
    border: 1.5px solid var(--blue);
    box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px oklch(0.47 0.07 255 / 0.4);
}

.cl-shield--large {
    width: 72px;
    height: 84px;
    padding-bottom: 9px;
}

/* Page one: core --------------------------------------------------------------- */

.cl-core {
    padding: 11mm 11mm 10mm;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.cl-core-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 304px;
    gap: 22px;
}

.cl-core-left {
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.cl-identity {
    display: flex;
    align-items: flex-end;
    gap: 18px;
}

.cl-level {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: none;
    position: relative;
    top: 6px;
}

.cl-level-banner {
    position: relative;
    width: 60px;
    height: 90px;
    display: grid;
    place-items: center;
}

.cl-level-input {
    position: relative;
    margin-top: -14px;
    width: 42px;
    text-align: center;
    font-size: 32px;
    font-weight: 600;
}

.cl-identity-fields {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cl-identity-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 62px;
    gap: 14px;
    position: relative;
    top: 6px;
}

.cl-identity-input {
    width: 100%;
    font-size: 17px;
    font-weight: 600;
    border-bottom: 1px solid var(--rule);
    padding: 0 2px;
}

.cl-abilities {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
}

.cl-ability-pair {
    display: grid;
    grid-template-columns: 140px 140px minmax(0, 1fr);
    column-gap: 14px;
    align-items: start;
}

.cl-ability-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cl-ability-row {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
}

.cl-ability {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: none;
}

.cl-ability-name {
    display: flex;
    align-items: baseline;
    line-height: 1;
    white-space: nowrap;
}

.cl-ability-name .cl-initial {
    font-size: 38px;
}

.cl-ability-name .cl-initial-rest {
    font-size: 18.5px;
    letter-spacing: 0.035em;
    margin-left: 1px;
}

.cl-ability-figures {
    display: flex;
    align-items: center;
    gap: 14px;
    padding-bottom: 12px;
}

.cl-ability-ring {
    position: relative;
    width: 56px;
    height: 56px;
    flex: none;
    border-radius: 50%;
    border: 1.5px solid var(--ink-muted);
    box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 4px var(--rule);
    background: var(--paper);
    display: grid;
    place-items: center;
}

.cl-ability-modifier {
    width: 42px;
    text-align: center;
    font-size: 27px;
    font-weight: 600;
}

.cl-ability-score {
    position: absolute;
    left: 50%;
    bottom: -13px;
    transform: translateX(-50%);
    width: 40px;
    height: 24px;
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    background: var(--field);
    border: 1px solid var(--rule);
    border-radius: 12px;
}

.cl-save {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cl-toggle--save {
    width: 10px;
    height: 10px;
    transform: rotate(45deg);
}

.cl-save-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.cl-save-input {
    width: 32px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid var(--rule);
}

.cl-skills {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.cl-skill {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 23px;
}

.cl-toggle--proficiency {
    width: 9px;
    height: 9px;
    margin: 0 1px;
    transform: rotate(45deg);
}

.cl-toggle--expertise {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    --toggle-on: var(--blue);
}

.cl-skill-input {
    width: 30px;
    flex: none;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    border-bottom: 1px solid var(--rule);
}

.cl-skill-name {
    font-size: 17px;
    font-weight: 500;
    white-space: nowrap;
}

.cl-proficiency {
    justify-self: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding-top: 47px;
}

.cl-octagon {
    position: relative;
    width: 48px;
    height: 48px;
    flex: none;
    display: grid;
    place-items: center;
}

.cl-octagon-layer {
    position: absolute;
    clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}

.cl-octagon-layer--rim { inset: 0; background: oklch(0.62 0.08 72); }
.cl-octagon-layer--paper { inset: 1.5px; background: var(--paper); }
.cl-octagon-layer--gilt { inset: 4px; background: oklch(0.7 0.085 78 / 0.55); }
.cl-octagon-layer--face { inset: 5px; background: var(--paper); }

.cl-octagon-input {
    position: relative;
    width: 32px;
    text-align: center;
    font-size: 21px;
    font-weight: 600;
}

.cl-core-right {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.cl-portrait {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cl-portrait-arch {
    width: 100%;
    height: 262px;
    box-sizing: border-box;
    border: 3px double var(--gilt);
    border-radius: 150px 150px 6px 6px;
    padding: 5px;
}

.cl-portrait-window {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 144px 144px 3px 3px;
    overflow: hidden;
    background: var(--field);
}

.cl-toggle--inspiration {
    position: relative;
    width: 28px;
    height: 28px;
    margin-top: -17px;
    transform: rotate(45deg);
    border: 1.5px solid var(--red);
    background: var(--paper);
    box-shadow: 0 0 0 4px var(--paper);
    --toggle-on: var(--paper);
}

.cl-toggle--inspiration[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    inset: 4px;
    background: var(--red);
}

.cl-inspiration-label {
    margin-top: 9px;
}

.cl-defenses {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.cl-defense-grid {
    display: grid;
    grid-template-columns: auto auto auto;
    justify-content: space-between;
    align-items: center;
    justify-items: center;
    column-gap: 10px;
    row-gap: 5px;
    padding: 0 8px;
}

.cl-emblem {
    position: relative;
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
}

.cl-emblem-input {
    position: relative;
    text-align: center;
    font-weight: 600;
}

.cl-emblem-input--eye {
    margin-top: 2px;
    width: 34px;
    font-size: 25px;
}

.cl-emblem-input--wings {
    margin-top: 8px;
    width: 42px;
    font-size: 27px;
}

.cl-shield-slot {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
}

.cl-shield-input {
    width: 42px;
    text-align: center;
    font-size: 28px;
    font-weight: 600;
}

.cl-speeds {
    display: flex;
    align-items: flex-end;
    justify-content: space-evenly;
    gap: 10px;
    padding: 0 4px;
    position: relative;
    top: 10px;
}

.cl-speed {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.cl-speed-input {
    width: 64px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    border-bottom: 1px solid var(--rule);
}

.cl-hp {
    flex: 1;
    padding: 2px 14px 13px;
    gap: 11px;
}

.cl-hp-figures {
    display: grid;
    grid-template-columns: auto auto auto;
    justify-content: space-evenly;
    align-items: end;
    column-gap: 24px;
    padding-top: 2px;
}

.cl-hp-max {
    width: 84px;
    font-size: 40px;
    line-height: 1.05;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--rule);
}

.cl-hp-temp {
    width: 56px;
    font-size: 26px;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--rule);
}

.cl-hit-die {
    width: 56px;
    font-size: 24px;
    font-weight: 600;
    font-style: italic;
    text-align: center;
    border-bottom: 1px solid var(--rule);
}

.cl-hp-log {
    flex: 1;
    min-height: 60px;
    width: 100%;
    box-sizing: border-box;
    background: oklch(0.915 0.03 80 / 0.7);
    border-radius: 4px;
    padding: 8px 10px;
    font-size: 17px;
    line-height: 1.4;
}

.cl-hp-footer {
    display: flex;
    align-items: flex-end;
    gap: 16px;
}

.cl-dice {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1px;
}

.cl-dice-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.cl-dice-input {
    flex: 1;
    min-width: 0;
    width: 0;
    font-size: 21px;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid var(--rule);
}

.cl-dice-divider {
    font-size: 21px;
    color: var(--ink-muted);
}

.cl-conditions {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cl-conditions-input {
    width: 100%;
    font-size: 21px;
    font-weight: 600;
    font-style: italic;
    border-bottom: 1px solid var(--rule);
    padding: 0 2px;
}

.cl-core-bottom {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr);
    gap: 28px;
}

/* Page two: equipment ----------------------------------------------------- */

.cl-equipment {
    padding: 7mm 11mm 10mm;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.cl-equipment-head {
    display: flex;
    align-items: center;
    gap: 30px;
}

.cl-equipment-name {
    flex: 1;
    min-width: 0;
    padding-top: 8px;
}

.cl-coins {
    display: flex;
    gap: 14px;
    flex: none;
}

.cl-coin {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.cl-coin--pp { --coin-face: oklch(0.9 0.012 230); --coin-edge: oklch(0.62 0.02 230); margin-top: 0; }
.cl-coin--gp { --coin-face: oklch(0.86 0.07 85); --coin-edge: oklch(0.62 0.09 75); margin-top: 8px; }
.cl-coin--sp { --coin-face: oklch(0.91 0.005 90); --coin-edge: oklch(0.64 0.01 90); margin-top: 2px; }
.cl-coin--cp { --coin-face: oklch(0.81 0.065 50); --coin-edge: oklch(0.56 0.08 45); margin-top: 10px; }

.cl-coin-face {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    border: 1.5px solid var(--coin-edge);
    box-shadow: inset 0 0 0 3px var(--coin-face), inset 0 0 0 4.5px var(--coin-edge), inset 0 0 0 11px oklch(0.945 0.022 84 / 0.35);
    background: var(--coin-face);
    display: grid;
    place-items: center;
}

.cl-coin-input {
    width: 62px;
    text-align: center;
    font-size: 22px;
    font-weight: 700;
}

.cl-coin-label {
    letter-spacing: 0.05em;
}

.cl-equipment-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1.2fr) auto minmax(0, 1fr);
    grid-template-areas: "common special" "common attune" "belong comp";
    column-gap: 30px;
    row-gap: 26px;
}

.cl-area-common { grid-area: common; }
.cl-area-special { grid-area: special; }
.cl-area-companions { grid-area: comp; }
.cl-area-belongings { grid-area: belong; }

.cl-attunement {
    grid-area: attune;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 4px 6px 0 14px;
}

.cl-attunement-title {
    line-height: 1;
}

.cl-attunement-row {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 26px;
}

.cl-toggle--attunement {
    width: 13px;
    height: 13px;
    margin: 0 2px;
    transform: rotate(45deg);
    border: 1.5px solid var(--blue);
    box-shadow: inset 0 0 0 2px var(--paper);
    --toggle-on: var(--blue);
}

.cl-attunement-input {
    flex: 1;
    min-width: 0;
    font-size: 16px;
    font-weight: 600;
    font-style: italic;
    border-bottom: 1px solid var(--rule);
    padding: 0 2px;
}

/* Page three: spells ------------------------------------------------------ */

.cl-spellbook {
    padding: 8mm 11mm 10mm;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.cl-spell-head {
    display: flex;
    align-items: flex-end;
    gap: 26px;
}

.cl-spell-name {
    flex: 1;
    min-width: 0;
    padding-bottom: 22px;
}

.cl-spell-ability {
    width: 112px;
    flex: none;
    padding-bottom: 22px;
}

.cl-spell-ability-input {
    width: 100%;
    font-size: 18px;
    font-weight: 600;
    font-style: italic;
    text-align: center;
    border-bottom: 1px solid var(--rule);
}

.cl-spell-ability .cl-label {
    line-height: normal;
}

.cl-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: none;
}

.cl-spell-dc-input {
    width: 48px;
    text-align: center;
    font-size: 32px;
    font-weight: 600;
}

.cl-star {
    position: relative;
    width: 84px;
    height: 84px;
    display: grid;
    place-items: center;
}

.cl-star-layer {
    position: absolute;
}

.cl-star-layer--rim { inset: 0; background: var(--red); }
.cl-star-layer--face { inset: 1.6px; background: var(--paper); }

.cl-star-ring {
    position: absolute;
    inset: 11px;
    border-radius: 50%;
    border: 1px solid oklch(0.52 0.12 32 / 0.45);
}

.cl-star-input {
    position: relative;
    width: 48px;
    text-align: center;
    font-size: 30px;
    font-weight: 600;
}

.cl-slots {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cl-slots-title {
    line-height: 1;
    padding-left: 4px;
}

.cl-slots-grid {
    display: grid;
    grid-template-columns: 56px repeat(5, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
}

.cl-slots-key {
    display: grid;
    grid-template-rows: 38px 52px 1fr;
    padding-bottom: 10px;
}

.cl-slots-key-label {
    align-self: center;
}

.cl-slot {
    display: grid;
    grid-template-rows: 30px 52px auto;
    justify-items: center;
    row-gap: 0;
    border: 1px solid var(--rule);
    border-radius: 60px 60px 5px 5px;
    padding: 8px 10px 10px;
}

.cl-slot--red { --slot-accent: var(--red); --slot-soft: oklch(0.52 0.12 32 / 0.5); }
.cl-slot--blue { --slot-accent: var(--blue); --slot-soft: oklch(0.47 0.07 255 / 0.5); }

.cl-slot-numeral {
    font-family: "IM Fell English SC", serif;
    font-size: 20px;
    letter-spacing: 0.02em;
    line-height: 30px;
    color: var(--slot-accent);
}

.cl-slot-hex {
    position: relative;
    width: 68px;
    height: 48px;
    align-self: center;
    display: grid;
    place-items: center;
}

.cl-slot-hex-inner {
    stroke: var(--slot-soft);
}

.cl-slot-total {
    position: relative;
    width: 44px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
}

.cl-slot-used {
    width: 100%;
    margin-top: 6px;
    height: 46px;
    font-size: 16px;
    line-height: 22px;
    text-align: center;
    background: oklch(0.915 0.03 80 / 0.7);
    border-radius: 3px;
}

.cl-prepared {
    flex: 1;
    padding: 2px 14px 10px;
}

.cl-spell-columns {
    display: grid;
    grid-template-columns: 44px minmax(0, 190px) minmax(0, 1fr);
    gap: 16px;
}

.cl-spell-columns--head {
    padding: 6px 0 4px;
    font-family: "IM Fell English SC", serif;
    font-size: 11.5px;
    letter-spacing: 0.05em;
    color: var(--ink-muted);
}

.cl-spell-column-level {
    text-align: center;
}

.cl-spell-rows {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.cl-spell-row {
    flex: 1;
    min-height: 0;
    align-items: end;
    border-bottom: 1px solid oklch(0.74 0.04 72 / 0.55);
    padding-bottom: 2px;
}

.cl-spell-level {
    width: 100%;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--red);
}

.cl-spell-row-name {
    width: 100%;
    font-size: 18px;
    font-weight: 600;
}

.cl-spell-notes {
    width: 100%;
    font-size: 16.5px;
    font-weight: 500;
    font-style: italic;
}
