@import url('https://fonts.googleapis.com/css2?family=Chocolate+Classical+Sans&display=swap');

:root {
    --cell-size: 21px;
    --bordered-cell-size: calc(var(--cell-size) + 1px);

    --accent: #7c67f6;

    --bg: #edecf0;
    --input: #13111d0a;
    --gentle: #13111d44;
    --text: #13111d;
}

* {
    box-sizing: border-box;
    margin: 0;
    user-select: none;
    transform-origin: center center;
    font-family: "Chocolate Classical Sans", sans-serif;
}

body {
    width: 100dvw;
    height: 100dvh;
    font-size: large;
    line-height: var(--cell-size);
    background: var(--bg);
    color: var(--text);
}

#app {
    margin: auto;
    height: max(100dvh, min(100dvw, 500px));
    width: min(100dvw, 500px);
    box-shadow: 0 0 4px #00000044;
}

#calendar {
    width: 100%;
    height: 65%;
    overflow: auto;
    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: auto auto;
    position: relative;
}

#dates, #times, #corner {
    z-index: 5;
    background: var(--bg);
}

#selection-h, #selection-v {
    position: absolute;
    display: block;
    width: 0;
    height: 0;
    top: 0;
    left: 0;
    pointer-events: none;
}

#selection-h {
    width: min(100dvw, 500px);
    border-bottom: 2px solid #27273230;
    transform: translateY(calc(var(--cell-size) / 2 - 1px));
}

#selection-v {
    height: 65dvh;
    border-right: 2px solid #27273230;
    transform: translateX(calc(var(--cell-size) / 2 - 1px));
}

#corner {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 9;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    cursor: pointer;
}

#yearslot {
    font-size: x-large;
    font-weight: bold;
}

#corner-icons {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: small;
}

#corner-icons svg {
    width: 2ch;
}

#dates {
    position: sticky;
    left: 0;
}

#times {
    position: sticky;
    top: 0;
    display: grid;
    grid-template-columns: calc(var(--bordered-cell-size) / 2) repeat(47, calc(var(--bordered-cell-size))) calc(var(--bordered-cell-size) / 2);
}

#grid {
    background: var(--bg);
    height: calc(var(--bordered-cell-size) * 365);
    overflow: hidden;
    position: relative;
}

#times div, #dates div{
    border: 1px solid var(--gentle);
}

#dates div, #times div {
    white-space: nowrap;
    text-align: right;
    padding: 0;
}

#times div {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    border-top-width: 0;
    padding: 0.5ch 0;
    border-right-color: transparent;
    border-left-width: 0;
    border-right-width: 0;
}

#times div:nth-child(2) {
    border-left-width: 0;
    width: calc(var(--bordered-cell-size) / 2);
    overflow: hidden;
}

#times div:last-child {
    width: calc(var(--bordered-cell-size) / 2);
    overflow: hidden;
    display: flex;
    justify-content: end;
    align-items: end;
}

#times div:nth-child(2n-1) {
    color: var(--gentle);
}

#corner {
    border: 1px solid var(--gentle);
    border-top-width: 0;
    border-left-width: 0;
}

#dates div {
    height: var(--bordered-cell-size);
    border-top-width: 0;
    border-left-width: 0;
    padding: 0 0.5ch;
}

#dates div:last-child {
    border-bottom-width: 0;
}

#canvas {
    width: 100%;
    height: 100%;
}

#selection {
    border-width: 2px;
    border-style: solid;
    animation: pulse 1s linear infinite;
    width: calc(var(--bordered-cell-size) + 1px);
    height: calc(var(--bordered-cell-size) + 1px);
    position: absolute;
    z-index: 4;
}

@keyframes pulse {
    0% {border-color: #27273250}
    50% {border-color: #27273220}
    100% {border-color: #27273250}
}

#modal-wrapper, #mini-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: 100dvw;
    background: var(--gentle);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#modal, #mini-modal {
    max-height: 90dvh;
    width: calc(min(100dvw, 500px) - 10dvh);
    background: var(--bg);
    padding: 3ch;
    border-radius: 3ch;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#mini-modal {
    max-height: 80dvh;
    width: calc(min(100dvw, 500px) - 5dvh);
}

.modal-x {
    width: fit-content;
    align-self: end;
}

#mini-modal-inner {
    overflow: auto;
    max-height: 100%;
}

.tabset {
    width: 100%;
    overflow: auto;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border-top-right-radius: 0.5ch;
    border-top-left-radius: 0.5ch;
    flex-shrink: 0;
}

.tabhead {
    padding: 0.5ch 1ch;
    white-space: nowrap;
    border-bottom: 1px solid var(--gentle);
    text-align: center;
}

#modal.settings .tabhead.settings, #modal.colors .tabhead.colors, #modal.what .tabhead.what {
    border: 1px solid var(--gentle);
    border-top-right-radius: 0.5ch;
    border-top-left-radius: 0.5ch;
    border-bottom-width: 0;
    background: var(--bg);
}

.tab {
    display: none;
    flex-direction: column;
    gap: 1ch;
    margin-top: 1ch;
    overflow: auto;
    max-height: 100%;
}

#modal.settings .tab.settings, #modal.colors .tab.colors, #modal.what .tab.what {
    display: flex
}

a {
    color: var(--accent);
}

.center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1ch;
}

.button {
    background: var(--accent);
    padding: 0.5ch;
    border-radius: 0.5ch;
    color: var(--bg);
    text-align: center;
    cursor: pointer;
    position: relative;
    font-size: large;
}

.button:active {
    transform: translateY(1px);
}

#palette {
    width: 100%;
    height: 35%;
    border-top: 1px solid var(--gentle);
    transform: translateY(-1px);
}

.panel {
    display: none;
    width: 100%;
    height: 100%;
    padding: 1ch;
    gap: 1ch;
    flex-direction: column;
    flex-wrap: wrap;
}

.panel .button {
    min-height: calc((100% - 2ch) / 3);
    min-width: calc((100% - 3ch) / 4);
    flex-grow: 1;
    flex-shrink: 0;
}

.panel .button.selected {
    box-shadow: 0 0 3px #0008;
}

.shadowed {
    box-shadow: 0 0 5px #000c;
}

.button-label {
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    white-space: nowrap;
    overflow: hidden;
    padding: 0.5ch;
}

.button.dark-text {
    color: var(--text);
}

.parent-button::after {
    content: '';
    background: var(--bg);
    display: block;
    width: 1ch;
    height: 1ch;
    border-radius: 50%;
    position: absolute;
    bottom: 1ch;
    right: 1ch;
}

.parent-button.dark-text::after {
    background: var(--text);
}

#palette.panel-home #panel-home {display: flex;}
#palette.panel-0 #panel-0 {display: flex;}
#palette.panel-1 #panel-1 {display: flex;}
#palette.panel-2 #panel-2 {display: flex;}
#palette.panel-3 #panel-3 {display: flex;}
#palette.panel-4 #panel-4 {display: flex;}
#palette.panel-5 #panel-5 {display: flex;}
#palette.panel-6 #panel-6 {display: flex;}
#palette.panel-7 #panel-7 {display: flex;}
#palette.panel-8 #panel-8 {display: flex;}
#palette.panel-9 #panel-9 {display: flex;}
#palette.panel-10 #panel-10 {display: flex;}
#palette.panel-11 #panel-11 {display: flex;}

#color-config {
    max-width: 100%;
    font-size: small;
}

.sub-activities {
    padding-left: calc(1.5em + 1ch);
}

.activities, .sub-activities, .col-gap {
    display: flex;
    flex-direction: column;
    gap: 1ch;
}

.activity {
    display: flex;
    gap: 1ch;
    align-items: center;
    padding: 0 1px;
    border-radius: 2px;
    max-width: 100%;
}

.swatch {
    outline: 1px solid var(--gentle);
    border-radius: 50%;
    width: 1.5em;
    height: 1.5em;
    display: inline-block;
}

.activity > *:not(input) {
    flex-shrink: 0;
}

input[type=text] {
    appearance: none;
    min-width: 0;
    width: 100dvw;
    outline: 0;
    border: 0;
    background: var(--input);
    color: var(--text);
    padding: 0.5ch 1ch;
    border-radius: 0.5ch;
}

input[type=text]::placeholder {
    color: var(--gentle);
}

.swatches {
    font-size: xx-large;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1ch;
    justify-content: center;
    padding: 6px 0;
}

.swatches .swatch {
    margin: 0 calc((((100% - 2ch) / 3) - 1.5em) / 2);
}

.button-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1ch;
}

.activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .button-pair,
.sub-activities .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .activity ~ .button {
    display: none;
}

.act-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.x-button, .delete, #warning {
    color: hsl(355, 74%, 57%);
}

.select-activity {
    display: flex;
    flex-wrap: wrap;
    gap: 1ch;
    margin-top: 1em;
}

.select-activity .button {
    flex-shrink: 0;
    flex-grow: 1;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inline-button {
    display: inline-block;
    color: var(--bg);
    padding: 0.5ch 1ch;
    border-radius: 0.5ch;
}

.action-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 1ch;
}

.action-badge {
    display: flex;
    padding: 0.5ch 1ch;
    border-radius: 100dvh;
    gap: 1ch;
    border-width: 1px;
    border-style: solid;
    cursor: pointer;
    font-size: medium;
    align-items: center;
}

.ab-icon {
    height: fit-content;
}

.action-badge:active {
    transform: translateY(1px);
}

#saves-table {
    border-collapse: collapse;
}

#saves-table td {
    padding: 1ch;
}

#saves-menu td {
    border: none;
    border-top: 1px solid var(--gentle);
}

#warning {
    font-size: small;
    text-decoration: underline;
    cursor: pointer;
}

@keyframes li-pulse {
    0% {background: rgba(172, 160, 241, 0.5)}
    100% {background: transparent}
}