/* ═══════════════════════════════════════════════════════════════════
   SHORT LINKS — iztech.in/short (docs/DESIGN.md section 13)
   The link register: the site's ledger, kept for one person's links.
   Page-only, so a change here bumps only this page's version. Every
   colour, size, space, duration and shadow is a token from style.css.
   ═══════════════════════════════════════════════════════════════════ */

.short-body {
    background: var(--bg);
    color: var(--text);
    --sh-control: 3.375rem;          /* one height for every field and button (54px) */
}

.sh {
    padding-block: calc(var(--space-12) + var(--space-5)) var(--space-12);
    min-height: 70vh;
}

.sh-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.sh-vh,
.sh-skip:not(:focus) {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}
.sh-skip:focus {
    position: fixed;
    inset-block-start: var(--space-3);
    inset-inline-start: var(--space-3);
    z-index: 300;
    padding: var(--space-2) var(--space-4);
    background: var(--navy);
    color: var(--white);
    border-radius: var(--radius-sm);
}

.sh a:focus-visible,
.sh button:focus-visible,
.sh summary:focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: 3px;
    border-radius: 2px;
}

/* One control height, the house form symmetry rule */
.sh .cf-field input,
.sh .cf-field select { height: var(--sh-control); }
.sh .cf-submit { min-height: var(--sh-control); padding-block: 0; }
.sh .section-label { margin: 0 0 var(--space-5); }
.sh h2.section-label { font-family: var(--font); }

/* ─── Titles and lead ─── */
.sh-title {
    font-family: var(--serif);
    font-weight: 400;
    font-size: var(--fs-h2);
    line-height: var(--lh-tight);
    letter-spacing: var(--track-tight);
    color: var(--navy);
    margin: 0 0 var(--space-5);
}
.sh-lead {
    font-size: var(--fs-lead);
    max-width: 52ch;
    margin: 0 0 var(--space-6);
}

/* ─── Signed out: the intro beside the sign-in card ─── */
.sh-intro-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: var(--space-10);
    align-items: start;
    padding-block-start: var(--space-6);
}
.sh-facts { margin: 0; padding: 0; max-width: 52ch; }
.sh-facts li {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    padding-block: var(--space-3);
    border-bottom: 1px solid var(--bg-surface-2);
}
.sh-facts li::before {            /* the entry line's gold tick */
    content: '';
    flex: 0 0 1.625rem;
    height: 1px;
    background: var(--gold);
    transform: translateY(-0.3em);
}
.sh-sent { margin: 0 0 var(--space-5); }
.sh-otp {
    font-family: var(--font-mono);
    font-size: var(--fs-title) !important;
    letter-spacing: 0.3em;
    font-variant-numeric: tabular-nums;
}
.sh-form-quiet { margin-top: var(--space-5); }

.sh-text-btn {
    color: var(--navy);
    font-size: var(--fs-small);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 0.25em;
    text-decoration-thickness: 1px;
    cursor: pointer;
    padding: var(--space-2) 0;
    min-height: 24px;
}
.sh-text-btn:hover { color: var(--text); }

/* ─── Signed in: the head and the make-a-link form ─── */
.sh-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
}
.sh-head .sh-title { margin: 0; }
.sh-who {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--fs-small);
    color: var(--text-mid);
    white-space: nowrap;
}
.sh-who strong { color: var(--text); font-weight: 600; }

.sh-create { box-shadow: var(--shadow-sm); }
.sh-create-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 16rem 14rem auto;
    gap: var(--space-4);
    align-items: end;
}
.sh-create-grid .cf-field { margin-bottom: 0; }
.sh-create-btn { align-self: end; min-width: 0; }
.sh-prefixed { position: relative; display: block; }
.sh-prefix {
    position: absolute;
    inset-inline-start: var(--space-4);
    inset-block-start: 50%;
    transform: translateY(-50%);
    font-family: var(--font-mono);
    font-size: var(--fs-body);
    color: var(--text-mid);
    pointer-events: none;
}
.sh-prefixed input {
    font-family: var(--font-mono) !important;
    padding-inline-start: 5.75rem !important;
}
.sh-hint {
    margin: var(--space-3) 0 0;
    font-size: var(--fs-small);
    color: var(--text-mid);
}
.sh-msg { margin-top: var(--space-3); }
.sh-ok,
.sh-posted {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
    background: var(--navy-tint);
    color: var(--navy);
    border-radius: var(--radius-sm);
    font-size: var(--fs-small);
}
.sh-posted { margin: var(--space-5) 0 0; font-size: var(--fs-body); }
.sh-posted strong { font-weight: 600; }

/* ─── The register ─── */
/* This page's sections are parts of one tool, not the home page's chapters: style.css's section padding
   (up to 9rem each side) doubled every gap here; each part sets its own margin instead. */
.sh section { padding-block: 0; }
.sh-register { margin-top: var(--space-10); }
.sh-empty { color: var(--text-mid); margin: 0; }
.sh-table-wrap { overflow-x: auto; }
.sh-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-small);
}
.sh-table th {
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-mid);
    text-align: start;
    padding: 0 var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--bg-surface-2);
    white-space: nowrap;
}
.sh-table td {
    height: 48px;
    padding: 0 var(--space-3);
    border-bottom: 1px solid var(--bg-surface);
    white-space: nowrap;
    vertical-align: middle;
    transition: background var(--dur-fast) var(--ease-expo);
}
.sh-table tbody tr:hover td { background: var(--navy-tint); }
.sh-table th:first-child,
.sh-table td:first-child { padding-inline-start: 0; }
.sh-table th:last-child,
.sh-table td:last-child { padding-inline-end: 0; }
.sh-c-code { width: 1%; }
.sh-c-dest {
    max-width: 0;                 /* lets the one flexible column take the rest and end in an ellipsis */
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sh-c-num { text-align: end !important; width: 1%; }
.sh-c-date,
.sh-c-state,
.sh-c-act { width: 1%; }
.sh-code-link { display: inline-block; max-width: 100%; line-height: 1.5rem; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; color: var(--navy); font-weight: 500; }
.sh-code-link:hover { text-decoration: underline; text-underline-offset: 0.25em; }
.sh-dest-label { font-weight: 600; }
.sh-dest-host { color: var(--text-mid); }
.sh-sort { display: inline-flex; align-items: center; min-height: 1.5rem; gap: 0.25em; color: inherit; }   /* 24px targets */
.sh-sort:hover,
.sh-sort.is-on { color: var(--navy); }
.sh-sort-mark { display: inline-block; width: 1ch; }

/* A link just made: its entry line draws its gold tick (the page's one motion) */
.sh-table tr.is-new td { background: var(--navy-tint); }
.sh-table tr.is-new .sh-code-link::before {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1px;
    margin-inline-end: var(--space-2);
    vertical-align: middle;
    background: var(--gold);
    transform-origin: left center;
    animation: shTick var(--dur) var(--ease-expo) both;
}
@keyframes shTick { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Link state: text first, colour second */
.sh-state {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-small);
    white-space: nowrap;
}
.sh-state::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px var(--text-mid);
}
.sh-state[data-state="live"]::before { background: var(--live); box-shadow: none; }
.sh-state[data-state="expired"],
.sh-state[data-state="disabled"] { color: var(--text-mid); }
.sh-state[data-state="held"] { color: var(--terracotta); }
.sh-state[data-state="held"]::before { background: var(--terracotta); box-shadow: none; }

.sh-copy {
    font-size: var(--fs-small);
    font-weight: 600;
    color: var(--navy);
    padding: var(--space-2) var(--space-3);
    min-height: 32px;
    border: 1px solid var(--bg-surface-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-expo), background var(--dur-fast) var(--ease-expo);
}
.sh-copy:hover { border-color: var(--navy); background: var(--white); }
.sh-copy.is-done { color: var(--text); border-color: var(--live); }
.sh-copy-main { border: none; color: var(--white); }
.sh-copy-main:hover { background: var(--gold); color: var(--text); }
.sh-copy-main.is-done { border: none; color: var(--white); background: var(--navy); }

.sh-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    margin-top: var(--space-4);
    font-size: var(--fs-small);
    color: var(--text-mid);
}
.sh-pager-sizes { display: inline-flex; align-items: center; gap: var(--space-2); }
.sh-pager-size,
.sh-pager-steps a { color: var(--navy); padding: var(--space-2); min-width: 24px; text-align: center; }
.sh-pager-size.is-on { font-weight: 600; color: var(--text); text-decoration: underline; text-underline-offset: 0.3em; }
.sh-pager-steps { display: inline-flex; gap: var(--space-4); }
.sh-pager-steps [aria-disabled] { padding: var(--space-2); opacity: 0.55; }

/* ─── A link's page ─── */
.sh-back {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;           /* a 24px target */
    gap: var(--space-2);
    font-size: var(--fs-small);
    font-weight: 600;
    color: var(--navy);
    margin-bottom: var(--space-6);
}
.sh-back::before { content: '←'; }
.sh-back:hover { color: var(--text); }
.sh-link-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-5);
}
.sh-link-title {
    font-size: var(--fs-h3);
    font-weight: 500;
    line-height: var(--lh-tight);
    color: var(--navy);
    margin: 0;
    overflow-wrap: anywhere;
}
.sh-link-host { color: var(--text-mid); font-weight: 400; }
.sh-link-dest {
    margin: var(--space-4) 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sh-link-dest a { color: var(--navy); text-decoration: underline; text-underline-offset: 0.25em; text-decoration-thickness: 1px; }
.sh-link-meta { margin: var(--space-2) 0 0; font-size: var(--fs-small); color: var(--text-mid); }
.sh-sep { margin-inline: var(--space-2); color: var(--bg-surface-2); }
.sh-link-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-5);
}
.sh-link-actions form { display: contents; }
.sh-btn { min-height: var(--sh-control); justify-content: center; }
.sh-notice {
    margin: var(--space-5) 0 0;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface);
    border-inline-start: 2px solid var(--terracotta);
    border-radius: var(--radius-sm);
    max-width: 72ch;
}
.sh-notice a { color: var(--navy); text-decoration: underline; }

/* Totals, like the top of a ledger account */
.sh-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5);
    margin-top: var(--space-10);
}
.sh-kpi {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding-top: var(--space-4);
    border-top: 1px solid var(--bg-surface-2);
}
.sh-kpi-label {
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-mid);
}
.sh-kpi-value { font-size: var(--fs-title); font-weight: 600; color: var(--navy); line-height: var(--lh-tight); }
.sh-kpi-note { font-size: var(--fs-small); color: var(--text-mid); }

/* Opens over 30 days: navy bars on a gold baseline */
.sh-chart { margin-top: var(--space-10); }
.sh-bars { display: block; width: 100%; height: 10rem; }
.sh-bars-base { stroke: var(--gold); stroke-width: 1; }
.sh-bar { fill: var(--navy); transition: fill var(--dur-fast) var(--ease-expo); }
.sh-bar:hover { fill: var(--gold); }
.sh-bar.is-zero { fill: none; }
.sh-bars-axis {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    color: var(--text-mid);
}
.sh-table-toggle { margin-top: var(--space-4); }
.sh-table-toggle summary,
.sh-report summary {
    cursor: pointer;
    color: var(--navy);
    font-weight: 600;
    width: fit-content;
}
.sh-table-toggle summary { font-size: var(--fs-small); }
.sh-table--days { max-width: 24rem; margin-top: var(--space-3); }
.sh-table--days td { height: 36px; }

/* Breakdowns: short ranked lists, a hairline bar each */
.sh-breakdowns {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-6);
    margin-top: var(--space-10);
}
.sh-rank-title {
    font-family: var(--font);
    font-size: var(--fs-micro);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-mid);
    margin: 0 0 var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--bg-surface-2);
}
.sh-rank { margin: 0; padding: 0; }
.sh-rank li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-2) var(--space-3);
    padding-block: var(--space-2);
    font-size: var(--fs-small);
}
.sh-rank-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-rank-bar { grid-column: 1 / -1; width: 100%; height: 4px; display: block; }
.sh-rank-track { fill: var(--bg-surface-2); }
.sh-rank-fill { fill: var(--navy); }
.sh-privacy { margin: var(--space-6) 0 0; font-size: var(--fs-small); color: var(--text-mid); max-width: 72ch; }

/* Change destination: a compact form, so a dialog */
.sh-dialog {
    border: none;
    border-radius: var(--radius);
    padding: var(--space-6);
    width: min(36rem, calc(100vw - 2 * var(--space-4)));
    background: var(--white);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    margin: auto;                 /* the site's reset removes the browser's centring */
    max-height: calc(100dvh - 2 * var(--space-4));
    overflow-y: auto;
}
.sh-dialog::backdrop { background: rgba(22, 36, 47, 0.45); }
.sh-dialog-note { margin: var(--space-2) 0 var(--space-5); color: var(--text-mid); font-size: var(--fs-small); }
.sh-dialog-actions { display: flex; gap: var(--space-3); margin-top: var(--space-2); }

/* A row's actions: Copy, then a small menu (Statistics, Disable or Enable, Delete) in a popover, which sits in
   the top layer so the table's scroll box cannot clip it; short.js places it under its button. */
.sh-row-acts { display: inline-flex; align-items: center; gap: var(--space-2); }
.sh-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text-mid);
    fill: currentColor;
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease-expo), border-color var(--dur-fast) var(--ease-expo);
}
.sh-more-btn:hover,
.sh-more-btn:focus-visible { color: var(--navy); border-color: var(--bg-surface-2); }
.sh-more-menu {
    margin: auto;
    min-width: 12rem;
    padding: var(--space-2);
    border: 1px solid var(--bg-surface-2);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}
.sh-more-menu form { display: contents; }
.sh-more-menu a,
.sh-more-menu button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 2.5rem;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font: inherit;
    font-size: var(--fs-small);
    text-align: start;
    white-space: nowrap;
    cursor: pointer;
}
.sh-more-menu a:hover,
.sh-more-menu button:hover,
.sh-more-menu a:focus-visible,
.sh-more-menu button:focus-visible { background: var(--navy-tint); color: var(--navy); }

/* Delete asks first, on the link's page: what is deleted and what follows, then the two choices */
.sh-confirm {
    margin-top: var(--space-5);
    padding: var(--space-5) var(--space-6);
    border: 1px solid var(--bg-surface-2);
    border-radius: var(--radius);
    background: var(--white);
    max-width: 44rem;
    scroll-margin-top: 7rem;      /* the jump to #delete clears the fixed nav */
}
#sh-delete-h:focus { outline: none; }   /* focused for screen readers, not an action: no ring */
.sh-confirm-note { margin: var(--space-2) 0 var(--space-5); color: var(--text-mid); max-width: 62ch; text-wrap: pretty; }
.sh-confirm-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.sh-confirm-actions .cf-submit { width: auto; padding-inline: var(--space-6); }

/* QR code: the code on white, ruled like the ledger's cards; its note on one line */
.sh-qr {
    width: 15rem;
    aspect-ratio: 1;
    margin: 0 auto;
    border: 1px solid var(--bg-surface-2);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.sh-qr svg { display: block; width: 100%; height: 100%; }
.sh-qr-note { margin: var(--space-4) 0 var(--space-5); font-size: var(--fs-small); color: var(--text-mid); text-align: center; text-wrap: balance; }

.sh-plain { padding-block-start: var(--space-6); }
.sh-ref { color: var(--text-mid); font-size: var(--fs-small); }

/* ─── Report a link ─── */
.sh-report { margin-top: var(--space-12); padding-block: 0; }
.sh-report summary {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    list-style: none;
}
.sh-report summary::-webkit-details-marker { display: none; }
.sh-report summary::before {
    content: '';
    flex: 0 0 1.625rem;
    height: 1px;
    background: var(--gold);
}
.sh-report-form { margin-top: var(--space-5); max-width: 48rem; }
.sh-report .sh-msg { max-width: 48rem; }

/* ─── Widths below the desktop ─── */
@media (max-width: 1100px) {
    .sh-create-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .sh-f-target { grid-column: 1 / -1; }
    .sh-create-btn { grid-column: 1 / -1; justify-self: start; min-width: 200px; }
    .sh-breakdowns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .sh-intro-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
    .sh-head { flex-direction: column; align-items: flex-start; gap: var(--space-4); }
    .sh-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .sh-create-grid { grid-template-columns: minmax(0, 1fr); }
    .sh-create-btn { width: 100%; }
    .sh-breakdowns { grid-template-columns: minmax(0, 1fr); }
    .sh-pager { flex-wrap: wrap; }
    .sh-who { white-space: normal; flex-wrap: wrap; }
    /* The register keeps what a phone decision needs; where it goes, when it was made and when it
       expires are one tap away on the link's own page. */
    .sh-table .sh-c-dest,
    .sh-table .sh-c-date { display: none; }
    .sh-table .sh-c-code { width: 100%; max-width: 0; }   /* the code takes the room left, ending in an ellipsis */
    .sh-code-host { display: none; }                       /* the column head already says it is the short link */
    .sh-row-acts .sh-copy { display: none; }               /* on a phone Copy lives in the row's menu, so the code keeps its room */
    .sh-dialog { padding: var(--space-5); }
    .sh-dialog-actions { flex-wrap: wrap; }
    .sh-dialog-actions > * { flex: 1 1 0; padding-inline: var(--space-3); white-space: nowrap; }
    .sh-dialog-actions > .cf-submit { flex-basis: 100%; }
    .sh-confirm { padding: var(--space-5); }
    .sh-confirm-actions > * { flex: 1 1 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .sh-table tr.is-new .sh-code-link::before { animation: none; }
}
@media (forced-colors: active) {
    .sh-copy, .sh-state::before { border: 1px solid ButtonText; }
    .sh-bar { fill: CanvasText; }
}

/* The address carried from the home page's "Shorten it", waiting for sign-in */
.sh-carried {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    margin: 0 0 var(--space-6);
    padding: var(--space-3) var(--space-4);
    background: var(--navy-tint);
    color: var(--navy);
    border-radius: var(--radius-sm);
    max-width: 52ch;
}
.sh-carried strong { font-weight: 600; overflow-wrap: anywhere; }
