/*
 * Notification + loading UI (toasts, confirm dialog, blocking overlay, page
 * progress bar).
 *
 * Written as plain CSS on purpose:
 *  - it lives in public/, which Tailwind does not scan, so utility classes used
 *    from JS would be purged out of the build;
 *  - the layouts fall back to the Tailwind Play CDN when no Vite build exists,
 *    and this file is linked in both paths.
 *
 * Colours come from the design tokens in assets/portofolio/theme.css, so dark
 * mode follows the rest of the app with no extra work.
 */

:root {
    --dh-success: 142 71% 36%;
    --dh-error: 0 72% 51%;
    --dh-warning: 32 95% 44%;
    --dh-info: 217 91% 55%;

    --dh-toast-width: 380px;
    --dh-z: 9000;
}

.dark {
    --dh-success: 142 69% 48%;
    --dh-error: 0 84% 65%;
    --dh-warning: 38 92% 55%;
    --dh-info: 213 94% 68%;
}

/* ------------------------------------------------------------------ *
 * Page progress bar
 * ------------------------------------------------------------------ */

.dh-progress {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    height: 3px;
    z-index: calc(var(--dh-z) + 30);
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
}

.dh-progress[data-active="true"] {
    opacity: 1;
}

.dh-progress__bar {
    width: 0;
    height: 100%;
    border-start-end-radius: 3px;
    border-end-end-radius: 3px;
    background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--dh-info)));
    box-shadow: 0 0 10px hsl(var(--primary) / 0.7);
    transition: width 200ms ease;
}

/* ------------------------------------------------------------------ *
 * Toasts
 * ------------------------------------------------------------------ */

.dh-toaster {
    position: fixed;
    inset-block-start: 1rem;
    inset-inline-end: 1rem;
    z-index: calc(var(--dh-z) + 20);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    width: min(var(--dh-toast-width), calc(100vw - 2rem));
    pointer-events: none;
}

.dh-toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    overflow: hidden;
    padding: 0.875rem 0.875rem 0.875rem 1.125rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: 0 10px 30px -10px rgb(0 0 0 / 0.35), 0 2px 8px -2px rgb(0 0 0 / 0.15);
    pointer-events: auto;
    animation: dh-toast-in 260ms cubic-bezier(0.21, 1.02, 0.73, 1);
}

.dh-toast[data-leaving="true"] {
    animation: dh-toast-out 200ms cubic-bezier(0.06, 0.71, 0.55, 1) forwards;
}

/* Accent stripe down the leading edge, tinted per variant. */
.dh-toast::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 0;
    width: 4px;
    background-color: hsl(var(--dh-accent));
}

.dh-toast--success { --dh-accent: var(--dh-success); }
.dh-toast--error   { --dh-accent: var(--dh-error); }
.dh-toast--warning { --dh-accent: var(--dh-warning); }
.dh-toast--info    { --dh-accent: var(--dh-info); }
.dh-toast--loading { --dh-accent: var(--primary); }

.dh-toast__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 1px;
    color: hsl(var(--dh-accent));
}

.dh-toast__icon svg {
    width: 1.25rem;
    height: 1.25rem;
}

.dh-toast__body {
    flex: 1 1 auto;
    min-width: 0;
}

.dh-toast__title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
}

.dh-toast__message {
    margin: 0.15rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: hsl(var(--muted-foreground));
    overflow-wrap: anywhere;
}

.dh-toast__message ul {
    margin: 0.25rem 0 0;
    padding-inline-start: 1.1rem;
    list-style: disc;
}

.dh-toast__close {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    margin: -0.25rem -0.25rem 0 0;
    border: 0;
    border-radius: calc(var(--radius) - 4px);
    background: transparent;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
}

.dh-toast__close:hover {
    background-color: hsl(var(--accent));
    color: hsl(var(--foreground));
}

.dh-toast__close svg {
    width: 0.875rem;
    height: 0.875rem;
}

/* Remaining-time indicator along the bottom edge. */
.dh-toast__timer {
    position: absolute;
    inset-block-end: 0;
    inset-inline-start: 0;
    height: 2px;
    width: 100%;
    transform-origin: left center;
    background-color: hsl(var(--dh-accent) / 0.55);
    animation: dh-toast-timer linear forwards;
}

.dh-toast:hover .dh-toast__timer {
    animation-play-state: paused;
}

@keyframes dh-toast-in {
    from { opacity: 0; transform: translateX(110%) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes dh-toast-out {
    from { opacity: 1; transform: translateX(0) scale(1); max-height: 200px; }
    to   { opacity: 0; transform: translateX(110%) scale(0.96); max-height: 0; }
}

@keyframes dh-toast-timer {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Below sm the stack docks to the bottom, full width. */
@media (max-width: 640px) {
    .dh-toaster {
        inset-block-start: auto;
        inset-block-end: 1rem;
        inset-inline: 0.75rem;
        width: auto;
        flex-direction: column-reverse;
    }

    @keyframes dh-toast-in {
        from { opacity: 0; transform: translateY(120%) scale(0.96); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }

    @keyframes dh-toast-out {
        from { opacity: 1; transform: translateY(0); max-height: 200px; }
        to   { opacity: 0; transform: translateY(120%); max-height: 0; }
    }
}

/* ------------------------------------------------------------------ *
 * Confirm dialog
 * ------------------------------------------------------------------ */

.dh-dialog {
    position: fixed;
    inset: 0;
    z-index: calc(var(--dh-z) + 25);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.dh-dialog[hidden] {
    display: none;
}

.dh-dialog__overlay {
    position: absolute;
    inset: 0;
    background-color: rgb(0 0 0 / 0.6);
    backdrop-filter: blur(2px);
    animation: dh-fade-in 180ms ease;
}

.dh-dialog__panel {
    position: relative;
    width: min(28rem, 100%);
    padding: 1.5rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background-color: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.4);
    animation: dh-dialog-in 200ms cubic-bezier(0.21, 1.02, 0.73, 1);
}

.dh-dialog__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    margin-bottom: 1rem;
    border-radius: 999px;
    background-color: hsl(var(--dh-accent) / 0.12);
    color: hsl(var(--dh-accent));
}

.dh-dialog__icon svg {
    width: 1.375rem;
    height: 1.375rem;
}

.dh-dialog--success { --dh-accent: var(--dh-success); }
.dh-dialog--error,
.dh-dialog--danger  { --dh-accent: var(--dh-error); }
.dh-dialog--warning { --dh-accent: var(--dh-warning); }
.dh-dialog--info    { --dh-accent: var(--dh-info); }

.dh-dialog__title {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
}

.dh-dialog__message {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: hsl(var(--muted-foreground));
}

.dh-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

@media (max-width: 480px) {
    .dh-dialog__actions {
        flex-direction: column-reverse;
    }
}

.dh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 2.25rem;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) - 2px);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 150ms ease, opacity 150ms ease;
}

.dh-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.dh-btn--outline {
    border-color: hsl(var(--border));
    background-color: transparent;
    color: hsl(var(--foreground));
}

.dh-btn--outline:hover {
    background-color: hsl(var(--accent));
}

.dh-btn--primary {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.dh-btn--primary:hover {
    background-color: hsl(var(--primary) / 0.9);
}

.dh-btn--danger {
    background-color: hsl(var(--dh-error));
    color: #fff;
}

.dh-btn--danger:hover {
    background-color: hsl(var(--dh-error) / 0.9);
}

@keyframes dh-dialog-in {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes dh-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ------------------------------------------------------------------ *
 * Blocking loading overlay + spinner
 * ------------------------------------------------------------------ */

.dh-overlay {
    position: fixed;
    inset: 0;
    z-index: calc(var(--dh-z) + 28);
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: hsl(var(--background) / 0.72);
    backdrop-filter: blur(2px);
    animation: dh-fade-in 150ms ease;
}

.dh-overlay[hidden] {
    display: none;
}

.dh-overlay__box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    padding: 1.75rem 2.25rem;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    background-color: hsl(var(--card));
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.35);
}

.dh-overlay__text {
    margin: 0;
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
}

.dh-spinner {
    display: inline-block;
    width: 1.75rem;
    height: 1.75rem;
    border: 2.5px solid hsl(var(--muted-foreground) / 0.25);
    border-top-color: hsl(var(--primary));
    border-radius: 999px;
    animation: dh-spin 700ms linear infinite;
}

.dh-spinner--sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

@keyframes dh-spin {
    to { transform: rotate(360deg); }
}

/* Inline busy state for submit buttons driven by [data-dh-form]. */
.dh-busy {
    position: relative;
    pointer-events: none;
    opacity: 0.75;
}

/* ------------------------------------------------------------------ *
 * Reduced motion: keep the state changes, drop the movement.
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    .dh-toast,
    .dh-dialog__panel,
    .dh-dialog__overlay,
    .dh-overlay {
        animation: none !important;
    }

    .dh-toast__timer {
        animation-duration: inherit;
    }

    .dh-spinner {
        animation-duration: 1.6s;
    }

    .dh-progress__bar {
        transition: none;
    }
}
