/*
 * The desk calendar (includes/pieces/desk.php): a flip calendar on a stone desk. A board-black backing
 * board, card leaves on steel wire rings, each leaf a month's payment (the day in big figures, the
 * month's little calendar with the day ringed in the group's colour, why it falls there). Leaves turn
 * up and over the rings (CSS 3D, hinged at the top). Beside it, the year as a timetable column.
 */

.desk { --pick: #d02b2b; --card: #f7f2e5; --ink-c: #15171a; --ink-c2: #3c4148; --turn: transform .78s cubic-bezier(.45, .05, .25, 1); display: grid; gap: 18px; }
.desk[data-group="wed3"] { --pick: #1d6cb4; }
.desk[data-group="wed4"] { --pick: #11865a; }
.desk[data-group="third"] { --pick: #7446a6; }
.desk[data-group="ssi"] { --pick: #e0690b; }
.desk__head, .desk__wd, .desk__mm, .desk__ct, .desk__k, .desk__legend, .desk__opt span, .desk__early, .desk__leaf.is-moved .desk__why::before { font-family: var(--board-font); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

/* The desk top, lit from above; the backing board and its shadow. */
.desk__stage { padding: 30px 22px 40px; border-radius: 10px; background: radial-gradient(120% 90% at 50% 0%, #f1ece1, #e2dbcc 70%, #d6cebd); box-shadow: inset 0 1px 0 #fffb, inset 0 -2px 0 #0001; }
.desk__cal { position: relative; max-width: 430px; margin: 0 auto; padding-top: 14px; }
.desk__stand { position: absolute; inset: 0 -12px -16px; border-radius: 7px 7px 5px 5px; background: linear-gradient(#2b2f35, #191b1f 40%, #111316); box-shadow: inset 0 1px 0 #fff2, 0 2px 0 #08090a, 0 34px 34px -22px #1e16088c, 0 10px 14px -8px #1e160859; }
.desk__stand::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: 5px; height: 6px; border-radius: 3px; background: linear-gradient(#3a3f46, #1e2125); }

/* The pad: the leaves in one place, the first on top; the leaves still to come as a thickness at its foot. */
.desk__pad { --left: 0; position: relative; display: grid; perspective: 1100px; perspective-origin: 50% 12%; margin-bottom: calc(var(--left) * 1.3px + 14px); }
.desk__pad::after { content: ""; position: absolute; left: 2px; right: 2px; top: calc(100% - 2px); height: calc(var(--left) * 1.3px + 2px); border-radius: 0 0 4px 4px; background: repeating-linear-gradient(#f3eddf 0 .8px, #c9bfa9 .8px 1.3px); box-shadow: 0 2px 2px #0005; transition: height .5s; }
.desk__leaf { grid-area: 1 / 1; position: relative; z-index: var(--z, 1); transform-origin: 50% 0; transform-style: preserve-3d; transition: var(--turn), visibility 0s; }
.desk__leaf.is-turned { transform: rotateX(172deg); visibility: hidden; transition: var(--turn), visibility 0s .78s; }
/* Opacity on the faces, never on the leaf: a leaf with opacity is drawn flat, and would show its print from behind. */
.desk__front, .desk__back { border-radius: 3px 3px 6px 6px; backface-visibility: hidden; transition: opacity .2s; }
.desk__leaf.is-turned > * { opacity: 0; transition: opacity .26s ease .36s; }
.desk__front { position: relative; height: 100%; padding: 20px 18px 14px; color: var(--ink-c); background: linear-gradient(#fbf8f0, var(--card) 18% 86%, #efe8d6); box-shadow: inset 0 0 0 1px #0001, 0 1px 1px #0003; }
.desk__back { position: absolute; inset: 0; transform: rotateX(180deg); background: linear-gradient(#e9e2cf, #ddd4bd); }

/* The steel wire rings, each into its punched hole. */
.desk__rings { position: absolute; z-index: 60; top: 1px; left: 16px; right: 16px; display: flex; justify-content: space-around; pointer-events: none; }
.desk__rings i { position: relative; width: 8px; height: 24px; border: 2.5px solid #8d939b; border-bottom: 0; border-top-color: #f1f3f5; border-left-color: #c9ced4; border-radius: 5px 5px 3px 3px; box-shadow: 1px 0 1px #0005; }
.desk__rings i::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 8px; margin-left: -5px; border-radius: 50%; background: radial-gradient(closest-side, #0d0e10 60%, #2c2f34 85%, #2c2f3400); }

/* A leaf's print. */
.desk__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 8px 0 0; padding: 8px 12px 6px; border-radius: 3px; border-bottom: 5px solid var(--pick); background: #15171a; color: #f3efe5; font-size: 1.15rem; line-height: 1.15; letter-spacing: .1em; transition: border-color .4s; }
.desk__head span:last-child, .desk__cy, .desk__early { color: #f5c21b; }
.desk__face { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 6px 16px; padding: 14px 2px 10px; }
.desk__big { display: grid; justify-items: start; margin: 0; transform-origin: 50% 0; }
.desk__num { font: 700 clamp(5.6rem, 3.2rem + 7vw, 8.4rem)/.8 var(--board-font); font-variant-numeric: tabular-nums; }
.desk__wd { margin-top: 10px; font-size: 1.45rem; line-height: 1; }
.desk__md { margin-top: 6px; font-size: 1rem; line-height: 1.3; color: var(--ink-c2); }
.desk__leaf.is-swap .desk__big { animation: desk-print .5s cubic-bezier(.3, .2, .2, 1) both; }
@keyframes desk-print { from { transform: rotateX(-80deg); opacity: 0; } }
.desk__mini { min-width: 0; }
.desk__mm { margin: 0 0 4px; font-size: 1rem; line-height: 1.2; text-align: center; }
.desk__grid { position: relative; display: grid; grid-template-columns: repeat(7, 1.75em); grid-auto-rows: 1.6em; font: 700 .95rem/1.6em var(--board-font); text-align: center; color: var(--ink-c2); }
.desk__grid i { font-style: normal; font-variant-numeric: tabular-nums; }
.desk__grid .desk__wk { border-bottom: 1px solid #cfc6b1; }
.desk__grid .desk__wk, .desk__grid .is-pay { color: var(--ink-c); }
.desk__grid .is-due { color: #8a2016; text-decoration: line-through 2px; }
.desk__ring { position: absolute; left: 0; top: 0; width: 1.75em; height: 1.6em; border-radius: 50%; box-shadow: 0 0 0 3px var(--pick); transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%)); transition: transform .6s cubic-bezier(.3, .1, .2, 1); }
.desk__why { margin: 0; padding-top: 10px; border-top: 1px dashed #c4baa4; font-size: 1rem; line-height: 1.4; color: var(--ink-c2); }
.desk__leaf.is-moved .desk__why { color: var(--ink-c); }
.desk__leaf.is-moved .desk__why::before { content: "Early"; margin-right: 8px; padding: 2px 7px 1px; border-radius: 3px; background: #15171a; color: #f5c21b; font-size: .95rem; }

/* The cover. */
.desk__cover .desk__front { display: grid; align-content: center; justify-items: center; gap: 6px; padding-top: 34px; background: linear-gradient(#2a2d33, #121417); color: #f3efe5; box-shadow: inset 0 0 0 1px #000, inset 0 2px 0 #fff2; }
.desk__cover .desk__front::before { content: ""; position: absolute; inset: 14px; border: 2px solid #3a3f46; border-radius: 4px; }
.desk__cover p { margin: 0; }
.desk__cy { font: 700 clamp(5rem, 3rem + 6vw, 7.5rem)/.85 var(--board-font); }
.desk__ct { font-size: 1.6rem; line-height: 1; letter-spacing: .14em; }
.desk__cs { font-size: 1rem; color: #c9c4ba; }

/* The year, as a timetable column; the row on the desk is lit. */
.desk__k { margin: 0 0 8px; font-size: 1.05rem; line-height: 1.25; color: var(--ink); }
.desk__year { margin: 0; padding: 0; list-style: none; border-top: 2px solid var(--ink); }
.desk__row { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; padding: 7px 10px; border-bottom: 1px solid var(--stone-2); font-size: 1rem; line-height: 1.3; color: var(--ink); }
.desk__rm { font-weight: 600; }
.desk__rv { display: inline-flex; align-items: baseline; gap: 8px; font: 700 1.12rem/1.2 var(--board-font); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.desk__early { padding: 2px 6px 1px; border-radius: 3px; background: #15171a; font-size: .95rem; line-height: 1.1; }
.desk__row.is-on { background: #15171a; color: #f3efe5; border-bottom-color: #15171a; box-shadow: inset 5px 0 0 var(--pick); }
.desk__row.is-on .desk__rv { color: #f5c21b; }
.desk__row.is-on .desk__early { background: #f5c21b; color: #1b1600; }
.desk__hit { position: absolute; inset: 0; width: 100%; margin: 0; padding: 0; border: 0; background: none; cursor: pointer; }
.desk__hit:focus-visible { outline: 3px solid var(--signal); outline-offset: -3px; box-shadow: none; border-radius: 0; }
.desk__row:hover:not(.is-on):has(.desk__hit) { background: var(--stone); }

/* The controls: the groups as push-in tabs, and the two turning buttons. */
.desk__ctrl { display: grid; gap: 14px; }
.desk__groups { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; margin: 0; padding: 0; border: 0; }
.desk__legend { width: 100%; margin: 0 0 2px; padding: 0; font-size: 1.05rem; color: var(--ink); }
.desk__opt { position: relative; display: inline-flex; }
.desk__opt input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.desk__opt span { display: inline-flex; align-items: center; min-height: 44px; padding: 8px 14px; border-radius: 8px; background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 2px var(--stone-2), 0 2px 0 var(--stone-2); font-size: 1.02rem; line-height: 1.15; letter-spacing: .05em; }
.desk__opt input:checked + span { background: #15171a; color: #f3efe5; box-shadow: inset 0 -4px 0 var(--pick), 0 1px 0 #000; transform: translateY(1px); }
.desk__opt input:focus-visible + span { outline: 3px solid var(--signal); outline-offset: 2px; }
.desk__turn { display: flex; flex-wrap: wrap; gap: 10px; }
.desk__turn .p-btn--quiet { color: var(--ink); }
.desk__turn .p-btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.desk__say { margin: 0; font-size: 1.06rem; line-height: 1.5; color: var(--ink); }

/* The page's own list spacing (.prose ol, .prose li) does not apply inside the drawing. */
.piece .desk__year, .piece .desk__row { margin: 0; }
@media (min-width: 700px) {
	.desk { grid-template-columns: minmax(0, 1fr) 238px; column-gap: 22px; align-items: start; }
	.desk__stage { padding: 34px 30px 44px; }
	.desk__side { grid-column: 2; grid-row: 1 / span 2; }
	.desk__wrap { grid-column: 1; grid-row: 2; }
	.desk__say { grid-column: 1 / -1; }
}
@media (max-width: 699px) {
	.desk__year { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 10px; }
	.desk__row { padding: 6px 8px; }
}
@media (max-width: 400px) {
	.desk__stage { padding: 24px 14px 34px; margin-inline: -4px; }
	.desk__front { padding: 18px 12px 12px; }
	.desk__face { gap: 4px 10px; }
	.desk__grid { grid-template-columns: repeat(7, 1.5em); }
	.desk__ring { width: 1.5em; }
	.desk__head { padding: 7px 9px 5px; font-size: 1.05rem; }
	.desk__wd { font-size: 1.1rem; letter-spacing: .03em; }
}
@media (max-width: 360px) {
	.desk__face { grid-template-columns: minmax(0, 1fr); justify-items: center; }
	.desk__big { grid-template-columns: auto auto; align-items: end; column-gap: 12px; }
	.desk__num { grid-row: span 2; }
	.desk__wd { margin-top: 0; }
}
@media (prefers-color-scheme: dark) {
	.desk__stage { background: radial-gradient(120% 90% at 50% 0%, #3a3c40, #2a2c30 70%, #212326); box-shadow: inset 0 1px 0 #fff1; }
	.desk__stand { box-shadow: inset 0 1px 0 #fff2, 0 2px 0 #000, 0 34px 34px -22px #000c; }
	.desk__row.is-on, .desk__opt input:checked + span { background: #f3efe5; color: #15171a; border-bottom-color: #f3efe5; }
	.desk__row.is-on .desk__rv { color: #15171a; }
}
@media (prefers-reduced-motion: reduce) {
	.desk__leaf, .desk__leaf.is-turned, .desk__leaf > *, .desk__ring, .desk__pad::after { transition: none; }
	.desk__leaf.is-swap .desk__big { animation: none; }
}
