/* What Start shows when something is done or arrives (effects.js): a tick drawn in gold, a row that leaves, a row that
   came, the day's end and the line at the foot of the screen. Every movement stands under prefers-reduced-motion at the
   end; above it is only how things look at rest. */

/* #region Ticks */

.tick.is-done::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 46%;
    width: calc(var(--control) * 0.15);
    height: calc(var(--control) * 0.28);
    border: solid var(--black);
    border-width: 0 1.5px 1.5px 0;
    transform: translate(-50%, -50%) rotate(42deg);
}

.tick:hover::before {
    border-color: var(--gold);
}

.row-title {
    text-decoration-color: var(--gold);
}

.is-ticked .row-title {
    color: var(--muted);
    text-decoration-line: line-through;
    text-decoration-color: var(--gold);
}

/* The line a pen draws through a name, over as many lines as the name takes. */
.is-ticked .row-title:has(.strike) {
    text-decoration-line: none;
}

.strike {
    background: linear-gradient(var(--gold), var(--gold)) 0 56% / 100% 2px no-repeat;
}

/* „Zrobione” pressed on an opened task: the button itself turns to the gold of a tick. */
.button.is-doing {
    border-color: var(--gold);
    background: var(--gold);
    color: var(--black);
}

.row.is-leaving {
    overflow: clip;
    pointer-events: none;
}

.spark {
    position: absolute;
    inset: -0.9rem;
    z-index: 1;
    overflow: visible;
    pointer-events: none;
}

.spark line {
    stroke: var(--gold);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-dasharray: 0 1;
}

/* #endregion */

/* #region The day */

/* How much of the day is behind: one thin gold line and its figure, and a gold seal once nothing waits. */
.day {
    margin: 0.5rem 0 1rem;
}

.day p {
    white-space: nowrap;
}

.day strong {
    display: inline-block;
    margin-left: 0.2rem;
    font-size: 1.25rem;
    font-variant-numeric: tabular-nums;
}

.day-clear {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
}

.day-clear svg {
    flex: none;
    width: 4rem;
    height: 4rem;
    fill: none;
    stroke: var(--gold);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.day-clear span {
    font-family: var(--font-display);
    font-size: 1.35rem;
    line-height: 1.3;
}

/* #endregion */

/* #region Messages at the foot */

.toasts {
    position: fixed;
    left: var(--edge);
    right: var(--edge);
    bottom: calc(4.25rem + env(safe-area-inset-bottom));
    z-index: 4;
    display: flex;
    justify-content: center;
    pointer-events: none;
}

.toast {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 34rem;
    min-height: 3.25rem;
    padding: 0.25rem 0.25rem 0.25rem 1rem;
    overflow: hidden;
    border-radius: 0.8rem;
    background: var(--black);
    color: var(--white);
    box-shadow: 0 0.75rem 2rem rgba(var(--black-rgb), 0.22);
    pointer-events: auto;
}

/* The gold line that says something happened; red when it did not. */
.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--gold);
}

.toast.is-failure::before,
.toast.is-urgent::before {
    background: var(--late);
}

.toast p {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.toast-act,
.toast-close {
    flex: none;
    min-width: 2.75rem;
    min-height: 2.75rem;
    border: 0;
    background: none;
    color: var(--gold);
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
}

.toast-act {
    display: inline-flex;
    align-items: center;
    padding: 0 0.75rem;
    text-decoration: none;
}

.toast-act:hover {
    text-decoration: underline;
    text-underline-offset: 0.3em;
}

.toast-close {
    position: relative;
}

.toast-close::before,
.toast-close::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 0.9rem;
    height: 1px;
    background: var(--white);
    opacity: 0.7;
}

.toast-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.toast-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

@media (min-width: 64rem) {
    .toasts {
        left: auto;
        right: 2rem;
        bottom: 2rem;
    }

    .toast {
        width: auto;
        min-width: 22rem;
    }
}

/* #endregion */

/* #region Movement */

@media (prefers-reduced-motion: no-preference) {
    /* One screen gives way to the next instead of blinking. */
    @view-transition {
        navigation: auto;
    }

    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 140ms;
    }

    .button,
    .button-quiet,
    .chip {
        transition: transform 120ms ease, border-color 160ms ease;
    }

    .button:active,
    .button-quiet:active,
    .chip:active {
        transform: scale(0.97);
    }

    .tick::before {
        transition: border-color 160ms ease;
    }

    .tick:active::before {
        transform: scale(0.9);
    }

    .tick.is-drawn::before {
        animation: tick-fill 380ms cubic-bezier(0.3, 2.2, 0.5, 1), tick-ring 560ms ease-out;
    }

    .tick.is-drawn::after {
        animation: tick-mark 260ms 90ms ease-out backwards;
    }

    .spark line {
        animation: spark 520ms 80ms ease-out backwards;
    }

    .is-ticked .row-title {
        transition: color 260ms ease;
    }

    .strike {
        animation: strike 380ms 90ms cubic-bezier(0.5, 0, 0.2, 1) backwards;
    }

    .row.is-ticked {
        animation: row-done 560ms ease-out;
    }

    .button.is-doing {
        transition: background 160ms ease;
        animation: tick-fill 320ms cubic-bezier(0.3, 1.5, 0.5, 1);
    }

    /* The day's figure jumps when it grows, and what comes into the pane comes in from its edge. */
    .day strong.is-new {
        animation: day-done 620ms cubic-bezier(0.3, 1.6, 0.5, 1);
    }

    .pane.is-in > * {
        animation: pane-in 240ms cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
    }

    .row.is-new {
        animation: row-new 2600ms ease-out;
    }

    .count.is-new {
        animation: count-new 520ms cubic-bezier(0.3, 1.6, 0.5, 1);
    }

    .toast {
        animation: toast 320ms cubic-bezier(0.2, 0.9, 0.3, 1);
    }

    .toast::before {
        animation: rule 420ms 120ms ease-out backwards;
    }

    #message-success,
    #message-failure {
        animation: message 320ms ease-out;
    }

    .day-clear.is-drawn path,
    .day-clear.is-drawn circle {
        stroke-dasharray: 1;
        animation: drawn 700ms ease-out backwards;
    }

    .day-clear.is-drawn .day-mark {
        animation-delay: 450ms;
        animation-duration: 350ms;
    }

    .day-clear.is-drawn .day-rays {
        animation-delay: 700ms;
        animation-duration: 450ms;
    }

    .day-clear.is-drawn span {
        animation: message 500ms 500ms ease-out backwards;
    }
}

@keyframes tick-fill {
    from { transform: scale(0.6); }
    to { transform: scale(1); }
}

/* A ring of gold leaves the tick as a drop leaves its ring on water. */
@keyframes tick-ring {
    from { box-shadow: 0 0 0 0 rgba(182, 165, 116, 0.7); }
    to { box-shadow: 0 0 0 1rem rgba(182, 165, 116, 0); }
}

@keyframes tick-mark {
    from { clip-path: inset(100% 0 0 0); }
    to { clip-path: inset(0 0 0 0); }
}

/* A ray is a short stroke that runs outwards and is gone. */
@keyframes spark {
    0% { stroke-dasharray: 0 1; stroke-dashoffset: 0; }
    40% { stroke-dasharray: 0.8 1; stroke-dashoffset: 0; }
    100% { stroke-dasharray: 0.01 1.99; stroke-dashoffset: -1; opacity: 0; }
}

@keyframes row-new {
    0% { background: rgba(182, 165, 116, 0); transform: translateY(-0.4rem); }
    12% { background: rgba(182, 165, 116, 0.28); transform: none; }
    100% { background: rgba(182, 165, 116, 0); }
}

@keyframes strike {
    from { background-size: 0 2px; }
    to { background-size: 100% 2px; }
}

@keyframes row-done {
    0% { background-color: rgba(182, 165, 116, 0); }
    25% { background-color: rgba(182, 165, 116, 0.3); }
    100% { background-color: rgba(182, 165, 116, 0.12); }
}

@keyframes day-done {
    0% { transform: translateY(0.6rem) scale(0.6); opacity: 0; }
    55% { color: var(--gold); }
    100% { transform: none; opacity: 1; }
}

@keyframes pane-in {
    from { opacity: 0; transform: translateX(0.9rem); }
    to { opacity: 1; transform: none; }
}

@keyframes count-new {
    from { transform: scale(0.4); }
    to { transform: scale(1); }
}

@keyframes toast {
    from { opacity: 0; transform: translateY(1rem); }
    to { opacity: 1; transform: none; }
}

@keyframes rule {
    from { transform: scaleY(0); }
    to { transform: scaleY(1); }
}

@keyframes message {
    from { opacity: 0; transform: translateY(-0.4rem); }
    to { opacity: 1; transform: none; }
}

@keyframes drawn {
    from { stroke-dashoffset: 1; }
    to { stroke-dashoffset: 0; }
}

/* #endregion */
