/**
 * Shared components (SPEC §4): buttons, card, ink card, form fields, key/value list,
 * status dot, stepper, label. Used by checkout, order confirmation, My Account and
 * the login dialog. Tokens only.
 */

/* -----------------------------------------
   Buttons
   ----------------------------------------- */
.dh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    height: 36px;
    margin: 0;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--dh-radius-pill);
    background: var(--dh-secondary);
    color: var(--dh-foreground);
    font: 500 0.875rem/1 var(--dh-font-sans);
    text-decoration: none !important;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color var(--dh-ease), border-color var(--dh-ease), filter var(--dh-ease);
}

.dh-btn:hover {
    filter: brightness(0.97);
}

.dh-btn:focus-visible {
    outline: 3px solid color-mix(in oklch, var(--dh-ring) 50%, transparent);
    outline-offset: 1px;
}

.dh-btn:disabled,
.dh-btn[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
}

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

.dh-btn--primary:hover {
    filter: brightness(0.92);
}

.dh-btn--outline {
    background: var(--dh-card);
    border-color: var(--dh-border);
}

.dh-btn--outline:hover {
    filter: none;
    border-color: color-mix(in oklch, var(--dh-foreground) 25%, var(--dh-border));
}

.dh-btn--ghost {
    background: transparent;
}

.dh-btn--ghost:hover {
    filter: none;
    background: var(--dh-accent);
}

.dh-btn--dest {
    background: color-mix(in oklch, var(--dh-status-bad) 12%, transparent);
    color: var(--dh-status-bad);
}

.dh-btn--sm {
    height: 32px;
    padding: 0 12px;
    font-size: 0.8125rem;
}

.dh-btn--lg {
    height: 48px;
    padding: 0 20px;
    font-size: 0.96875rem;
}

.dh-btn--block {
    display: flex;
    width: 100%;
}

.dh-btn--icon {
    width: 36px;
    padding: 0;
}

@media (pointer: coarse) {
    .dh-btn { height: 40px; }
    .dh-btn--sm { height: 36px; }
    .dh-btn--lg { height: 52px; }
    .dh-btn--icon { width: 40px; }
}

/* Underlined text link that looks like a link, not a button */
.dh-link {
    all: unset;
    padding: 4px 8px;
    border-radius: 0.6rem;
    color: var(--dh-foreground);
    font-size: 0.875rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.dh-link:hover {
    background: var(--dh-accent);
}

.dh-link:focus-visible {
    outline: 3px solid color-mix(in oklch, var(--dh-ring) 50%, transparent);
}

/* -----------------------------------------
   Card + ink card (max one ink card per page)
   ----------------------------------------- */
.dh-card {
    box-sizing: border-box;
    min-width: 0;
    background: var(--dh-card);
    color: var(--dh-card-foreground);
    border: 1px solid var(--dh-border);
    border-radius: var(--dh-radius-2xl);
    box-shadow: var(--dh-shadow-card);
}

.dh-ink {
    background: var(--dh-ink);
    color: var(--dh-ink-foreground);
    border-color: transparent;
}

.dh-ink .dh-label,
.dh-ink .dh-kv dt {
    color: color-mix(in oklch, var(--dh-ink-foreground) 72%, transparent);
}

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

/* «small» uppercase label */
.dh-label {
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--dh-muted-foreground);
}

.dh-muted {
    color: var(--dh-muted-foreground);
}

.dh-tab {
    font-variant-numeric: tabular-nums;
}

/* -----------------------------------------
   Form fields
   ----------------------------------------- */
.dh-fgrp {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.dh-fgrp > label,
.dh-flabel {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--dh-foreground);
}

.dh-fgrp > label .dh-muted {
    font-weight: 400;
}

.dh-input,
.dh-select {
    box-sizing: border-box;
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 0 16px;
    border: 1px solid var(--dh-input);
    border-radius: var(--dh-radius-pill);
    background: var(--dh-card);
    color: var(--dh-foreground);
    font: 400 0.9375rem/1 var(--dh-font-sans);
    font-variant-numeric: tabular-nums;
    outline: none;
    transition: border-color var(--dh-ease), box-shadow var(--dh-ease);
}

.dh-card .dh-input,
.dh-card .dh-select {
    background: var(--dh-background);
}

.dh-input::placeholder {
    color: var(--dh-muted-foreground);
    font-weight: 300;
    opacity: 1;
}

.dh-select {
    appearance: none;
    padding-right: 40px;
    cursor: pointer;
}

/* Chevron: wrap the select in .dh-selectwrap (mask keeps it on the tokens) */
.dh-selectwrap {
    position: relative;
    display: block;
}

.dh-selectwrap::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 14px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    background: var(--dh-muted-foreground);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    pointer-events: none;
}

.dh-input:focus,
.dh-select:focus {
    border-color: var(--dh-ring);
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--dh-ring) 50%, transparent);
}

@media (max-width: 600px) {
    .dh-input,
    .dh-select {
        font-size: 1rem; /* never under 16 px on mobile */
    }
}

/* -----------------------------------------
   Key/value list
   ----------------------------------------- */
.dh-kv {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px 24px;
    margin: 0;
}

.dh-kv dt {
    font-size: 0.8125rem;
    color: var(--dh-muted-foreground);
}

.dh-kv dd {
    margin: 0;
    font-size: 0.9375rem;
    overflow-wrap: anywhere;
}

.dh-kv--stack {
    grid-template-columns: 1fr;
}

/* Rows: label left, value right (sums) */
.dh-kv--rows {
    grid-template-columns: 1fr;
    gap: 8px;
}

.dh-kv--rows > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.dh-kv--rows dt,
.dh-kv--rows dd {
    font-size: 0.875rem;
}

.dh-kv--rows dd {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* -----------------------------------------
   Status: 7 px dot + word
   ----------------------------------------- */
.dh-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    white-space: nowrap;
}

.dh-status::before {
    content: "";
    flex: none;
    width: 7px;
    height: 7px;
    border-radius: var(--dh-radius-full);
    background: var(--dh-status, var(--dh-status-idle));
}

.dh-status--ok { --dh-status: var(--dh-status-ok); }
.dh-status--info { --dh-status: var(--dh-status-info); }
.dh-status--warn { --dh-status: var(--dh-status-warn); }
.dh-status--bad { --dh-status: var(--dh-status-bad); }
.dh-status--idle { --dh-status: var(--dh-status-idle); }

/* -----------------------------------------
   Stepper (− n +)
   ----------------------------------------- */
.dh-stepper {
    display: inline-flex;
    align-items: center;
    height: 32px;
    border-radius: var(--dh-radius-pill);
    background: var(--dh-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.dh-stepper button {
    all: unset;
    display: grid;
    place-items: center;
    width: 30px;
    height: 100%;
    border-radius: var(--dh-radius-full);
    color: var(--dh-muted-foreground);
    cursor: pointer;
}

.dh-stepper button:hover {
    color: var(--dh-foreground);
}

.dh-stepper button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.dh-stepper button:focus-visible {
    outline: 3px solid color-mix(in oklch, var(--dh-ring) 50%, transparent);
}

.dh-stepper output,
.dh-stepper span {
    min-width: 22px;
    text-align: center;
}

.dh-stepper--sm {
    height: 28px;
}

.dh-stepper--sm button {
    width: 26px;
}

/* Round icon button (remove, close) */
.dh-xbtn {
    all: unset;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: var(--dh-radius-full);
    color: var(--dh-muted-foreground);
    cursor: pointer;
}

.dh-xbtn:hover {
    background: var(--dh-muted);
    color: var(--dh-foreground);
}

.dh-xbtn:focus-visible {
    outline: 3px solid color-mix(in oklch, var(--dh-ring) 50%, transparent);
}

/* Product thumbnail in rows */
.dh-thumb {
    display: grid;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
    place-items: center;
    width: 48px;
    height: 48px;
    overflow: hidden;
    padding: 4px;
    box-sizing: border-box;
    border-radius: 0.8rem;
    background: var(--dh-photo);
}

.dh-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Greeting / heading with serif aside («God kveld, Kari.» + «Ett prosjekt er ute.») */
.dh-greet {
    display: grid;
    margin: 0;
    font: 600 clamp(2rem, 1.25rem + 2.4vw, 3.25rem)/1.05 var(--dh-font-heading);
    letter-spacing: -0.035em;
    color: var(--dh-foreground);
    text-wrap: balance;
}

.dh-greet em {
    font: italic 400 1em/1.05 var(--dh-font-serif);
    letter-spacing: -0.015em;
}

.dh-svg {
    width: 16px;
    height: 16px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
