/* Age Difference Calculator — scoped styles, light theme by default, dark theme under html.dark */

.bg-agediff-grid {
    background-color: #fafafa;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgba(99, 102, 241, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(99, 102, 241, 0.05) 1px, transparent 1px);
}

html.dark .bg-agediff-grid {
    background-color: #030303;
    background-image:
        linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
}

/* Cards */
.diff-card {
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(212, 212, 216, 0.9);
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04);
}

html.dark .diff-card {
    background: rgba(14, 14, 18, 0.92);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.diff-card--result {
    border-color: rgba(99, 102, 241, 0.45);
}

html.dark .diff-card--result {
    border-color: rgba(129, 140, 248, 0.35);
}

/* iOS zooms into inputs below 16px */
.diff-input,
#agediff-workspace input,
#agediff-workspace select {
    font-size: 16px !important;
    line-height: 1.5;
}

html.dark .diff-input {
    color-scheme: dark;
}

/* Result */
.diff-result {
    overflow-wrap: anywhere;
}

.diff-result--error {
    font-size: 1.0625rem !important;
    line-height: 1.4 !important;
    font-weight: 700 !important;
    color: #be123c !important;
}

html.dark .diff-result--error {
    color: #fda4af !important;
}

.diff-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    color: #3f3f46;
}

html.dark .diff-chip {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #d4d4d8;
}

/* Swap Button Scoped Responsiveness */
#btn-swap .swap-icon-desktop {
    display: none !important;
}
#btn-swap .swap-icon-mobile {
    display: inline-block !important;
}
@media (min-width: 768px) {
    #btn-swap .swap-icon-desktop {
        display: inline-block !important;
    }
    #btn-swap .swap-icon-mobile {
        display: none !important;
    }
}
#agediff-workspace .preset-btn,
.preset-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px !important;
    height: 30px;
    padding: 0 0.75rem !important;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    background: rgba(99, 102, 241, 0.08);
    color: #4f46e5;
    border: 1px solid rgba(99, 102, 241, 0.22);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    user-select: none;
}

#agediff-workspace .preset-btn:hover,
.preset-btn:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px -1px rgba(79, 70, 229, 0.3);
}

#agediff-workspace .preset-btn:active,
.preset-btn:active {
    transform: scale(0.95);
}

html.dark #agediff-workspace .preset-btn,
html.dark .preset-btn {
    background: rgba(129, 140, 248, 0.12);
    color: #a5b4fc;
    border-color: rgba(129, 140, 248, 0.25);
}

html.dark #agediff-workspace .preset-btn:hover,
html.dark .preset-btn:hover {
    background: #6366f1;
    color: #ffffff;
    border-color: #818cf8;
}

/* Action buttons: Copy / Share / Reset, 44px tap targets */
.diff-action {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    background: #f4f4f5;
    border: 1px solid #d4d4d8;
    color: #27272a;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.diff-action:hover {
    background: #e4e4e7;
}

.diff-action:active {
    transform: scale(0.97);
}

.diff-action:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.diff-action--primary {
    background: #4f46e5;
    border-color: #4338ca;
    color: #fff;
}

.diff-action--primary:hover {
    background: #4338ca;
}

html.dark .diff-action {
    background: #18181b;
    border-color: rgba(255, 255, 255, 0.12);
    color: #e4e4e7;
}

html.dark .diff-action:hover {
    background: #27272a;
}

html.dark .diff-action--primary {
    background: #4f46e5;
    border-color: #6366f1;
    color: #fff;
}

html.dark .diff-action--primary:hover {
    background: #4338ca;
}

/* Definition lists in the extras cards */
.diff-list > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-top: 1px solid #e4e4e7;
    font-size: 0.875rem;
}

.diff-list > div:first-child {
    border-top: 0;
}

.diff-list dt {
    color: #52525b;
}

.diff-list dd {
    margin: 0;
    font-weight: 700;
    color: #18181b;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

html.dark .diff-list > div {
    border-top-color: rgba(255, 255, 255, 0.07);
}

html.dark .diff-list > div:first-child {
    border-top: 0;
}

html.dark .diff-list dt {
    color: #a1a1aa;
}

html.dark .diff-list dd {
    color: #fafafa;
}

.diff-link {
    color: #4338ca;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

html.dark .diff-link {
    color: #a5b4fc;
}

/* Content sections */
.diff-prose h2 {
    font-size: 1.375rem;
    line-height: 1.3;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: #18181b;
}

@media (min-width: 640px) {
    .diff-prose h2 {
        font-size: 1.75rem;
    }
}

.diff-prose p,
.diff-prose li {
    font-size: 0.9375rem;
    line-height: 1.65;
    color: #3f3f46;
}

.diff-prose ol,
.diff-prose ul {
    padding-left: 1.25rem;
    display: grid;
    gap: 0.4rem;
}

.diff-prose ol {
    list-style: decimal;
}

.diff-prose ul {
    list-style: disc;
}

.diff-prose strong {
    color: #18181b;
}

html.dark .diff-prose h2,
html.dark .diff-prose strong {
    color: #fafafa;
}

html.dark .diff-prose p,
html.dark .diff-prose li {
    color: #a1a1aa;
}

.diff-formula {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.875rem;
    line-height: 1.7;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: #312e81;
    overflow-x: auto;
}

html.dark .diff-formula {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
}

.diff-example {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    background: #ffffff;
    border: 1px solid #e4e4e7;
    transition: border-color 0.15s ease;
}

.diff-example:hover {
    border-color: #6366f1;
}

.diff-example__label {
    font-size: 0.8125rem;
    color: #52525b;
}

.diff-example__value {
    font-size: 1.0625rem;
    font-weight: 800;
    color: #18181b;
}

.diff-example__note {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #52525b;
}

html.dark .diff-example {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.08);
}

html.dark .diff-example__label,
html.dark .diff-example__note {
    color: #a1a1aa;
}

html.dark .diff-example__value {
    color: #fafafa;
}

@media print {
    #btn-copy, #btn-share, #btn-reset, #btn-swap {
        display: none !important;
    }
}
