/* ============================================================================
   HotelTRS base layer - fonts, element defaults, focus, scrollbars
   ----------------------------------------------------------------------------
   Loads after tokens.css and after the Blazorise stylesheets.

     - variables                -> css/tokens.css
     - app-specific overrides   -> app.css

   Nothing here may contain a literal colour. Every value comes from a token.
   ============================================================================ */

/* ----------------------------------------------------------------------------
   1. FONTS - self-hosted, no third-party request

   latin-ext is REQUIRED, not optional: the app is HR/EN localized and
   c-caron, c-acute, z-caron, s-caron and d-stroke all live in that range.
   Drop it and Croatian silently falls back to a system font.
   ---------------------------------------------------------------------------- */

/* DM Sans - variable, 400 to 700 in one file */
@font-face {
    font-family: 'DM Sans';
    src: url('/content/fonts/DMSans-Variable-latin.woff2') format('woff2');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'DM Sans';
    src: url('/content/fonts/DMSans-Variable-latin-ext.woff2') format('woff2');
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* DM Mono - static 400 and 500 */
@font-face {
    font-family: 'DM Mono';
    src: url('/content/fonts/DMMono-400-latin.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'DM Mono';
    src: url('/content/fonts/DMMono-400-latin-ext.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'DM Mono';
    src: url('/content/fonts/DMMono-500-latin.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'DM Mono';
    src: url('/content/fonts/DMMono-500-latin-ext.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Inter - retained. Three AccountManagement pages hardcode font-family:'Inter'
   inside their own <style> blocks and are frozen until Phase 4. */
@font-face {
    font-family: 'Inter';
    src: url('/content/fonts/Inter.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* ----------------------------------------------------------------------------
   2. ELEMENT DEFAULTS

   html stays at 16px on purpose. Changing the root rescales every Bootstrap
   rem-based padding and margin, which is a layout change - Phase 4 owns that.
   The 14px base is applied to body only.
   ---------------------------------------------------------------------------- */

html {
    font-size: 16px;
}

body {
    font-family: var(--trs-font-sans);
    font-size: var(--trs-text-base);
    font-weight: var(--trs-weight-regular);
    color: var(--trs-text);
    background: var(--trs-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* The .hN class utilities are listed alongside the elements on purpose.
   Bootstrap ships both (h1,.h1{font-size:2.5rem} ... h6,.h6{1rem}); tokenising
   only the elements left the utilities at Bootstrap's scale, so Blazorise's
   TextSize="TextSize.HeadingN" - which emits .hN - rendered off the ramp.
   That matters as soon as a heading's LEVEL and its SIZE have to differ, which
   is what giving a page a real h1 without resizing its toolbar requires. */
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    font-family: var(--trs-font-sans);
    color: var(--trs-text);
    letter-spacing: -.02em;
}

h1, .h1 { font-size: var(--trs-text-3xl); font-weight: var(--trs-weight-bold); }
h2, .h2 { font-size: var(--trs-text-2xl); font-weight: var(--trs-weight-bold); }
h3, .h3 { font-size: var(--trs-text-xl);  font-weight: var(--trs-weight-bold); }
h4, .h4 { font-size: var(--trs-text-lg);  font-weight: var(--trs-weight-medium); }
h5, .h5 { font-size: var(--trs-text-md);  font-weight: var(--trs-weight-medium); }
h6, .h6 { font-size: var(--trs-text-base); font-weight: var(--trs-weight-medium); }

code, kbd, samp, pre {
    font-family: var(--trs-font-mono);
}

::selection {
    background: var(--trs-p-100);
    color: var(--trs-text);
}

/* ----------------------------------------------------------------------------
   3. FOCUS

   Restores the focus ring that app.css removed application-wide.

   Uses outline rather than box-shadow deliberately. Blazorise emits
   .form-control:focus rules from a <style> element inside <body>, which
   comes after this file in document order and wins any specificity tie, so a
   box-shadow ring would be overridden. Neither Bootstrap nor Blazorise ever
   sets outline to a colour, and the leading `html` lifts this to (0,2,1),
   beating Bootstrap's .btn:focus-visible{outline:0} at (0,2,0). No
   !important needed.

   Do not add border-radius here - outline already follows the element's own
   radius, and setting it would change the element's shape on focus.
   ---------------------------------------------------------------------------- */

html :is(
    a,
    button,
    input,
    select,
    textarea,
    summary,
    [tabindex]:not([tabindex="-1"]),
    .form-control,
    .form-select,
    .form-check-input,
    .btn,
    .b-bar-link,
    .b-bar-item,
    .dropdown-item
):focus-visible {
    outline: 2px solid var(--trs-focus);
    outline-offset: 2px;
}

/* FocusOnNavigate in Routes.razor focuses the h1 on every navigation.
   Unconditional on purpose. The obvious :not(:focus-visible) form does NOT
   work: Chromium reports :focus-visible = true for a programmatic .focus() on
   a tabindex="-1" element, so the guarded rule never matches and the browser's
   default outline draws a box around the page title on every navigation.
   Verified in-browser, not assumed.

   Nothing is lost by suppressing it - a heading is not interactive, and this
   focus exists only to move the screen-reader cursor to the top of the new
   page. Interactive elements keep their ring from the rule above. */
h1:focus {
    outline: none;
}

/* ----------------------------------------------------------------------------
   4. SCROLLBARS
   Moved from app.css and pointed at tokens.

   The element selectors here used to be a workaround: MainLayout.razor carried
   an inline <style> setting *::-webkit-scrollbar-thumb from inside <body>,
   which beat any universal rule in this file, so these were written narrow
   enough to win on html/body/.content/.modal-body and the rest of the app was
   left to MainLayout. That block is gone, and the webkit rules below are
   universal again - which is what actually shipped, since MainLayout is
   rendered on every authenticated page.

   The standard properties stay on the four scroll containers. scrollbar-color
   inherits, so setting it on every element is redundant and costs a style
   recalculation on every node.
   ---------------------------------------------------------------------------- */

:root {
    --scroll-size: 14px;
    --scroll-radius: var(--trs-radius-full);
    --scroll-track: var(--trs-surface-sunken);
    --scroll-thumb: var(--trs-border-strong);
    --scroll-thumb-hover: var(--trs-fill);
    --scroll-shadow: none;
}

html,
body,
.content,
.modal-body {
    scrollbar-width: auto;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
    width: var(--scroll-size);
    height: var(--scroll-size);
}

*::-webkit-scrollbar-track {
    background: var(--scroll-track);
}

*::-webkit-scrollbar-thumb {
    background-color: var(--scroll-thumb);
    border-radius: var(--scroll-radius);
    box-shadow: var(--scroll-shadow);
    border: 3px solid transparent;
    background-clip: padding-box;
    transition: background-color var(--trs-motion-fast) var(--trs-ease);
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--scroll-thumb-hover);
}

textarea::-webkit-scrollbar,
pre::-webkit-scrollbar,
code::-webkit-scrollbar {
    width: 12px;
}

/* ----------------------------------------------------------------------------
   5. MOTION PREFERENCES
   Staff running the rack all day are exactly the people who turn this on.
   ---------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
