/* Home screen (index.html): the menu on the left (☰ collapses it to just the icons) and a working
   elevator in the rest of the page, drawn like a sketched plan: black lines on white, hatched concrete.
   All elevator sizes are parts of --fh, one floor's height (panel-test.js sets it from the screen). */
*,
*::before,
*::after{
    box-sizing: border-box;
}

:root{
    --ink: #111;
    --line: 1.5px solid #111;
    --menu-open: 280px;
    --menu-closed: 68px;   /* collapsed: just the icons */
    --menu: var(--menu-open);
    --fh: 160px;
    --floors: 4;
    /* concrete on a plan: diagonal lines */
    --hatch: repeating-linear-gradient(45deg, #111 0, #111 1px, transparent 1px, transparent 6px);
}

.home-page.menu-collapsed{
    --menu: var(--menu-closed);
}

.home-page{
    margin: 0;
    min-height: 100dvh;
    font-family: 'DM Sans', sans-serif;
    background: #fff;
    color: var(--ink);
    overflow: hidden;
}


.sketch-defs{
    position: absolute;
}

/* everything drawn gets the hand-drawn wobble (each part on its own, so moving the car stays smooth) */
.wall,
.landing,
.rail,
.crosshead,
.stile,
.guide,
.cab,
.platform,
.apron,
.cw-frame,
.bedplate,
.drive-shaft,
.motor,
.sheave,
.slab,
.pit{
    filter: url(#sketch);
}

/* style.css sets a font on every element, so these have to be set directly */
.menu-drawer *{
    font-family: 'DM Sans', sans-serif;
}

.home-words p,
.words-you,
.floor-num,
.cab-indicator,
.cab-indicator *{
    font-family: 'Architects Daughter', 'DM Sans', sans-serif;
}

/* #region hoistway */
/* hidden until home.js has sized the elevator */
.shaft:not(.ready){
    visibility: hidden;
}

.shaft{
    position: fixed;
    top: 0;
    bottom: 0;
    left: var(--menu);
    right: 0;
    overflow: hidden;
    display: flex;
    justify-content: flex-end; /* the elevator as far right as it goes */
    background: #fff;
    transition: left 0.28s cubic-bezier(0.3, 0, 0.2, 1);
}


.home-words{
    display: none;
}

@media (min-width: 1100px){
    .home-words{
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: flex-start; /* lined up on the left, the elevator on the right */
        padding: 0 56px;
        font-family: 'Architects Daughter', 'DM Sans', sans-serif;
    }
}

.home-words p{
    margin: 0;
    color: #111;
}

/* small line over YOU */
.home-words .home-greeting{
    margin-bottom: 12px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #666;
}

/* YOU: big, on its own line, underlined by hand */
.words-you{
    width: fit-content;
    margin-bottom: 0.25em;
    padding: 0 0.25em 0.06em 0;
    font-size: clamp(64px, 6.6vw, 96px);
    line-height: 1;
    border-bottom: 4px solid #111;
    filter: url(#sketch);
}

.home-words .home-line{
    max-width: 340px;
    font-size: clamp(28px, 2.6vw, 36px);
    line-height: 1.25;
}

/* New Job (filled) + Chatevator (outline) */
.home-actions{
    display: flex;
    gap: 10px;
    margin-top: 28px;
}

.home-actions[hidden]{
    display: none;
}

.home-actions .home-btn{
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
    padding: 0 18px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 700;
    color: #111;
    background: #fff;
    border: 1px solid #d5d5d5;
    border-radius: 10px;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.home-actions .home-btn:hover,
.home-actions .home-btn:focus-visible{
    background: #f5f5f5;
    border-color: #111;
    outline: none;
}

.home-actions .home-btn-main{
    color: #fff;
    background: #111;
    border-color: #111;
}

.home-actions .home-btn-main:hover,
.home-actions .home-btn-main:focus-visible{
    background: #333;
    border-color: #333;
}

.home-btn-arrow{
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.home-btn-logo{
    height: 0.9em;
    width: auto;
}

/* machine room 1 floor tall on top, 4 floors, then the pit */
.hoistway{
    position: relative;
    flex-shrink: 0;
    width: calc(var(--fh) * 1.85);
    height: 100%;
    margin-right: calc(var(--fh) * 0.06); /* room for its right wall */
    font-family: 'Architects Daughter', 'DM Sans', sans-serif;
}

/* computer only: a gap between the elevator and the screen's edge */
@media (min-width: 601px){
    .hoistway{
        margin-right: calc(var(--fh) * 0.06 + 48px);
    }
}

/* the concrete walls, cut through */
.wall{
    position: absolute;
    top: 0;
    bottom: 0;
    width: calc(var(--fh) * 0.06);
    background: var(--hatch);
    border-left: var(--line);
    border-right: var(--line);
}

.wall.left{ left: calc(var(--fh) * -0.06); }
.wall.right{ right: calc(var(--fh) * -0.06); }

/* the floor slabs, cut through: wall to wall */
.landing{
    position: absolute;
    left: 0;
    right: 0;
    top: calc(var(--fh) * var(--sill));
    height: calc(var(--fh) * 0.07);
    background: var(--hatch), #fff;
    border-top: var(--line);
    border-bottom: var(--line);
}

/* floor number, hand-lettered */
.floor-num{
    position: absolute;
    left: calc(var(--fh) * 0.06);
    top: calc(var(--fh) * (var(--sill) - 0.32));
    font-size: calc(var(--fh) * 0.2);
    line-height: 1;
    color: #111;
}

/* the steel rails, a bracket holding them to the wall every half floor */
.rail{
    position: absolute;
    top: calc(var(--fh) * 1);
    bottom: calc(var(--fh) * 0.1);
    background: #fff;
    border-left: 1px solid #111;
    border-right: 1px solid #111;
}

.rail::after{
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    right: -60%;
    background: repeating-linear-gradient(180deg,
        transparent 0,
        transparent calc(var(--fh) * 0.48),
        #111 calc(var(--fh) * 0.48),
        #111 calc(var(--fh) * 0.5));
}

.car-rail{ width: calc(var(--fh) * 0.035); }
.car-rail.left{ left: calc(var(--fh) * 0.27); }
.car-rail.right{ left: calc(var(--fh) * 1.19); }

.cw-rail{ width: calc(var(--fh) * 0.025); }
.cw-rail.left{ left: calc(var(--fh) * 1.38); }
.cw-rail.right{ left: calc(var(--fh) * 1.69); }

/* the ropes: 4 thin lines going up out of sight behind the machine room */
.ropes,
.machine-rope{
    position: absolute;
    width: calc(var(--fh) * 0.075);
    background: repeating-linear-gradient(90deg, #111 0, #111 1px, transparent 1px, transparent 25%);
}

.ropes{
    bottom: 100%;
    left: 50%;
    height: calc(var(--fh) * 7);
    transform: translateX(-50%);
}

/* the moving parts: JS sets where they go and how long it takes */
.car,
.counterweight{
    position: absolute;
    top: 0;
    will-change: transform;
    transition: transform var(--trip, 0s) cubic-bezier(0.45, 0.05, 0.55, 0.95);
}
/* #endregion */

/* #region car */
.car{
    left: calc(var(--fh) * 0.3);
    width: calc(var(--fh) * 0.9);
    height: calc(var(--fh) * 0.82);
    z-index: 2;
}

/* the frame (sling) the cab rides in */
.crosshead{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--fh) * 0.07);
    background: #fff;
    border: 2px solid #111;
    z-index: 1;
}

.stile{
    position: absolute;
    top: 0;
    bottom: calc(var(--fh) * 0.03);
    width: calc(var(--fh) * 0.05);
    background: #fff;
    border: var(--line);
}

.stile.left{ left: 0; }
.stile.right{ right: 0; }

/* roller guides running on the rails */
.guide{
    position: absolute;
    width: calc(var(--fh) * 0.07);
    height: calc(var(--fh) * 0.07);
    border-radius: 50%;
    border: var(--line);
    background: radial-gradient(circle closest-side, #111 0 22%, #fff 26% 100%);
    z-index: 2;
}

.guide.top{ top: calc(var(--fh) * 0.08); }
.guide.bottom{ bottom: calc(var(--fh) * 0.06); }
.guide.left{ left: calc(var(--fh) * -0.045); }
.guide.right{ right: calc(var(--fh) * -0.045); }

/* the cab */
.cab{
    position: absolute;
    top: calc(var(--fh) * 0.09);
    bottom: calc(var(--fh) * 0.05);
    left: calc(var(--fh) * 0.05);
    right: calc(var(--fh) * 0.05);
    background: #fff;
    border: 2px solid #111;
}

/* floor indicator over the doors */
.cab-indicator{
    position: absolute;
    top: calc(var(--fh) * 0.014);
    left: 50%;
    transform: translateX(-50%);
    height: calc(var(--fh) * 0.082);
    min-width: calc(var(--fh) * 0.2);
    padding: 0 calc(var(--fh) * 0.025);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--fh) * 0.02);
    border: 1px solid #111;
    background: #fff;
    color: #111;
    font-size: calc(var(--fh) * 0.07);
    line-height: 1;
}

.cab-arrow{
    font-size: 0.7em;
    opacity: 0;
    transition: opacity 0.2s;
}

.car.moving .cab-arrow{
    opacity: 1;
}

.cab-opening{
    position: absolute;
    top: calc(var(--fh) * 0.11);
    bottom: 0;
    left: calc(var(--fh) * 0.07);
    right: calc(var(--fh) * 0.07);
    overflow: hidden;
    border: var(--line);
    border-bottom: none;
}

/* inside the cab: back wall with the corners drawn in, a handrail and the floor */
.cab-inside{
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to top right, transparent calc(50% - 0.5px), #111 calc(50% - 0.5px), #111 calc(50% + 0.5px), transparent calc(50% + 0.5px)) 0 100% / 16% 12% no-repeat,
        linear-gradient(to top left, transparent calc(50% - 0.5px), #111 calc(50% - 0.5px), #111 calc(50% + 0.5px), transparent calc(50% + 0.5px)) 100% 100% / 16% 12% no-repeat,
        #fff;
}

.cab-inside::before{
    content: '';
    position: absolute;
    left: 16%;
    right: 16%;
    top: 0;
    bottom: 12%;
    border-left: 1px solid #111;
    border-right: 1px solid #111;
    border-bottom: 1px solid #111;
}

.cab-rail{
    position: absolute;
    left: 16%;
    right: 16%;
    top: 58%;
    height: calc(var(--fh) * 0.012);
    border-top: 1px solid #111;
    border-bottom: 1px solid #111;
}

/* the two door panels, meeting in the middle */
.door{
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    background: repeating-linear-gradient(90deg,
        rgba(0, 0, 0, 0.22) 0, rgba(0, 0, 0, 0.22) 1px, transparent 1px, transparent 7px), #fff;
    transition: transform 0.9s cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

.door.left{
    left: 0;
    border-right: var(--line);
}

.door.right{
    right: 0;
    border-left: var(--line);
}

.car.open .door.left{ transform: translateX(-92%); }
.car.open .door.right{ transform: translateX(92%); }

/* platform the cab stands on, and the toe guard under it */
.platform{
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--fh) * 0.01);
    height: calc(var(--fh) * 0.04);
    background: var(--hatch), #fff;
    border: 2px solid #111;
}

.apron{
    position: absolute;
    left: calc(var(--fh) * 0.12);
    right: calc(var(--fh) * 0.12);
    bottom: calc(var(--fh) * -0.02);
    height: calc(var(--fh) * 0.03);
    background: #fff;
    border: 1px solid #111;
}
/* #endregion */

/* #region counterweight */
.counterweight{
    left: calc(var(--fh) * 1.42);
    width: calc(var(--fh) * 0.25);
    height: calc(var(--fh) * 0.9);
    z-index: 1;
}

/* steel frame with the stacked weights in it */
.cw-frame{
    position: absolute;
    inset: 0;
    border: 2px solid #111;
    background: repeating-linear-gradient(180deg,
        #fff 0,
        #fff calc(var(--fh) * 0.06),
        #111 calc(var(--fh) * 0.06),
        #111 calc(var(--fh) * 0.066));
}
/* #endregion */

/* #region machine room + pit */
.machine-room{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--fh) * 1);
    z-index: 3;
    background: #fff;
}

/* steel base on the slab: the motor and sheave stand on it */
.bedplate{
    position: absolute;
    left: calc(var(--fh) * 0.02);
    right: calc(var(--fh) * 0.2);
    top: calc(var(--fh) * 0.8);
    height: calc(var(--fh) * 0.1);
    background: #fff;
    border: 2px solid #111;
}

/* motor → sheave */
.drive-shaft{
    position: absolute;
    left: calc(var(--fh) * 0.6);
    width: calc(var(--fh) * 0.55);
    top: calc(var(--fh) * 0.395);
    height: calc(var(--fh) * 0.05);
    background: #fff;
    border-top: var(--line);
    border-bottom: var(--line);
}

/* the ropes coming off the sheave down through the slab (these don't move) */
.machine-rope{
    top: calc(var(--fh) * 0.42);
    bottom: 0;
    transform: translateX(-50%);
}

.machine-rope.car-side{ left: calc(var(--fh) * 0.75); }
.machine-rope.cw-side{ left: calc(var(--fh) * 1.545); }

/* motor with its cooling fins */
.motor{
    position: absolute;
    left: calc(var(--fh) * 0.02);
    width: calc(var(--fh) * 0.62);
    top: calc(var(--fh) * 0.34);
    height: calc(var(--fh) * 0.46);
    border: 2px solid #111;
    border-radius: calc(var(--fh) * 0.05);
    background: repeating-linear-gradient(90deg,
        #fff 0, #fff calc(var(--fh) * 0.04),
        #111 calc(var(--fh) * 0.04), #111 calc(var(--fh) * 0.044));
}

/* the grooved drive wheel the ropes run over: circles */
.sheave{
    position: absolute;
    left: calc(var(--fh) * 0.7475);
    top: calc(var(--fh) * 0.0225);
    width: calc(var(--fh) * 0.795);
    height: calc(var(--fh) * 0.795);
    border-radius: 50%;
    border: 2px solid #111;
    background: radial-gradient(circle closest-side,
        #fff 0 62%,
        #111 62% 63.5%,
        #fff 63.5% 74%,
        #111 74% 75%,
        #fff 75% 80%,
        #111 80% 81%,
        #fff 81% 87%,
        #111 87% 88%,
        #fff 88% 100%);
}

/* spokes + hub: turns while the car moves */
.sheave-spokes{
    position: absolute;
    inset: 18%;
    border-radius: 50%;
    background:
        radial-gradient(circle closest-side, #111 0 10%, #fff 11% 28%, #111 29% 32%, transparent 33%),
        repeating-conic-gradient(#111 0 2deg, transparent 2deg 60deg);
    animation: sheave-turn 2.4s linear infinite;
    animation-play-state: paused;
}

.home-page.going-up .sheave-spokes{
    animation-play-state: running;
}

.home-page.going-down .sheave-spokes{
    animation-direction: reverse;
    animation-play-state: running;
}

@keyframes sheave-turn{
    to{ transform: rotate(360deg); }
}

/* machine room floor */
.slab{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--fh) * 0.1);
    background: var(--hatch), #fff;
    border-top: var(--line);
    border-bottom: var(--line);
}

.pit{
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--fh) * 0.2);
    background: linear-gradient(0deg, transparent 0, transparent 100%);
}

/* compensation ropes: 2 lines each, from the car and the counterweight down into the pit */
.comp-clip{
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--fh) * (var(--floors) + 1.09)); /* ends in the pit */
    overflow: hidden;
    z-index: 1;
}

.comp-rope{
    position: absolute;
    top: 0;
    width: calc(var(--fh) * 0.02);
    height: calc(var(--fh) * 7);
    margin-left: calc(var(--fh) * -0.01);
    border-left: 1px solid #111;
    border-right: 1px solid #111;
    will-change: transform;
    transition: transform var(--trip, 0s) cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

.comp-rope.car-side{ left: calc(var(--fh) * 0.75); }
.comp-rope.cw-side{ left: calc(var(--fh) * 1.47); }

/* the loop they make in the pit (stays put) */
.comp-loop{
    position: absolute;
    top: calc(var(--fh) * 0.08);
    left: calc(var(--fh) * 0.74);
    width: calc(var(--fh) * 0.74);
    height: calc(var(--fh) * 0.08);
    border: 1px solid #111;
    border-top: none;
    border-radius: 0 0 calc(var(--fh) * 0.05) calc(var(--fh) * 0.05);
}

.comp-loop::after{
    content: '';
    position: absolute;
    inset: 0 calc(var(--fh) * 0.02) calc(var(--fh) * 0.02);
    border: 1px solid #111;
    border-top: none;
    border-radius: 0 0 calc(var(--fh) * 0.035) calc(var(--fh) * 0.035);
}

/* the pit floor */
.pit::after{
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--fh) * 0.035);
    background: var(--hatch), #fff;
    border-top: var(--line);
}

/* spring buffers on the pit floor */
.buffer{
    position: absolute;
    bottom: calc(var(--fh) * 0.035);
    width: calc(var(--fh) * 0.09);
    height: calc(var(--fh) * 0.09);
    transform: translateX(-50%);
    border-left: 1px solid #111;
    border-right: 1px solid #111;
    background: repeating-linear-gradient(170deg,
        #111 0, #111 1px, transparent 1px, transparent calc(var(--fh) * 0.02));
}

.buffer.car-side{ left: calc(var(--fh) * 0.5); }
.buffer.cw-side{ left: calc(var(--fh) * 1.6); }
/* #endregion */

/* #region menu (open on the left, collapses to the icons) */
.menu-drawer{
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
    width: var(--menu);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-right: 1px solid #ececec;
    transition: width 0.28s cubic-bezier(0.3, 0, 0.2, 1);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.menu-head{
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 0 11px;
    border-bottom: 1px solid #eee;
}

/* ☰ — collapse / open */
.menu-toggle{
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.menu-toggle span{
    width: 22px;
    height: 2.5px;
    border-radius: 2px;
    background: var(--ink);
}

.menu-toggle:hover,
.menu-toggle:focus-visible{
    background: #f5f5f5;
    border-color: #e5e5e5;
    outline: none;
}

.menu-logo{
    height: 36px;
    width: auto;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

/* waits until it knows your pages, so buttons don't pop in */
.menu-list:not(.ready){
    visibility: hidden;
}

.menu-list{
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

/* one page: [icon] Purchasing — black bar on the left on hover */
.menu-item{
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 54px;
    padding: 0 20px;
    color: #111;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.menu-item[hidden]{
    display: none;
}

.menu-item::before{
    content: '';
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 0 3px 3px 0;
    background: #111;
    opacity: 0;
    transition: opacity 0.15s;
}

.menu-item:hover,
.menu-item:focus-visible{
    background: #fafafa;
    outline: none;
}

.menu-item:hover::before,
.menu-item:focus-visible::before{
    opacity: 1;
}

/* Schedule: a small heading with its pages under it, a little space before the next page */
.menu-group[hidden]{
    display: none;
}

.menu-group{
    margin: 8px 0;
}

.menu-group-title{
    display: flex;
    align-items: center;
    min-height: 28px;
    padding: 0 20px;
    color: #666;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* collapsed: no heading, just the icons */
.menu-collapsed .menu-group-title{
    display: none;
}

/* the page's icon in a small black square, drawn in white */
.menu-icon{
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    color: #fff;
}

.menu-icon svg{
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.menu-name{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}

.menu-arrows{
    height: 0.8em;
    width: auto;
    color: #111;
}

/* collapsed: only ☰ and the icons (names show as a tooltip) */
.menu-collapsed .menu-logo,
.menu-collapsed .menu-name{
    opacity: 0;
    pointer-events: none;
}
/* #endregion */

/* computer: dashboard look — white menu, the page in a rounded white card on light gray
   (the card's margins + border are counted in layout() in home.js) */
@media (min-width: 601px){
    .home-page{
        background: #f7f7f7;
    }

    .shaft{
        top: 28px;
        bottom: 28px;
        left: calc(var(--menu) + 28px);
        right: 28px;
        border: 1px solid #ececec;
        border-radius: 16px;
    }

    /* the menu stays open here, so no ☰; the logo lines up with the headings and icons */
    .menu-toggle{
        display: none;
    }

    .menu-head{
        padding: 0 20px;
        border-bottom: none;
    }
}

/* phones: the open menu goes over the elevator instead of pushing it */
@media (max-width: 600px){
    :root{
        --menu-open: min(260px, 78vw);
        --menu-closed: 60px;
    }

    .shaft{
        left: var(--menu-closed);
    }

    .home-page:not(.menu-collapsed) .menu-drawer{
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.15);
    }

    .menu-head{ padding: 0 7px; }
    .menu-item{ padding: 0 16px; }
    /* the small headings are computer only: here it's one plain list */
    .menu-group{ margin: 0; }
    .menu-group-title{ display: none; }
    .menu-logo{ height: 30px; }
}
