/*
Copyright (c) 2026 Martin Bartos
Licensed under the MIT License. See LICENSE file for details.
*/

/*
Components ported from the desktop app's Design/Styles, with the same class names.
*/

/* Icons: inline SVG symbols from the sprite at the top of <body>, colored by the text color */
.icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/*
Icons have fixed sizes: the reset's max-width: 100% would collapse them inside content-sized buttons.
Scoped to svg, because "icon" is also the app's class for round icon buttons (class="button secondary icon").
*/
svg.icon {
    flex: none;
    width: var(--icon-size-xs);
    height: var(--icon-size-xs);
    max-width: none;
    fill: currentColor;
}

/*
Segmented control (ListBox.segmented and its items in ListBox.axaml and ListBoxItem.axaml).
Built from native radio inputs: one tab stop, arrow keys move the selection. Markup:
<div class="segmented" role="radiogroup"><label><input type="radio"><span class="segment">…</span></label>…</div>
*/
.segmented {
    display: inline-flex;
    gap: var(--spacing-xxs);
    padding: var(--spacing-xxs);
    border: var(--border-thickness) solid var(--sem-border);
    border-radius: var(--radius-sm);
    background-color: var(--sem-surface-elevated);
}

.segmented label {
    position: relative;
    display: flex;
    cursor: pointer;
}

/* the input stays focusable and in the accessibility tree; the visible part is the segment */
.segmented input {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.segmented .segment {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xxs);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-xs);
    font-size: var(--font-size-xs);
    line-height: var(--icon-size-xs);
    color: var(--sem-foreground);
}

@media (hover: hover) {
    .segmented label:hover .segment {
        background-color: var(--sem-surface-brand);
    }
}

.segmented input:checked + .segment {
    background-color: var(--sem-brand);
    color: var(--sem-on-brand);
}

.segmented input:focus-visible + .segment {
    outline: var(--border-thickness-thick) solid var(--sem-border-focus);
    outline-offset: 2px;
}

/* larger hit areas for touch: 32 × 40 px instead of 32 × 24 px */
@media (pointer: coarse) {
    .segmented .segment {
        padding: 0.5rem 0.75rem;
    }
}

/*
Buttons (Button.axaml): "button" plus the app's classes, e.g. class="button primary regular". Links styled as buttons
use the same classes.
*/
/* the content wraps only when the button can't fit it on one line (very large text) */
.button {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xxs);
    border: 0;
    font-family: inherit;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    text-decoration: none;
    cursor: pointer;
}

.button.regular {
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-xs);
}

/* touch screens: at least 44px tall, so the buttons are easy to hit */
@media (pointer: coarse) {
    .button.regular {
        min-height: 2.75rem;
    }
}

.button.primary {
    background: var(--sem-gradient-brand);
    color: var(--sem-on-brand);
}

.button.primary:hover,
.button.primary:active {
    background: var(--sem-gradient-brand-hover);
}

/* the 1px border is an inset shadow, so secondary buttons are as tall as primary ones next to them */
.button.secondary {
    background-color: var(--sem-surface-brand);
    box-shadow: inset 0 0 0 var(--border-thickness) var(--sem-brand-strong);
    color: var(--sem-brand-strong);
}

.button.secondary:hover,
.button.secondary:active {
    background-color: var(--sem-surface-brand-hover);
    color: var(--sem-brand-strong-hover);
}

/* round icon button */
.button.icon {
    padding: 0.5rem;
    border-radius: var(--radius-circular);
}

/* Cards (Border.axaml) */
.card {
    padding: 1.125rem;
    border: var(--border-thickness) solid var(--sem-border-card);
    border-radius: var(--radius-md);
    background-color: var(--sem-surface-card);
}

.elevated.card {
    border-color: var(--sem-border-card-elevated);
    background-color: var(--sem-surface-elevated);
}

/* strong danger text: the plain danger color doesn't reach AA contrast on this background */
.danger.card {
    background: var(--sem-gradient-danger-subtle);
    color: var(--sem-danger-strong);
}
