
#stairs {
    margin: 1em 1.5em;
    position: sticky;
    top: 3em;
}

#stairs:has( > .stairs__title) {
    top: 1em;
}

body:has( > #wpadminbar) #stairs {
    top: calc(3em + 32px);
}

body:has( > #wpadminbar) #stairs:has( > .stairs__title) {
    top: calc(1em + 32px);
}

.stairs__title {
    text-align: center;
}

.stairs__render {
    margin: 0 auto;
    max-width: 100%;
    min-width: 100px;
	position: relative;
    transition: width 0.1s linear, height 0.1s linear;
	z-index: 1;
}

#stairs.stairs__toobig .stairs__render {
    height: auto !important;
    width: 50% !important;
}

.stairs__title + .stairs__render {
    margin-top: 3em;
}

.stairs__handrail,
.stairs__step {
    box-sizing: border-box;
    user-select: none;
}

.stairs__handrail {
	background: #0f2c32;
	border: 1px solid #0003;
	border-radius: 0.125em;
	bottom: -0.25em;
	flex: 0 0 1em;
	position: absolute;
	top: -0.25em;
    transition: bottom 0.1s linear;
	width: 1em;
    z-index: 4;
}

.stairs__handrail::before,
.stairs__handrail::after {
    background: #ededed;
    border-radius: 2px;
    border: 1px solid #0f2c32;
    content: '';
    display: none;
    height: 1.5em;
    position: absolute;
    width: 1.5em;
    z-index: 5;
}

.stairs__handrail--left::before,
.stairs__handrail--left::after {
    left: -0.3125em;
}

.stairs__handrail--right::before,
.stairs__handrail--right::after {
    right: -0.3125em;
}

.stairs__handrail--newel-top::before {
    display: block;
    top: -0.75em;
}

.stairs__handrail--newel-bottom::after {
    bottom: -0.75em;
    display: block;
}

.stairs__handrail--left {
    left: -0.5em;
}

.stairs__handrail--right {
    right: -0.5em;
}

.stairs__handrail--spindle {
    background-image: url("../img/spindle.svg");
    background-position: 50% 0.25em;
    background-repeat: repeat-y;
    background-size: 50% var(--spindle-depth);
}

.stairs__handrail--feature {
    bottom: calc(var(--step-height) - 0.25em);
}

.stairs__handrail--doublefeature {
    bottom: calc((var(--step-height) * 2) - 0.25em);
}

.stairs__steps {
    position: relative;
	z-index: 1;
}

.stairs__step {
    align-items: center;
	background: #ddd;
    box-shadow: 0 0 0 1px #91af74;
    box-sizing: content-box;
    border-width: 1px;
    display: flex;
    font-size: 0.75em;
    line-height: 1;
    justify-content: center;
    min-height: 1em;
	position: relative;
    transition: height 0.1s linear;
    width: 100%;
	z-index: var(--z-index);
}

#stairs.stairs__toobig .stairs__step {
    height: 2.5em !important;
    width: 100% !important;
}

#stairs.stairs__toobig .stairs__render .stairs__step:nth-child(7) ~ .stairs__step {
    display: none;
}

#stairs.stairs__toobig .stairs__render .stairs__step:nth-last-child(8) ~ .stairs__step {
    display: block;
}

#stairs.stairs__toobig .stairs__render:after {
    background: linear-gradient(0deg, #ededed0 0, #ededed 0.5em, #ededed calc(100% - 0.5em), #ededed0 100%);
    content: '(unable to accurately display full staircase with selected options)';
    font-size: 0.75em;
    left: -1em;
    line-height: 1.8;
    padding: 1.8em 0.9em;
    position: absolute;
    right: -1em;
    text-align: center;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
}

#step-1 {
    margin-top: calc(var(--step-height) * -1);
    padding-top: var(--step-height);
}

.stairs__step--landing {
    box-shadow: 0 1px 0 0 #91af74;
    color: #0006;
    padding: 1em 0;
}

.stairs__step::before,
.stairs__step::after {
    background: inherit;
    bottom: 0;
    content: '';
    display: none;
    position: absolute;
    top: 0;
    z-index: 1;
}

.stairs__step::before {
    box-shadow: -1px 1px 0 0 #91af74, -1px -1px 0 0 #91af74;
    right: 100%;
    right: calc(100% - 1px);
}

.stairs__step::after {
    box-shadow: 1px 1px 0 0 #91af74, 1px -1px 0 0 #91af74;
    left: 100%;
    left: calc(100% - 1px);
}

.stairs__step--bullnose--left {
    border-bottom-left-radius: calc(var(--step-height) / 2);
}

.stairs__step--curtail--left::before {
    border-top-left-radius: calc(var(--step-height) / 2);
    border-bottom-left-radius: calc(var(--step-height) / 2);
    display: block;
    left: calc(var(--step-height) / -2);
}

#step-1.stairs__step--curtail--left::before {
    top: var(--step-height);
}

.stairs__step--doublecurtail--left::before {
    border-top-left-radius: calc(var(--step-height) / 1);
    border-bottom-left-radius: calc(var(--step-height) / 1);
    display: block;
    left: calc(var(--step-height) * -1);
    top: calc(var(--step-height) * -1);
}

#step-1.stairs__step--doublecurtail--left::before {
    top: 0;
}

.stairs__step--bullnose--right {
    border-bottom-right-radius: calc(var(--step-height) / 2);
}

.stairs__step--curtail--right::after {
    border-top-right-radius: calc(var(--step-height) / 2);
    border-bottom-right-radius: calc(var(--step-height) / 2);
    display: block;
    right: calc(var(--step-height) / -2);
}

#step-1.stairs__step--curtail--right::after {
    top: var(--step-height);
}

.stairs__step--doublecurtail--right::after {
    border-top-right-radius: calc(var(--step-height) / 1);
    border-bottom-right-radius: calc(var(--step-height) / 1);
    display: block;
    right: calc(var(--step-height) * -1);
    top: calc(var(--step-height) * -1);
}

#step-1.stairs__step--doublecurtail--right::after {
    top: 0;
}

.stairs__step--landing {
	background: radial-gradient(ellipse at 50% 100%, #ddd, #ddd 33%, #ededed 66%, #ededed 100%);
    border: none;
    bottom: 100%;
    left: 0;
    padding: 1em 0;
    position: absolute;
    right: 0;
}

.stairs__step {
	line-height: 1.8;
	text-align: center;
}

.stairs__legend {
    font-size: 0.75em;
    line-height: 1;
    position: absolute;
    text-align: center;
    z-index: 3;
}

.stairs__legend:before {
    content: '';
    position: absolute;
    z-index: 1;
}

.stairs__legend--x {
    border-left: 1px dashed #0006;
    border-right: 1px dashed #0006;
    left: 0;
    right: 0;
    top: 100%;
    top: calc(100% + 1em);
}

.stairs__legend--x::before {
    border-top: 1px dashed #0006;
    left: 0;
    right: 0;
    top: 50%;
}

.stairs__legend--y {
    border-bottom: 1px dashed #0006;
    border-top: 1px dashed #0006;
    bottom: 0;
    left: 100%;
    left: calc(100% + 1em);
    top: 0;
    writing-mode: vertical-rl;
}

.stairs__legend--y::before {
    border-left: 1px dashed #0006;
    bottom: 0;
    left: 50%;
    top: 0;
}

.stairs__legend-text {
    background: #ededed;
    position: relative;
    z-index: 3;
}

.stairs__legend-text--x {
    padding: 0.25em 1em;
}

.stairs__legend-text--y {
    padding: 1em 0.25em;
}