/*
 * Listari design tokens (Claude Design project "Listari mobile app design").
 * The same values are mapped into Tailwind in tailwind.config.js.
 */
:root {
    --ink: #141414;
    --paper: #F5F5F3;
    --line: #E3E3E0;
    --line-strong: #D6D6D2;
    --muted: #6F6F6B;
    --brand: #E0301E;
    --brand-dark: #B8261A;
    --surface: #FFFFFF;
    --on-ink: #FFFFFF;
    --warning: #E6C200;
    --warning-soft: #FFF3C4;
    --warning-ink: #6B5500;
    --success: #1F7A3A;      /* 3.91.0: design system tokens for the VALMIS / HYL. tags */
    --success-soft: #E7F4E9;
    --on-success: #FFFFFF;
    --brand-soft: #FCEBE8;
    --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --radius: 2px;
    /* 3.96.0: more design system tokens (.design-sync/package/styles.css) for the dialog,
       buttons and fields. */
    --ink-hover: #000000;
    --ink-600: #57574F;
    --faint: #A3A39E;
    --on-brand: #FFFFFF;
    --backdrop: rgba(14, 14, 14, 0.4);
    --shadow-dialog: 0 30px 60px rgba(0, 0, 0, 0.2);
    --font-sans: "Geist", ui-sans-serif, system-ui, sans-serif;
    --space-2: 8px;
    --control-sm: 36px;
    --control-md: 40px;
    --control-input: 44px;
    --control-lg: 46px;
}
/* Tag (design system component "Tag"): a boxed mono label. Tones: outline (default),
   ink fill, warning. ls-tag-lg is the 10px size (TESTI, the editor's mode tag). */
.ls-tag {
    display: inline-block;
    font: 600 9px/14px var(--font-mono);
    letter-spacing: .06em;
    padding: 0 4px;
    border: 1px solid var(--ink);
    background: var(--surface);
    color: var(--ink);
    white-space: nowrap;
}
.ls-tag-lg { font-size: 10px; line-height: 16px; }
.ls-tag-invoice { background: var(--ink); color: var(--on-ink); }
.ls-tag-check { background: var(--warning-soft); border-color: var(--warning); color: var(--warning-ink); }
.ls-tag-rejected { border-color: var(--brand); color: var(--brand-dark); }
.ls-tag-ready { background: var(--success); border-color: var(--success); color: var(--on-success); }
/* Skeleton ("ghost screen") loading placeholders, see js/skeleton.js. */
.skeleton {
    background-color: var(--line);
    animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton {
        animation: none;
    }
}

/* Protected pages start hidden until their session check passes
   (utils.revealPage()), so logged-out visitors never see them flash. */
html.auth-pending body {
    visibility: hidden;
}
body {
    color: var(--ink);
    font-family: 'Geist', ui-sans-serif, system-ui, sans-serif;
    overscroll-behavior: none; /* Prevents pull-to-refresh on canvas */
}
.controls-section {
    background-color: var(--paper);
    border-right: 1px solid var(--line);
}
.control-group {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    background-color: var(--surface);
}
.direction-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 150px;
    height: 150px;
}
.direction-pad button {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    line-height: 1;
    border: 1px solid var(--line-strong);
    background-color: white;
    transition: background-color: 0.2s;
}
@media (hover: hover) {
    .direction-pad button:hover {
        background-color: var(--paper);
    }
}
.direction-pad button:active {
    background-color: var(--ink);
    color: #ffffff;
}
/*
 * Full visible height. On phones 100vh also counts the area behind the
 * browser and system navigation bars, which hid the phone dock; dvh is the
 * visible height (100vh stays as the fallback for older browsers).
 */
.h-app {
    height: 100vh;
    height: 100dvh;
}
/* Keyboard hint panel on the editor canvas (PC). */
#keyHint kbd {
    font-family: 'Geist Mono', ui-monospace, monospace;
    font-size: 10.5px;
    padding: 0 4px;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
}
/* Compass arrows: one SVG shape rotated per key (editor.html). */
.pad-arrow {
    width: 55%;
    height: 55%;
    pointer-events: none;
}
/* Phone dock (editor.html #mobileDock): glove-sized keys, 64 px. */
.direction-pad-lg {
    width: auto;
    height: auto;
    grid-template-columns: repeat(3, 64px);
    grid-auto-rows: 64px;
    gap: 6px;
}
.direction-pad-lg button {
    font-size: 1.9rem;
    border-width: 1.5px;
    border-color: var(--ink);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.dock-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 64px;
}
.dock-btn {
    height: 64px;
    width: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: 1.5px solid var(--line-strong);
    border-radius: var(--radius);
    background: #ffffff;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.dock-btn:active {
    background-color: var(--ink);
    color: #ffffff;
}
.dock-btn.hidden {
    display: none;
}
/* Fine-tune −1 / +1 buttons (editor.html #fineTuneBar): glove-sized, hold to repeat. */
.ft-btn {
    height: 56px;
    width: 56px;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius);
    background: #ffffff;
    font-family: 'Geist Mono', ui-monospace, monospace;
    font-size: 1.15rem;
    font-weight: 600;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}
.ft-btn:active:not(:disabled) {
    background: var(--ink);
    color: #ffffff;
}
.ft-btn:disabled {
    opacity: 0.35;
}
/* Three columns on a small laptop (1024–1279 px) leave a narrow drawing: compact bar. */
@media (min-width: 1024px) and (max-width: 1279px) {
    #fineTuneBar .ft-btn {
        width: 46px;
    }
    #fineTuneBar #fineTuneValue {
        min-width: 84px;
    }
    #fineTuneBar #fineTuneVar {
        width: 42px;
    }
    #fineTuneBar #fineTuneLabel {
        display: none;
    }
    /* Left-aligned so it stays clear of the zoom buttons on the right. */
    #fineTuneBar {
        left: 12px;
        --tw-translate-x: 0;
        transform: none;
    }
}
/* Edge tabs: hide / show a side panel (dashboard detail panel, editor columns). */
.edge-tab {
    width: 26px;
    height: 34px;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    color: var(--muted);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
    cursor: pointer;
}
.edge-tab:hover,
.edge-tab:focus-visible {
    color: var(--ink);
    border-color: var(--ink);
    outline: none;
}
/*
 * Editor top bar (≥768 px, js/editorTopBar.js): the order actions moved in from the
 * menu keep their ids and listeners; these rules turn the menu's full-width buttons
 * into compact bar buttons (id selectors outrank the Tailwind utilities).
 */
#editorTopBar #previewBtn,
#editorTopBar #submitReviewBtn,
#editorTopBar #saveChangesBtn,
#editorTopBar #completeOrderBtn,
#editorTopBar #saveDraftBtn {
    width: auto;
    margin-top: 0;
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    white-space: nowrap;
    border-radius: var(--radius);
}
#editorTopBar #saveDraftBtn {
    display: inline-flex;
    gap: 0.4rem;
}
#editorTopBar #saveDraftBtn.hidden {
    display: none;
}
/* The draft button is an icon in the menu; the bar has room for its name. */
#editorTopBar #saveDraftBtn::after {
    content: "Tallenna luonnos";
    font-weight: 600;
}
#editorTopBar #backToDashboardBtn {
    flex: none;
}
/* Clear order: an icon in the menu, labelled in the bar. */
#editorTopBar #clearBtn {
    width: auto;
    display: inline-flex;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    white-space: nowrap;
}
#editorTopBar #clearBtn.hidden {
    display: none;
}
#editorTopBar #clearBtn::after {
    content: "Tyhjennä";
    font-weight: 600;
}
/* Reference (viite) chip in the bar: goes on the invoice, so it stands out. */
.topbar-ref {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0.2rem 0.7rem 0.2rem 0.6rem;
    border: 1px solid var(--ink);
    border-left: 3px solid var(--brand);
    border-radius: var(--radius);
    line-height: 1.15;
}
/* Site name and viite in the bar open the order details when editable. */
.topbar-editable {
    cursor: pointer;
    border-radius: var(--radius);
}
#topBarTitle.topbar-editable:hover #topBarSite {
    text-decoration: underline;
    text-underline-offset: 3px;
}
.topbar-ref.topbar-editable:hover {
    background-color: var(--paper);
}
.topbar-editable:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}
.topbar-ref-default #topBarRefValue {
    color: var(--muted);
    font-style: italic;
}
.topbar-ref-missing #topBarRefValue {
    color: var(--brand);
    font-style: italic;
}
/* Narrower screens: secondary buttons and the save status as icons only (tooltips keep the names). */
@media (max-width: 1279px) {
    #editorTopBar #saveDraftBtn::after,
    #editorTopBar #clearBtn::after {
        content: none;
    }
    #editorTopBar .save-status-text {
        display: none !important;
    }
}
#editorModeIndicator {
    flex: none;
    cursor: help;
}
#sidebarHeader #editorModeIndicator {
    margin-left: 0.25rem;
}
.save-status-text {
    display: none;
}
#editorTopBar #saveStatusIndicator {
    gap: 0.35rem;
    margin-right: 0.25rem;
}
#editorTopBar .save-status-text {
    display: inline;
    font-size: 0.8125rem;
    white-space: nowrap;
}
/* Editor column / table tabs sit on the drawing's edge next to what they hide. */
.edge-tab-left {
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}
.edge-tab-right {
    border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
}
.edge-tab-bottom {
    width: 34px;
    height: 26px;
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
}
/*
 * Hidden columns (js/editorLayout.js initColumnToggles): the column slides out past
 * the screen edge (negative margin, so its content doesn't reflow while moving) and
 * the drawing grows into the space. Phones keep the slide-out menu.
 */
@media (min-width: 768px) {
    #controlsPanel {
        transition: margin-left .25s ease, visibility 0s linear 0s;
    }
    body.editor-left-closed #controlsPanel {
        margin-left: -33.3333%;
        visibility: hidden;
        transition: margin-left .25s ease, visibility 0s linear .25s;
    }
}
@media (min-width: 1024px) {
    body.editor-left-closed #controlsPanel {
        margin-left: -320px;
    }
    #propertiesPanel {
        transition: margin-right .25s ease, visibility 0s linear 0s;
    }
    body.editor-right-closed #propertiesPanel {
        margin-right: -320px;
        visibility: hidden;
        transition: margin-right .25s ease, visibility 0s linear .25s;
    }
    /* The summary box repeats the right column's details on wide screens. */
    #summaryBox {
        display: none !important;
    }
}
@media (prefers-reduced-motion: reduce) {
    #controlsPanel, #propertiesPanel, .param-table-wrap {
        transition: none !important;
    }
}
/* Parametric measurements table below the drawing: slides down to hide (js/ui.js). */
.param-table-wrap {
    max-height: 40vh;
    transition: max-height .25s ease;
}
#parametricRightPane.param-collapsed .param-table-wrap {
    max-height: 0;
}
/* Undo / redo under the PC compass on the canvas (#desktopDrawDock). */
.dock-btn-sm {
    height: 40px;
    width: 100%;
}
.dock-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}
.direction-pad .center-btn {
    grid-column: 2;
    grid-row: 2;
    background-color: var(--line);
    font-size: 0.75rem;
    font-weight: 600;
}
canvas {
    cursor: grab;
    touch-action: none; /* Prevents browser gestures on canvas */
}
#canvas {
    display: block; /* Sized in JS (high-DPI); no inline baseline gap */
}
canvas:active {
    cursor: grabbing;
}
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--backdrop); /* 3.96.0: the design system's scrim */
    display: flex;
    justify-content: center;
    /* Align to top with padding for mobile to make space for keyboard */
    align-items: flex-start;
    padding-top: 4rem; /* 64px */
    z-index: 1000;
    overflow-y: auto; /* Allow scrolling if content is still too long */
}
@media (min-width: 768px) {
    .modal-overlay {
        /* Center on desktop screens */
        align-items: center;
        padding-top: 0;
    }
}
/*
 * Phones: the on-screen keyboard covers the lower half. Only the dialog moves:
 * the overlay covers just the visible area above the keyboard (--vv-top /
 * --vv-height from utils.trackVisualViewport); the page underneath keeps its
 * size. The dialog is compact, fits that area and keeps its OK / Peruuta row
 * pinned at the bottom (the form scrolls instead).
 */
@media (max-width: 767px) {
    .modal-overlay {
        top: var(--vv-top, 0px);
        bottom: auto;
        height: var(--vv-height, 100%);
        padding: 0.75rem 0;
    }
    #promptModal .modal-content {
        padding: 1.25rem;
        max-height: 100%;
        overflow-y: auto;
    }
    #promptModal .modal-content h3 {
        margin-bottom: 0.5rem;
    }
    #promptModal .modal-content #promptMessage {
        margin-bottom: 0.75rem;
    }
    #promptModal #promptInputsContainer {
        margin-bottom: 1rem;
    }
    #promptModal .modal-content > .flex.justify-end {
        position: sticky;
        bottom: -1.25rem;
        margin: 0 -1.25rem -1.25rem;
        padding: 0.75rem 1.25rem;
        background: var(--surface);
        border-top: 1px solid var(--line);
    }
    #promptModal .modal-content > .flex.justify-end button {
        min-height: 48px;
        min-width: 96px;
    }
}
/* 3.96.0 (legacy style sweep): every .modal-content dialog takes the design system's Dialog
   look (.design-sync/package, Dialog): surface, a 3px ink top edge, the dialog shadow, square;
   the × is the square ls-close. Wider dialogs keep their own max-w-* utility. */
.modal-content {
    background: var(--surface);
    border-top: 3px solid var(--ink);
    border-radius: 0;
    padding: 26px;
    box-shadow: var(--shadow-dialog);
    width: calc(100% - 32px);
    max-width: 440px;
    box-sizing: border-box;
}
.modal-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background-color: transparent;
    color: var(--muted);
}
.modal-close-btn:hover {
    background-color: var(--paper);
    color: var(--ink);
}
/* Hide scrollbar for the controls panel but allow scrolling */
.controls-scroller::-webkit-scrollbar {
    display: none;
}
.controls-scroller {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
/*
 * Work card fonts (js/svgText.js): one family per weight, so the SVG pages,
 * the PNG and the PDF (which embeds the same files) all use identical metrics.
 */
@font-face { font-family: LGeist400; src: url(fonts/Geist-Regular.ttf) format('truetype'); font-display: block; }
@font-face { font-family: LGeist500; src: url(fonts/Geist-Medium.ttf) format('truetype'); font-display: block; }
@font-face { font-family: LGeist600; src: url(fonts/Geist-SemiBold.ttf) format('truetype'); font-display: block; }
@font-face { font-family: LGeistMono500; src: url(fonts/GeistMono-Medium.ttf) format('truetype'); font-display: block; }
@font-face { font-family: LGeistMono600; src: url(fonts/GeistMono-SemiBold.ttf) format('truetype'); font-display: block; }

/* Work card preview (js/preview.js): toolbar on top, A4 pages below. */
.preview-overlay {
    position: fixed;
    inset: 0;
    background-color: #e3e3e0;
    z-index: 2000;
    overflow-y: auto;
}
.work-card-toolbar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #ffffff;
    border-bottom: 1px solid #cfcfca;
}
.work-card-title {
    font-weight: 600;
    font-size: 15px;
    margin-right: 12px;
}
/* Phones (3.70.2): the title and × on the first row (× top-right, where a close button is
   expected), the marks toggle, PDF and Tulosta on the second. */
@media (max-width: 639px) {
    .work-card-toolbar .work-card-title { order: 0; flex: 0 0 calc(100% - 44px); margin-right: 0; }
    .work-card-toolbar [data-wc="close"] { order: 1; }
    .work-card-toolbar > :not(.work-card-title):not([data-wc="close"]) { order: 2; }
}
.work-card-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 16px;
}
.work-card-page {
    width: 100%;
    max-width: 210mm;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(20, 20, 20, .15), 0 8px 24px rgba(20, 20, 20, .08);
}
.work-card-page svg {
    display: block;
    width: 100%;
    height: auto;
}
.work-card-status {
    padding: 48px 0;
    color: #6F6F6B;
}

/* Overlapping measurements on the card: shown above the pages, never printed. */
.work-card-warning {
    max-width: 210mm;
    width: 100%;
    margin: 0 auto;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #E0301E;
    border-left-width: 4px;
    color: #B3261A;
    font-size: 14px;
    font-weight: 500;
}
@media print {
    .work-card-warning { display: none !important; }
}

/*
 * Printing the work card: one SVG page per A4 sheet, nothing else. Without
 * these rules the fixed overlay repeats on every page (Chrome) or is clipped
 * to one page by the editor's h-screen/overflow-hidden body.
 */
@page {
    size: A4;
    margin: 0;
}
@media print {
    html, body {
        height: auto !important;
        overflow: visible !important;
        background: #fff !important;
    }
    body > *:not(.preview-overlay) {
        display: none !important;
    }
    .preview-overlay {
        position: static !important;
        display: block !important;
        overflow: visible !important;
        background: none !important;
    }
    .work-card-toolbar {
        display: none !important;
    }
    .work-card-pages {
        display: block !important;
        padding: 0 !important;
    }
    .work-card-page {
        width: 210mm !important;
        max-width: none !important;
        height: 297mm !important;
        box-shadow: none !important;
        break-after: page;
        page-break-after: always;
        overflow: hidden;
    }
    .work-card-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }
    .work-card-page svg {
        width: 210mm !important;
        height: 297mm !important;
    }
}

/* The Ohennus switch (.toggle-checkbox / .toggle-label) is in tailwind.input.css (3.96.0). */
#summaryBox.collapsed #summaryContent {
    max-height: 0px;
}
#summaryBox:not(.collapsed) #summaryContent {
     max-height: 500px; /* A value larger than the content will ever be */
}
#summaryBox.collapsed #summaryToggleIcon {
    transform: rotate(-180deg);
}
/* Fine-tune bar: a value being typed with the keyboard. */
#fineTuneValue.ft-typing {
    border-color: #141414;
    box-shadow: inset 0 0 0 1px #141414;
    background: #F5F5F3;
}

/* "Piirrä alkupäästä": pressed while new lines go to the profile's start. */
.draw-at-start-btn.is-on {
    background: #141414;
    color: #ffffff;
}
.draw-at-start-btn.is-on:hover {
    background: #000000;
}

/* Enlarged profile drawing (dashboard #zoomModal): the "Sovita" chip when zoomed in and the
   touch hint (3.75.0, js/pinchZoom.js). */
.zoom-chip {
    height: 2.5rem;
    padding: 0 1rem;
    border: 1px solid var(--ink);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: 0.875rem;
    font-weight: 600;
}
.zoom-hint {
    display: none;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius);
    background: rgba(20, 20, 20, 0.6);
    color: var(--on-ink);
    font-size: 0.75rem;
}
/* Only touch screens get the hint (the mouse wheel needs none). */
@media (pointer: coarse) {
    .zoom-hint { display: inline; }
}

/* Search words in the order list (3.76.0, dashboardTable.highlightHtml): warning-soft
   like the design's TARKISTA tone; stronger on the selected (ink) row. */
mark.search-hit {
    background: var(--warning-soft);
    color: inherit;
    box-shadow: inset 0 -1px 0 var(--warning);
    padding: 0;
}
.order-row[aria-current="true"] mark.search-hit {
    background: var(--warning);
    color: var(--ink);
}

