/*
  TimeReport's stylesheet. The direction is in .impeccable.md: a printed timesheet, the
  figure first, hairline rules, one accent. Phone first.
  The login pages keep Microsoft's markup and are styled through the class names it carries
  (form-floating, form-control, btn, alert, text-danger); see docs/decisions/003-login.md.
*/

@font-face {
    font-family: "Familjen Grotesk";
    src: url("fonts/familjen-grotesk.woff2") format("woff2");
    font-weight: 400 700;
    font-display: swap;
}

@font-face {
    font-family: "Schibsted Grotesk";
    src: url("fonts/schibsted-grotesk.woff2") format("woff2");
    font-weight: 400 900;
    font-display: swap;
}

:root {
    color-scheme: light dark;

    /* Paper and ink, tinted towards the accent's green. */
    --paper: light-dark(oklch(0.985 0.004 150), oklch(0.19 0.008 160));
    --sheet: light-dark(oklch(0.998 0.002 150), oklch(0.225 0.009 160));
    --shade: light-dark(oklch(0.955 0.007 150), oklch(0.26 0.01 160));
    --rule: light-dark(oklch(0.87 0.01 150), oklch(0.36 0.012 160));
    --rule-strong: light-dark(oklch(0.55 0.015 155), oklch(0.6 0.015 155));
    --ink: light-dark(oklch(0.23 0.015 160), oklch(0.93 0.008 150));
    --ink-soft: light-dark(oklch(0.46 0.015 158), oklch(0.72 0.012 155));

    --accent: light-dark(oklch(0.4 0.085 158), oklch(0.78 0.11 158));
    --accent-ink: light-dark(oklch(0.985 0.01 150), oklch(0.2 0.03 160));
    --accent-wash: light-dark(oklch(0.94 0.035 158), oklch(0.3 0.04 158));
    --failed: light-dark(oklch(0.46 0.15 32), oklch(0.76 0.12 35));
    --failed-wash: light-dark(oklch(0.95 0.03 35), oklch(0.3 0.05 32));
    --waiting: light-dark(oklch(0.5 0.1 80), oklch(0.82 0.11 85));
    --waiting-wash: light-dark(oklch(0.95 0.045 90), oklch(0.31 0.045 85));

    /* 4-point spacing scale. */
    --space-2xs: 0.25rem;
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Type: five steps, ratio about 1.3. */
    --text-xs: 0.8125rem;
    --text-sm: 0.9375rem;
    --text-md: 1.0625rem;
    --text-lg: 1.375rem;
    --text-xl: 1.875rem;
    --text-figure: 3rem;

    --font-text: "Schibsted Grotesk", system-ui, sans-serif;
    --font-display: "Familjen Grotesk", "Schibsted Grotesk", system-ui, sans-serif;

    --radius: 0.375rem;
    --tap: 2.75rem;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-family: var(--font-text);
    font-size: 100%;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    background: var(--paper);
    color: var(--ink);
    font-size: var(--text-md);
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 650;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0;
}

h1 {
    font-size: var(--text-xl);
}

h1:focus {
    outline: none;
}

h2 {
    font-size: var(--text-lg);
}

h3 {
    font-size: var(--text-md);
}

p {
    margin: 0;
    max-width: 68ch;
}

a {
    color: var(--accent);
    text-underline-offset: 0.15em;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- The frame: a top line, the page, and on the phone a bar at the thumb ---------- */

.app-header {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xs) var(--space-md);
    border-bottom: 1px solid var(--rule);
}

.app-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-md);
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
}

.app-nav {
    display: flex;
    gap: var(--space-2xs);
}

.app-nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    padding: 0 var(--space-sm);
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 550;
    border-radius: var(--radius);
}

.app-nav a:hover {
    color: var(--ink);
}

.app-nav a.active {
    color: var(--ink);
    box-shadow: inset 0 -2px 0 var(--accent);
    border-radius: 0;
}

.sign-out {
    margin: 0 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.signed-in-as {
    display: none;
    color: var(--ink-soft);
    font-size: var(--text-xs);
}

.app-main {
    display: grid;
    gap: var(--space-lg);
    align-content: start;
    max-width: 44rem;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md) var(--space-2xl);
}

.app-main.wide {
    max-width: 78rem;
}

@media (max-width: 40rem) {
    .app-header .app-nav {
        position: fixed;
        inset: auto 0 0 0;
        z-index: 10;
        justify-content: space-around;
        padding: var(--space-2xs) var(--space-xs) max(var(--space-2xs), env(safe-area-inset-bottom));
        background: var(--sheet);
        border-top: 1px solid var(--rule);
    }

    .app-header .app-nav a {
        flex: 1;
        justify-content: center;
        min-height: 3.25rem;
    }

    .app-nav a.active {
        box-shadow: inset 0 2px 0 var(--accent);
    }

    .app-main {
        padding-bottom: 6rem;
    }
}

@media (min-width: 40rem) {
    .signed-in-as {
        display: inline;
    }
}

/* ---------- Page furniture ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-sm) var(--space-lg);
}

.eyebrow {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.lede {
    color: var(--ink-soft);
}

.section {
    display: grid;
    gap: var(--space-sm);
}

.section > h2 {
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--rule-strong);
}

.stack {
    display: grid;
    gap: var(--space-md);
}

.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

.muted {
    color: var(--ink-soft);
}

.small {
    font-size: var(--text-sm);
}

.figure {
    font-family: var(--font-display);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
}

.right {
    text-align: right;
}

/* ---------- Lists that read like lines in a ledger ---------- */

.lines {
    list-style: none;
    margin: 0;
    padding: 0;
}

.lines > li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--rule);
}

.lines > li > a:first-child {
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
}

.lines > li > a:first-child:hover {
    text-decoration: underline;
}

.lines .line-main {
    display: grid;
    gap: var(--space-2xs);
    min-width: 0;
}

.lines .line-side {
    flex: none;
    text-align: right;
    white-space: nowrap;
}

table.ledger {
    width: 100%;
    border-collapse: collapse;
}

table.ledger th {
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
    text-align: left;
    padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
    border-bottom: 1px solid var(--rule-strong);
}

table.ledger td {
    padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
    border-bottom: 1px solid var(--rule);
    vertical-align: baseline;
}

table.ledger tbody th {
    border-bottom-color: var(--rule);
    padding-right: var(--space-lg);
    white-space: nowrap;
}

/* Amounts are set to the right. Not in tabular figures: that setting widens the comma and
   the full stop of this typeface, and amounts that all end in ",00 kr" line up without it.
   The month sheet, which holds whole hours only, uses tabular figures. */
table.ledger .num {
    text-align: right;
}

/* ---------- Words for a state ---------- */

.state {
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    padding: 0.1em 0.55em;
    border-radius: 999px;
    font-size: var(--text-xs);
    font-weight: 600;
    background: var(--shade);
    color: var(--ink);
    white-space: nowrap;
}

.state.ok {
    background: var(--accent-wash);
    color: var(--accent);
}

.state.waiting {
    background: var(--waiting-wash);
    color: var(--waiting);
}

.state.failed {
    background: var(--failed-wash);
    color: var(--failed);
}

/* ---------- Forms ---------- */

.form {
    display: grid;
    gap: var(--space-md);
    max-width: 32rem;
}

.field {
    display: grid;
    gap: var(--space-2xs);
}

.field > label,
.form-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink-soft);
}

.field .hint {
    font-size: var(--text-xs);
    color: var(--ink-soft);
}

.fields-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: var(--space-md);
}

/* An input without a type is a text input: Blazor's InputText writes none. */
input:not([type]),
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea,
.form-control {
    width: 100%;
    min-height: var(--tap);
    padding: var(--space-xs) var(--space-sm);
    font: inherit;
    font-size: max(1rem, var(--text-md));
    color: var(--ink);
    background: var(--sheet);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
}

textarea {
    min-height: 5rem;
    resize: vertical;
}

input[inputmode="numeric"],
input[inputmode="decimal"],
input[type="date"] {
    font-variant-numeric: tabular-nums;
}

input.invalid,
.form-control.invalid {
    border-color: var(--failed);
}

.check {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    min-height: var(--tap);
}

.check input {
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--accent);
}

.btn,
button.primary,
button.quiet,
a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 var(--space-lg);
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 120ms var(--ease-out), border-color 120ms var(--ease-out);
}

.btn-primary,
button.primary,
a.button.primary {
    background: var(--accent);
    color: var(--accent-ink);
}

.btn-primary:hover,
button.primary:hover,
a.button.primary:hover {
    background: color-mix(in oklch, var(--accent), var(--ink) 15%);
}

button.quiet,
a.button {
    background: transparent;
    color: var(--ink);
    border-color: var(--rule-strong);
}

button.quiet:hover,
a.button:hover {
    background: var(--shade);
}

.btn-link,
button.link {
    min-height: var(--tap);
    padding: 0 var(--space-xs);
    font: inherit;
    font-size: var(--text-sm);
    background: none;
    border: 0;
    color: var(--ink-soft);
    text-decoration: underline;
    text-underline-offset: 0.15em;
    cursor: pointer;
}

.btn-link:hover,
button.link:hover {
    color: var(--ink);
}

/* The login pages' own helpers. */

.mb-3 {
    margin-bottom: var(--space-md);
}

.w-100 {
    width: 100%;
}

.form-floating {
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-2xs);
}

.form-control::placeholder {
    color: transparent;
}

/* ---------- Messages ---------- */

.notice,
.alert {
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--sheet);
}

.notice.ok,
.alert-success {
    border-color: var(--accent);
    background: var(--accent-wash);
}

.notice.failed,
.alert-danger {
    border-color: var(--failed);
    background: var(--failed-wash);
    color: var(--failed);
}

.notice.waiting {
    border-color: var(--waiting);
    background: var(--waiting-wash);
}

.text-danger,
.validation-message {
    color: var(--failed);
}

.validation-message {
    font-size: var(--text-sm);
}

ul.validation-errors {
    margin: 0;
    padding-left: var(--space-lg);
}

.blazor-error-boundary {
    padding: var(--space-md);
    background: var(--failed);
    color: var(--accent-ink);
}

.blazor-error-boundary::after {
    content: "Ett fel har inträffat.";
}

/* ---------- Rates on a project ---------- */

.rate-type {
    display: grid;
    gap: var(--space-sm);
    padding: var(--space-md) 0 var(--space-lg);
    border-bottom: 1px solid var(--rule);
}

.rate-form {
    align-items: end;
}

.rate-form .field {
    flex: 1 1 9rem;
    max-width: 14rem;
}

details > summary {
    cursor: pointer;
    min-height: var(--tap);
    display: flex;
    align-items: center;
    width: fit-content;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- A day's hours: the start page, made for one hand ---------- */

.day-head {
    display: grid;
    grid-template-columns: var(--tap) 1fr var(--tap);
    align-items: center;
    gap: var(--space-xs);
}

.day-title {
    display: grid;
    gap: var(--space-2xs);
    text-align: center;
}

.day-title h1::first-letter {
    text-transform: uppercase;
}

.day-step {
    display: grid;
    place-items: center;
    width: var(--tap);
    height: var(--tap);
    font-size: var(--text-lg);
    color: var(--ink-soft);
    text-decoration: none;
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

.day-step:hover {
    color: var(--ink);
    background: var(--shade);
}

.day-form {
    display: grid;
}

.entry {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--space-xs) var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--rule);
}

.entry:first-child {
    border-top: 1px solid var(--rule-strong);
}

.entry-what {
    display: grid;
    gap: var(--space-2xs);
    min-width: 0;
}

.entry-project {
    font-weight: 650;
}

.stepper {
    display: grid;
    grid-template-columns: 3rem 4.5rem 3rem;
    align-items: stretch;
}

.stepper button {
    font: inherit;
    font-size: var(--text-lg);
    color: var(--ink);
    background: var(--shade);
    border: 1px solid var(--rule-strong);
    cursor: pointer;
    touch-action: manipulation;
}

.stepper button:first-child {
    border-radius: var(--radius) 0 0 var(--radius);
}

.stepper button:last-child {
    border-radius: 0 var(--radius) var(--radius) 0;
}

.stepper button:active {
    background: var(--rule);
}

.stepper input {
    min-height: 3.5rem;
    padding: 0;
    text-align: center;
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
}

.entry-locked {
    display: flex;
    align-items: baseline;
    gap: var(--space-sm);
}

.entry-figure {
    font-size: var(--text-xl);
}

.entry-note {
    grid-column: 1 / -1;
}

.day-foot {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    background: var(--paper);
}

.day-total {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
}

.day-total .figure {
    font-size: var(--text-figure);
    line-height: 1;
}

.day-foot button {
    min-width: 9rem;
    min-height: 3.25rem;
}

@media (max-width: 40rem) {
    .day-foot {
        bottom: 3.75rem;
    }
}

/* ---------- The month ---------- */

.month-head h1::first-letter {
    text-transform: uppercase;
}

.month-total .figure {
    font-size: var(--text-xl);
}

.line-side .delivery {
    display: block;
    white-space: normal;
    max-width: 22rem;
}

/* On a phone: a list of days, each a link to the day. */

.days {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--rule-strong);
}

.days li {
    border-bottom: 1px solid var(--rule);
}

.days li.weekend {
    background: var(--shade);
}

.days a {
    display: grid;
    grid-template-columns: 2rem 2.5rem 1fr auto;
    align-items: baseline;
    gap: var(--space-sm);
    min-height: var(--tap);
    padding: var(--space-xs) var(--space-xs);
    color: var(--ink);
    text-decoration: none;
}

.days .day-number {
    text-align: right;
}

.days .today .day-number {
    color: var(--accent);
}

.days .day-what {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* On a computer: the sheet. */

.sheet-wrap {
    overflow-x: auto;
}

table.sheet {
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}

table.sheet th,
table.sheet td {
    padding: 0 var(--space-sm);
    height: 2.25rem;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}

table.sheet thead th {
    height: auto;
    padding-bottom: var(--space-xs);
    vertical-align: bottom;
    border-bottom: 1px solid var(--rule-strong);
    font-weight: 600;
}

table.sheet .num {
    text-align: right;
}

.sheet-project,
.sheet-rate {
    display: block;
}

.sheet-rate {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--ink-soft);
}

table.sheet .sheet-day {
    text-align: left;
    font-weight: 500;
    min-width: 5.5rem;
}

table.sheet .sheet-day a {
    color: inherit;
    text-decoration: none;
}

table.sheet .sheet-day a:hover {
    text-decoration: underline;
}

table.sheet tr.weekend > * {
    background: var(--shade);
}

table.sheet tr.today .sheet-day .figure {
    color: var(--accent);
}

table.sheet td.sheet-sum,
table.sheet th.sheet-sum {
    border-left: 1px solid var(--rule-strong);
    font-family: var(--font-display);
    font-weight: 650;
    min-width: 4.5rem;
}

table.sheet tfoot th,
table.sheet tfoot td {
    border-top: 1px solid var(--rule-strong);
    border-bottom: 0;
    font-family: var(--font-display);
    font-weight: 650;
    height: 2.75rem;
}

table.sheet td input {
    width: 4rem;
    min-height: 1.9rem;
    height: 1.9rem;
    padding: 0 var(--space-xs);
    text-align: right;
    font-size: var(--text-md);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.2rem;
}

table.sheet td input:hover {
    border-color: var(--rule);
}

table.sheet td input:focus {
    background: var(--sheet);
    border-color: var(--accent);
    outline: none;
}

/* A cell with a note carries a small mark in its corner; the note is its title. */
table.sheet td.has-note {
    background-image: linear-gradient(225deg, var(--waiting) 0.35rem, transparent 0.35rem);
}

/* ---------- Fakturera: the page that slows down ---------- */

table.invoice-lines tfoot th {
    text-align: right;
    text-transform: none;
    letter-spacing: 0;
    font-size: var(--text-sm);
    border-bottom: 0;
    padding-top: var(--space-xs);
}

table.invoice-lines tfoot td {
    border-bottom: 0;
}

table.invoice-lines tfoot tr:first-child > * {
    border-top: 1px solid var(--rule-strong);
}

table.invoice-lines tfoot tr.total > * {
    font-size: var(--text-lg);
    color: var(--ink);
    padding-top: var(--space-sm);
}

.confirm {
    padding: var(--space-lg);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    background: var(--sheet);
}

.confirm > h2 {
    border-bottom: 0;
    padding-bottom: 0;
}

.line-side .button {
    padding: 0 var(--space-md);
    margin-left: var(--space-sm);
}

/* ---------- The login pages' remaining helpers ---------- */

.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.mx-auto {
    margin-inline: auto;
}

a.signed-in-as {
    text-decoration: none;
}

a.signed-in-as:hover {
    text-decoration: underline;
}

@media (max-width: 40rem) {
    /* On the phone the address is the way to the account page, so it is shown. */
    .signed-in-as {
        display: inline;
        max-width: 9rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

code {
    font-size: 0.9em;
    padding: 0.1em 0.3em;
    background: var(--shade);
    border-radius: 0.2rem;
}
