/*
    POMODORO TIMER

    Markup: src/includes/pomodoro-timer.njk (the timer) and
    src/includes/yellow-tomato-apps.njk (the device cards), behaviour:
    pomodoro-timer.N.js. Uses the --pf-* tokens of the site-wide "modern
    shell" in index.NN.css; the ring, digits and buttons follow the Yellow
    Tomato extension's full-screen timer. The deploy caches this file for a
    year: bump N in its name (and in the include) whenever it changes.
*/

.pomodoro-timer {
    --pt-ink: var(--text-color-light);
    --pt-muted: #6b6964;
    --pt-body: var(--pf-body);
    --pt-line: var(--pf-line);
    --pt-focus: var(--pf-primary);
    --pt-rest: #68be94;
    --pt-tone: var(--pt-focus);
    --pt-track: rgba(249, 212, 119, 0.3);
    --pt-glow: rgba(249, 212, 119, 0.3);
    --pt-panel: rgba(255, 255, 255, 0.62);
    --pt-soft: rgba(49, 48, 48, 0.06);
    --pt-soft-hover: rgba(49, 48, 48, 0.1);
    --ring: min(300px, 72vw);

    max-width: 920px;
    margin: 30px auto 0;
    font-family: var(--pf-font);
    font-weight: 400;
    letter-spacing: normal;
    color: var(--pt-ink);
}

/* breaks get the apps' calm sage */
.pomodoro-timer[data-phase="break"] {
    --pt-tone: var(--pt-rest);
    --pt-track: rgba(104, 190, 148, 0.22);
    --pt-glow: rgba(104, 190, 148, 0.22);
}

/* dark: the apps' dimmed yellow, which doesn't glare on dark surfaces */
body.dark .pomodoro-timer {
    --pt-ink: var(--text-color-dark);
    --pt-muted: rgba(255, 255, 255, 0.62);
    --pt-body: rgba(255, 255, 255, 0.72);
    --pt-line: var(--pf-line-dark);
    --pt-focus: #dfb44a;
    --pt-rest: #60a884;
    --pt-track: rgba(223, 180, 74, 0.25);
    --pt-glow: rgba(223, 180, 74, 0.15);
    --pt-panel: rgba(255, 255, 255, 0.05);
    --pt-soft: rgba(255, 255, 255, 0.1);
    --pt-soft-hover: rgba(255, 255, 255, 0.15);
}

body.dark .pomodoro-timer[data-phase="break"] {
    --pt-track: rgba(96, 168, 132, 0.22);
    --pt-glow: rgba(96, 168, 132, 0.12);
}

/* `hidden` must win over the display values below */
.pomodoro-timer [hidden] {
    display: none !important;
}

.pomodoro-timer__card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    padding: 24px;
    border: 1px solid var(--pt-line);
    border-radius: 22px;
    background: var(--pf-surface);
    box-shadow: var(--pf-shadow-card), var(--pf-inset);
}

.pomodoro-timer__main {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    padding-top: 4px;
}

/* presets + sound */

.pomodoro-timer__top {
    position: relative;
    align-self: stretch;
    display: flex;
    justify-content: center;
    padding: 0 48px;
}

.pomodoro-timer__presets {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.pomodoro-timer__chip {
    padding: 0.35rem 0.95rem;
    border: 1.5px solid var(--pt-line);
    border-radius: 2rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, opacity 0.2s;
}

.pomodoro-timer__chip b {
    font-weight: 600;
}

.pomodoro-timer__chip:hover:not(:disabled) {
    border-color: var(--pf-primary-deep);
    background-color: rgba(255, 212, 101, 0.15);
}

.pomodoro-timer__chip[aria-pressed="true"] {
    border-color: var(--pf-primary-deep);
    background-color: var(--pt-focus);
    color: var(--pf-ink);
}

.pomodoro-timer__chip:disabled {
    cursor: default;
}

.pomodoro-timer__chip:disabled:not([aria-pressed="true"]) {
    opacity: 0.4;
}

.pomodoro-timer__icon-button {
    position: absolute;
    top: 0;
    right: 0;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--pt-line);
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.2s;
}

.pomodoro-timer__icon-button:hover {
    background: var(--pt-soft);
}

.pomodoro-timer__icon-button svg {
    width: 16px;
    height: 16px;
}

.pomodoro-timer__icon-button[aria-pressed="false"] .pomodoro-timer__sound-waves {
    opacity: 0.2;
}

/* the ring */

.pomodoro-timer__ring {
    position: relative;
    width: var(--ring);
    aspect-ratio: 1;
    margin-top: 22px;
}

.pomodoro-timer__glow {
    position: absolute;
    inset: 6%;
    border-radius: 50%;
    background-color: var(--pt-glow);
    filter: blur(min(64px, calc(var(--ring) * 0.17)));
    opacity: 0.75;
    transition: background-color 0.7s;
}

.pomodoro-timer__dial {
    position: absolute;
    inset: 0;
}

.pomodoro-timer__dial svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    transform: rotate(-90deg);
}

.pomodoro-timer__track,
.pomodoro-timer__arc {
    fill: none;
    stroke-width: 2.4;
}

.pomodoro-timer__track {
    stroke: var(--pt-track);
    transition: stroke 0.7s;
}

/* 289.03 = 2π × 46, the circle's r; the script moves the offset */
.pomodoro-timer__arc {
    stroke: var(--pt-tone);
    stroke-linecap: round;
    stroke-dasharray: 289.03 289.03;
    transition: stroke-dashoffset 0.3s ease-out, opacity 0.4s, stroke 0.7s;
}

.pomodoro-timer[data-phase="paused"] .pomodoro-timer__arc {
    opacity: 0.4;
}

.pomodoro-timer__readout {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.pomodoro-timer__phase {
    height: 20px;
    color: var(--pt-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

/* The apps' thin system digits: General Sans has no weight below 400. */
.pomodoro-timer__time {
    margin: calc(var(--ring) * 0.03) 0;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: calc(var(--ring) * 0.22);
    font-weight: 200;
    line-height: 1;
    letter-spacing: -0.025em;
    font-variant-numeric: tabular-nums;
}

.pomodoro-timer__ends {
    height: 20px;
}

.pomodoro-timer__ends-inner {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--pt-muted);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.pomodoro-timer__ends-inner svg {
    width: 16px;
    height: 16px;
}

/* "Pomodoro done · 3 today" */
.pomodoro-timer__flash {
    position: absolute;
    top: -6px;
    left: 50%;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--pf-ink);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--pf-shadow-card);
    opacity: 0;
    transform: translateX(-50%);
    pointer-events: none;
}

body.dark .pomodoro-timer__flash {
    background: var(--pt-focus);
    color: var(--pf-ink);
}

.pomodoro-timer__flash.is-shown {
    animation: pomodoro-timer-flash 3.4s ease both;
}

@keyframes pomodoro-timer-flash {
    0% { opacity: 0; transform: translate(-50%, 6px); }
    10%, 85% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* While the clock runs, the glow breathes and the ring beats once a second,
   as in the apps; only while someone is looking (is-attentive, set by the
   script), so the page holds still beside other work. */
.pomodoro-timer.is-attentive[data-phase="running"] .pomodoro-timer__dial {
    animation: pomodoro-timer-heartbeat 1s infinite;
}

.pomodoro-timer.is-attentive[data-phase="running"] .pomodoro-timer__glow {
    animation: pomodoro-timer-breathe 6s ease-in-out infinite;
}

@keyframes pomodoro-timer-heartbeat {
    0%, 50%, 100% { transform: scale(1); }
    75% { transform: scale(1.05); }
}

@keyframes pomodoro-timer-breathe {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

/* controls */

.pomodoro-timer__controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    min-height: 60px;
    margin-top: 26px;
}

.pomodoro-timer__button {
    display: grid;
    place-items: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--pt-soft);
    color: var(--pt-ink);
    cursor: pointer;
    transition: transform 0.2s var(--pf-ease-spring), background-color 0.2s, box-shadow 0.2s;
}

.pomodoro-timer__button:hover {
    background: var(--pt-soft-hover);
    transform: translateY(-1px);
}

.pomodoro-timer__button:active {
    transform: scale(0.94);
}

.pomodoro-timer__button svg {
    width: 24px;
    height: 24px;
}

.pomodoro-timer__button--primary,
.pomodoro-timer__button--primary:hover {
    background: var(--pt-focus);
    color: var(--pf-ink);
    box-shadow: 0 10px 30px -10px rgba(249, 212, 119, 0.9);
}

/* the start button invites a click while the timer rests */
.pomodoro-timer[data-phase="idle"] [data-action="start"] {
    animation: pomodoro-timer-invite 2.6s ease-in-out infinite;
}

@keyframes pomodoro-timer-invite {
    0%, 100% { box-shadow: 0 10px 22px -10px rgba(254, 190, 22, 0.7); }
    50% { box-shadow: 0 12px 32px -8px rgba(254, 190, 22, 1); }
}

/* today's count */

.pomodoro-timer__summary {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    margin-top: 20px;
    color: var(--pt-muted);
    font-size: 14px;
}

.pomodoro-timer__strong {
    color: var(--pt-ink);
    font-variant-numeric: tabular-nums;
}

.pomodoro-timer__clear {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--pt-muted);
    cursor: pointer;
}

.pomodoro-timer__clear:hover {
    background: var(--pt-soft);
    color: var(--pt-ink);
}

.pomodoro-timer__clear svg {
    width: 15px;
    height: 15px;
}

/* the line under the timer: what the apps would do right now */

.pomodoro-timer__hint {
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    padding: 11px 14px;
    border-radius: 14px;
    background: var(--pt-panel);
    color: var(--pt-body);
    font-size: 14px;
    line-height: 1.45;
}

.pomodoro-timer__hint > svg {
    flex: none;
    width: 15px;
    height: 15px;
    color: var(--pf-primary-deep);
}

.pomodoro-timer__hint a,
.pomodoro-timer__app-more a,
.yt-apps__foot a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: var(--pf-primary-deep);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

/* the apps panel */

.pomodoro-timer__app {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border: 1px solid var(--pt-line);
    border-radius: 18px;
    background: var(--pt-panel);
}

.pomodoro-timer__app.is-calling {
    animation: pomodoro-timer-call 1.2s ease-in-out 2;
}

@keyframes pomodoro-timer-call {
    0%, 100% { box-shadow: 0 0 0 0 rgba(254, 190, 22, 0); }
    50% { box-shadow: 0 0 0 6px rgba(254, 190, 22, 0.35); }
}

.pomodoro-timer__brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 15px;
    font-weight: 600;
}

.pomodoro-timer__brand svg {
    width: 26px;
    height: 26px;
}

.pomodoro-timer__pill {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--pf-secondary);
    color: var(--pf-ink);
    font-size: 12px;
    font-weight: 600;
}

.pomodoro-timer__variant {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.pomodoro-timer__app-title {
    margin-top: 18px;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.pomodoro-timer__app-text {
    margin-top: 10px;
    color: var(--pt-body);
    font-size: 15px;
    line-height: 1.5;
}

/* .pomodoro-timer prefix: outranks the article's own list styles */
.pomodoro-timer .pomodoro-timer__list {
    max-width: none;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
    font-size: 14.5px;
    line-height: 1.4;
    letter-spacing: normal;
}

.pomodoro-timer__list li {
    position: relative;
    padding-left: 27px;
}

.pomodoro-timer__list li + li {
    margin-top: 8px;
}

.pomodoro-timer__list li::before {
    content: "";
    position: absolute;
    top: 0.05em;
    left: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--pt-focus) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%23313030' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat;
}

/* the main call to action, also used by the nudge and the device cards.
   A block, not a flex box, so a long label wraps as one line of text. */
.pomodoro-timer__cta,
.yt-apps__button {
    display: block;
    margin-top: 20px;
    padding: 12px 20px;
    line-height: 26px;
    border-radius: 999px;
    background: var(--pf-primary);
    color: var(--pf-ink);
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 10px 22px -10px rgba(254, 190, 22, 0.7);
    transition: transform 0.2s var(--pf-ease-spring), box-shadow 0.2s;
}

.pomodoro-timer__cta:hover,
.yt-apps__button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px -10px rgba(254, 190, 22, 0.8);
}

/* outranks `body.dark .article a`, which would turn the label white */
body.dark .pomodoro-timer a.pomodoro-timer__cta,
body.dark .yt-apps a.yt-apps__button {
    background: #dfb44a;
    color: var(--pf-ink);
}

.pomodoro-timer__cta-free {
    font-weight: 500;
    opacity: 0.75;
    white-space: nowrap;
}

.pomodoro-timer__app-note {
    margin-top: 8px;
    color: var(--pt-muted);
    font-size: 13px;
    text-align: center;
}

.pomodoro-timer__app-more {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--pt-line);
    color: var(--pt-body);
    font-size: 14px;
}

.pomodoro-timer__site {
    align-self: flex-start;
    margin-top: 10px;
    color: var(--pt-muted) !important;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
}

.pomodoro-timer__site::after {
    content: " →";
}

.pomodoro-timer__site:hover {
    text-decoration: underline;
}

/* "Back from another tab?" */

.pomodoro-timer__nudge {
    position: fixed;
    bottom: 20px;
    left: 50%;
    z-index: 60;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    width: min(620px, calc(100vw - 32px));
    padding: 14px 16px 14px 18px;
    border: 1px solid var(--pt-line);
    border-radius: 18px;
    background: var(--pf-surface);
    background-color: var(--pf-bg);
    box-shadow: var(--pf-shadow-lg), var(--pf-inset);
    font-size: 15px;
    line-height: 1.45;
    transform: translateX(-50%);
    animation: pomodoro-timer-rise 0.35s var(--pf-ease-spring) both;
}

body.dark .pomodoro-timer__nudge {
    background-color: var(--bgr-color-dark);
}

@keyframes pomodoro-timer-rise {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.pomodoro-timer__nudge-text {
    flex: 1 1 300px;
}

.pomodoro-timer__nudge-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pomodoro-timer .pomodoro-timer__cta--small {
    margin-top: 0;
    padding: 9px 18px;
    font-size: 15px;
    line-height: 24px;
    white-space: nowrap;
}

.pomodoro-timer__nudge-close {
    padding: 9px 12px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--pt-muted);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.pomodoro-timer__nudge-close:hover {
    background: var(--pt-soft);
    color: var(--pt-ink);
}

.pomodoro-timer__visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.pomodoro-timer__noscript {
    display: block;
    margin-top: 12px;
    color: var(--pt-muted);
    font-size: 14px;
    text-align: center;
}

/*
    DEVICE CARDS (yellow-tomato-apps.njk)
*/

.yt-apps {
    --yt-muted: #6b6964;
    --yt-body: var(--pf-body);
    --yt-line: var(--pf-line);

    max-width: 920px;
    margin: 30px auto 0;
    font-family: var(--pf-font);
    font-weight: 400;
    letter-spacing: normal;
    color: var(--text-color-light);
}

body.dark .yt-apps {
    --yt-muted: rgba(255, 255, 255, 0.62);
    --yt-body: rgba(255, 255, 255, 0.72);
    --yt-line: var(--pf-line-dark);

    color: var(--text-color-dark);
}

.yt-apps__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.yt-apps__card {
    display: flex;
    flex-direction: column;
    padding: 22px;
    border: 1px solid var(--yt-line);
    border-radius: 22px;
    background: var(--pf-surface);
    box-shadow: var(--pf-shadow-card), var(--pf-inset);
}

.yt-apps__head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.yt-apps__icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--pf-primary);
    color: var(--pf-ink);
}

.yt-apps__icon svg {
    width: 24px;
    height: 24px;
}

.yt-apps__card--soon .yt-apps__icon {
    background: var(--pf-secondary);
}

.yt-apps__name {
    display: block;
    font-size: 18px;
    font-weight: 600;
}

.yt-apps__status {
    display: block;
    color: var(--yt-muted);
    font-size: 13px;
}

.yt-apps__text {
    flex: 1;
    margin-top: 14px;
    color: var(--yt-body);
    font-size: 15px;
    line-height: 1.5;
}

.yt-apps__action {
    display: flex;
    align-items: center;
    min-height: 50px;
    margin-top: 18px;
}

.yt-apps .yt-apps__button {
    flex: 1;
    margin-top: 0;
}

/* Apple's badge, unmodified: no hover motion, at least 40px tall */
.yt-apps__badge {
    display: inline-flex;
}

.yt-apps .yt-apps__badge img {
    display: block;
    width: auto;
    height: 44px;
    margin: 0;
}

.yt-apps__soon {
    flex: 1;
    padding: 12px 16px;
    border: 1.5px dashed var(--yt-line);
    border-radius: 999px;
    color: var(--yt-muted);
    font-size: 15px;
    font-weight: 500;
    text-align: center;
}

body.dark .yt-apps__soon {
    border-color: rgba(255, 255, 255, 0.25);
}

.yt-apps__foot {
    display: block;
    margin-top: 18px;
    color: var(--yt-body);
    font-size: 15px;
    text-align: center;
}

.yt-apps__legal {
    display: block;
    max-width: 630px;
    margin: 10px auto 0;
    color: var(--yt-muted);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

/* narrow screens: one column, the timer first */

@media (max-width: 860px) {
    .pomodoro-timer__card {
        grid-template-columns: minmax(0, 1fr);
    }

    .yt-apps__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 680px) {
    .pomodoro-timer {
        --ring: min(270px, 74vw);

        margin-top: 24px;
    }

    .pomodoro-timer__card {
        gap: 18px;
        padding: 16px 14px 14px;
    }

    .pomodoro-timer__top {
        padding: 0 40px 0 0;
        justify-content: flex-start;
    }

    .pomodoro-timer__app {
        padding: 18px;
    }

    .pomodoro-timer__nudge {
        bottom: 12px;
    }
}

/* the smallest phones: keep the three lengths on one row */
@media (max-width: 380px) {
    .pomodoro-timer__presets {
        gap: 6px;
    }

    .pomodoro-timer__chip {
        padding: 0.3rem 0.7rem;
        font-size: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pomodoro-timer *,
    .pomodoro-timer__nudge {
        animation: none !important;
    }

    .pomodoro-timer__flash.is-shown {
        animation: pomodoro-timer-fade 3.4s ease both !important;
    }

    .pomodoro-timer__arc,
    .pomodoro-timer__button,
    .pomodoro-timer__cta,
    .yt-apps__button {
        transition: none;
    }
}

@keyframes pomodoro-timer-fade {
    0%, 100% { opacity: 0; }
    10%, 85% { opacity: 1; }
}
