/* The same layer order Tailwind uses, declared first, so this file works whichever stylesheet loads first. */
@layer theme, base, components, utilities;

/*
 * Brand styles the CSS build step drops (it does not know these newer or browser-specific selectors),
 * so they are served as this plain file.
 *
 * Dropdowns in the brand look. Browsers that support customizable selects (Chrome and Edge, including
 * Chrome on Android) draw the list with the app's colours; others keep their own list, which still works.
 */
@supports (appearance: base-select) {
  select,
  select::picker(select) {
    appearance: base-select;
  }
  select {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
  }
  /* The same chevron as the rest of the app's icons (lucide chevron-down). */
  select::picker-icon {
    content: "";
    width: 1rem;
    height: 1rem;
    background-color: var(--muted-foreground);
    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='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: rotate 150ms ease;
  }
  select:open::picker-icon {
    rotate: 180deg;
  }
  select::picker(select) {
    margin-block: 0.25rem;
    padding: 0.25rem;
    min-width: anchor-size(width);
    max-height: min(20rem, 60svh);
    overflow-y: auto;
    border: var(--device-line, 1.5px) solid var(--border);
    border-radius: var(--radius);
    background: var(--popover);
    color: var(--popover-foreground);
    box-shadow: 0 12px 32px rgb(0 0 0 / 0.25);
  }
  select option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0 0.75rem;
    border-radius: calc(var(--radius) * 0.6);
    font-size: 0.95rem;
    cursor: pointer;
  }
  select option:hover,
  select option:focus-visible {
    background: var(--muted);
    outline: none;
  }
  select option:checked {
    background: var(--accent);
    font-weight: 500;
  }
  /* The chosen item shows the app's circle-check icon (the same one as on "saved" messages), in the text colour. */
  select option::checkmark {
    content: "";
    order: 1;
    margin-inline-start: auto;
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
    background-color: currentColor;
    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='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  select option:disabled {
    opacity: 0.5;
    cursor: default;
  }
}

/* Boxes the browser fills in for you (saved email and password) keep the app's colours instead of the browser's blue. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--foreground);
  caret-color: var(--foreground);
  box-shadow: 0 0 0 1000px var(--card) inset;
  transition: background-color 9999s ease-out 0s;
}

/* Android phones and tablets: touch targets of at least 48 dp, the Android standard (desktop keeps 44 px). */
@media (pointer: coarse) {
  [data-slot="button"],
  [data-slot="input"],
  [data-sidebar="menu-button"],
  select {
    min-height: 48px;
  }
  [data-slot="button"].size-11 {
    min-width: 48px;
  }
  /* Everything sized as a 44 px touch target in the app (h-11, min-h-11, size-11) grows to 48 on touch screens. */
  .h-11,
  .min-h-11,
  .size-11 {
    min-height: 48px;
  }
  .size-11 {
    min-width: 48px;
  }
}

/* Device brand 3.0: every heading in Inter Medium, whatever weight a screen asked for. Body text stays Inter Regular. */
h1,
h2,
h3 {
  font-family: var(--font-sans), sans-serif;
  font-weight: 500;
}

/*
 * Device brand 3.0: labels and interface text in IBM Plex Mono, spaced capital letters, like "SIMPLE SYSTEMS.
 * BUILT TO RUN." on the logo. Section labels, sidebar headings, number-tile labels, form section titles and the
 * headings of every table, in every portal.
 */
.device-label,
[data-sidebar="group-label"],
fieldset > legend,
thead th {
  font-family: var(--font-plex-mono), ui-monospace, monospace;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
thead th {
  color: var(--muted-foreground);
}

/*
 * Notifications slide in from the right and slide back out to the right (owner's choice), instead of dropping
 * down from the top. The library's own up-and-down movement is kept at zero for the newest notification;
 * the stacking of older ones under it is untouched.
 */
html [data-sonner-toast] {
  translate: calc(100% + 2rem) 0;
  transition: transform 400ms, opacity 400ms, height 400ms, box-shadow 200ms, translate 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
html [data-sonner-toast][data-y-position="top"]:not([data-mounted="true"]) {
  --y: translateY(0);
}
html [data-sonner-toast][data-mounted="true"] {
  translate: 0 0;
}
html [data-sonner-toast][data-removed="true"] {
  translate: calc(100% + 2rem) 0;
}
html [data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"] {
  --y: translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  html [data-sonner-toast] {
    translate: 0 0;
    transition: opacity 400ms, height 400ms, box-shadow 200ms;
  }
}

/* ==========================================================================================================
 * Motion (owner's requests, Nov 20, 2026). One set of speeds and curves for the whole system, built only from
 * plain CSS transitions and keyframes on transform, opacity and clip-path, so it looks the same on Android
 * (Chrome, Samsung, Huawei, Xiaomi browsers), iPhone and iPad (Safari and Chrome on iOS 16+) and laptops.
 * No View Transitions, no @starting-style, no scroll-driven animations.
 * House rule: nothing is ever hidden waiting for an animation. Everything is fully visible by default; a fade
 * only runs while the page is on screen (html[data-motion], set by components/motion-gate.tsx), so a paused or
 * background page always shows its content. People who ask their device for less motion get gentler motion: things
 * still fade, fill and answer a press, but nothing rises, slides or zooms (owner decision Nov 25, 2026).
 * ========================================================================================================== */
:root {
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-soft: cubic-bezier(0.65, 0, 0.35, 1);
  --motion-press: 120ms;
  --motion-hover: 180ms;
  --motion-sidebar: 300ms;
  --motion-page: 360ms;
  --motion-theme: 520ms;
  --motion-theme-fade: 240ms;
  --skeleton-sheen: rgb(255 255 255 / 0.65);
}
:root[data-theme="dark"] {
  --skeleton-sheen: rgb(255 255 255 / 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --skeleton-sheen: rgb(255 255 255 / 0.06);
  }
}

/* iPhone, iPad and Android: no grey flash on tap; the press feedback below is the app's own. */
html {
  -webkit-tap-highlight-color: transparent;
}

/* Defaults that a component's own classes still override (they join Tailwind's base layer). */
@layer base {
  button:not(:disabled),
  [role="button"]:not([aria-disabled="true"]),
  summary,
  select:not(:disabled),
  label[for],
  input[type="checkbox"]:not(:disabled),
  input[type="radio"]:not(:disabled) {
    cursor: pointer;
  }
  /* A visible ring for keyboard users on anything clickable that has no ring of its own. */
  :where(a, button, summary, [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
  }
}

/* --- Theme switch: a circle of the new look grows from the day / dark button, then the page settles into it. --- */
.device-theme-veil {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  -webkit-clip-path: circle(0px at var(--veil-x) var(--veil-y));
  clip-path: circle(0px at var(--veil-x) var(--veil-y));
  transition:
    -webkit-clip-path var(--motion-theme) var(--ease-in-out-soft),
    clip-path var(--motion-theme) var(--ease-in-out-soft),
    opacity var(--motion-theme-fade) var(--ease-out-soft);
}
.device-theme-veil[data-state="grow"],
.device-theme-veil[data-state="settle"] {
  -webkit-clip-path: circle(var(--veil-r) at var(--veil-x) var(--veil-y));
  clip-path: circle(var(--veil-r) at var(--veil-x) var(--veil-y));
}
.device-theme-veil[data-state="settle"] {
  opacity: 0;
}
/* While the look changes, nothing fades between the two looks on its own: boxes and buttons take the new colours at
 * once under the circle, so no old colour blinks through as the circle fades away (owner request Nov 25, 2026). */
html[data-theme-switching] *:not(.device-theme-veil),
html[data-theme-switching] *::before,
html[data-theme-switching] *::after {
  transition: none !important;
}

/* --- Moving between pages (Dashboard to Review, and every other page in every portal): the new page rises a few
 * pixels into place and fades in. Each new page is new content, so this runs once per page (keyed by the page). --- */
html[data-motion] .device-page > * {
  animation:
    device-page-rise var(--motion-page) var(--ease-out-soft) backwards,
    device-page-fade 260ms var(--ease-out-soft) backwards;
}
@keyframes device-page-rise {
  from {
    transform: translate3d(0, 6px, 0);
  }
}
@keyframes device-page-fade {
  from {
    opacity: 0;
  }
}

/* --- Sidebar: opening and closing (the narrow rail and the full sidebar) and the phone menu sliding in. --- */
[data-slot="sidebar-gap"],
[data-slot="sidebar-container"] {
  transition-duration: var(--motion-sidebar);
  transition-timing-function: var(--ease-in-out-soft);
  will-change: width;
}
[data-sidebar="menu-button"] {
  transition-duration: var(--motion-sidebar);
  transition-timing-function: var(--ease-in-out-soft);
}
/* The words beside the menu icons: on closing they fade out first; on opening they slide in once there is room. */
[data-sidebar="menu-button"] > span {
  transition:
    opacity 200ms var(--ease-out-soft) 110ms,
    transform 260ms var(--ease-out-soft) 90ms,
    max-width var(--motion-sidebar) var(--ease-in-out-soft);
}
[data-collapsible="icon"] [data-sidebar="menu-button"] > span {
  transform: translate3d(-6px, 0, 0);
  transition:
    opacity 120ms var(--ease-out-soft),
    transform 160ms var(--ease-out-soft),
    max-width var(--motion-sidebar) var(--ease-in-out-soft);
}
[data-sidebar="group-label"] {
  transition-duration: var(--motion-sidebar);
  transition-timing-function: var(--ease-in-out-soft);
}
/* The logo, business row and owner name that appear as the sidebar opens: in place at once, faded in on screen. */
html[data-motion] .device-fade-in {
  animation: device-fade-in 220ms var(--ease-out-soft) 90ms backwards;
}
@keyframes device-fade-in {
  from {
    opacity: 0;
  }
}
/* Phones: the menu slides in from the left edge as one panel, over a dimmed page. */
[data-slot="sidebar"][data-mobile="true"][data-side="left"] {
  transition: translate var(--motion-sidebar) var(--ease-out-soft), transform var(--motion-sidebar) var(--ease-out-soft);
}
[data-slot="sidebar"][data-mobile="true"][data-side="left"][data-starting-style],
[data-slot="sidebar"][data-mobile="true"][data-side="left"][data-ending-style] {
  translate: -100% 0;
  opacity: 1;
}
[data-slot="sheet-overlay"] {
  transition-duration: var(--motion-sidebar);
  transition-timing-function: var(--ease-out-soft);
}

/* --- Loading. --- */
/* The thin black line along the top while a page is on its way (components/nav-progress.tsx). */
.device-progress {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 2147482000;
  height: 2px;
  pointer-events: none;
  background: var(--foreground);
  transform-origin: 0 50%;
  transform: scaleX(0);
  opacity: 0;
}
.device-progress[data-state="start"] {
  opacity: 1;
  transform: scaleX(0.82);
  transition: transform 9s cubic-bezier(0.08, 0.82, 0.17, 1), opacity 120ms linear;
}
.device-progress[data-state="done"] {
  opacity: 0;
  transform: scaleX(1);
  transition: transform 200ms var(--ease-out-soft), opacity 260ms linear 180ms;
}
/* Skeletons: the shape of the page in border gray, with a soft lighter band passing over it. Without motion they are
 * plain gray shapes, already complete. */
[data-slot="skeleton"] {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
html[data-motion] [data-slot="skeleton"]::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translate3d(-100%, 0, 0);
  background: linear-gradient(90deg, transparent 0%, var(--skeleton-sheen) 50%, transparent 100%);
  animation: device-sheen 1.6s var(--ease-in-out-soft) infinite;
}
@keyframes device-sheen {
  to {
    transform: translate3d(100%, 0, 0);
  }
}
/* The split D while a whole screen waits: the mark in quiet gray, with black ink passing through it, left to right.
 * Without motion the ink simply fills the mark. */
html[data-motion] .device-mark-loader-ink {
  animation: device-mark-ink 1.8s var(--ease-in-out-soft) infinite;
}
@keyframes device-mark-ink {
  0% {
    -webkit-clip-path: inset(0 100% 0 0);
    clip-path: inset(0 100% 0 0);
  }
  50% {
    -webkit-clip-path: inset(0 0 0 0);
    clip-path: inset(0 0 0 0);
  }
  100% {
    -webkit-clip-path: inset(0 0 0 100%);
    clip-path: inset(0 0 0 100%);
  }
}

/* --- Clickable things say so: on a mouse, a soft lift or panel-gray fill; on every device, a small press. --- */
[data-slot="button"],
.device-pill,
.device-nav-card,
.device-nav-card .device-chevron {
  transition-property: color, background-color, border-color, opacity, scale, translate, box-shadow;
  transition-duration: var(--motion-hover);
  transition-timing-function: var(--ease-out-soft);
}
@media (hover: hover) and (pointer: fine) {
  /* Icon-only buttons (day / dark, bell, menu, close): a panel-gray circle fades in and the icon grows a touch. */
  [data-slot="button"]:has(> svg:only-child):not(:disabled):hover,
  [data-slot="button"]:has(> svg:first-child + .sr-only:last-child):not(:disabled):hover {
    background-color: var(--muted);
  }
  /* Cards that open another screen: their edge darkens (and, below, they lift and the arrow moves toward where it goes). */
  .device-nav-card:hover {
    border-color: var(--muted-foreground);
  }
  /* Bordered pills (go-to links, order numbers, chips) darken their edge and fill slightly. */
  .device-pill:hover {
    border-color: var(--foreground);
  }
}
/* The hover movements, left out when the device asks for less motion. */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  [data-slot="button"]:has(> svg:only-child):not(:disabled):hover,
  [data-slot="button"]:has(> svg:first-child + .sr-only:last-child):not(:disabled):hover {
    scale: 1.04;
  }
  .device-nav-card:hover {
    translate: 0 -2px;
  }
  .device-nav-card:hover .device-chevron {
    translate: 3px 0;
  }
}
[data-slot="button"]:not(:disabled):active,
.device-pill:active,
.device-nav-card:active {
  scale: 0.97;
  transition-duration: var(--motion-press);
}

/* --- Buttons, pills, chips and tabs: the words stay on one line beside their icon (one gap, centred), and the button
 * keeps its size in a row. (text-wrap would switch wrapping back on, so it is only used by .device-pill-wrap.) --- */
[data-slot="button"],
.device-pill {
  white-space: nowrap;
  text-align: center;
}
/* A label that truly has to break on a narrow phone: its lines stay centred and balanced, and the icon stays beside the
 * whole block, centred against it. */
.device-pill-wrap {
  white-space: normal;
  text-wrap: balance;
}

/* --- Dropdowns (select boxes): the chosen words stay on one line; long ones get a smaller size, then "…".
 * components/select-fit.tsx marks the long ones and puts the full words in the box's tooltip. --- */
select {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
select[data-fit="small"],
select[data-fit="clip"] {
  font-size: 0.8125rem;
}

/* --- Maps (Settings > Delivery, customer checkout): the map stays in its own layer, under top bars, sticky bars,
 * dialogs and sheets. Leaflet's own layers go up to z-index 1000; they now count only inside the map box. --- */
.leaflet-container {
  isolation: isolate;
  z-index: 0;
}

/* Less motion asked for on the device (owner decision Nov 25, 2026: gentler, not none, the way Apple's own apps do
 * it). Things still fade, fill and answer a press; nothing rises, slides or zooms. */
@media (prefers-reduced-motion: reduce) {
  /* A new page fades in without rising. */
  html[data-motion] .device-page > * {
    animation: device-page-fade 260ms var(--ease-out-soft) backwards;
  }
  /* Loading shapes glow softly instead of a shine sliding across. */
  html[data-motion] [data-slot="skeleton"]::after {
    transform: none;
    background: var(--skeleton-sheen);
    opacity: 0;
    animation: device-sheen-glow 1.6s var(--ease-in-out-soft) infinite;
  }
  /* The sidebar's words fade without sliding. */
  [data-sidebar="menu-button"] > span {
    transform: none !important;
  }
  /* Pop-ups and menus fade without zooming or sliding. */
  *,
  ::before,
  ::after {
    --tw-enter-scale: 1;
    --tw-enter-translate-x: 0;
    --tw-enter-translate-y: 0;
    --tw-exit-scale: 1;
    --tw-exit-translate-x: 0;
    --tw-exit-translate-y: 0;
  }
  /* Side panels and the phone menu fade in place; centered pop-ups fade without zooming. */
  :is([data-slot="sheet-content"], [data-slot="sidebar"][data-mobile="true"]):not([data-side="center"]):is([data-starting-style], [data-ending-style]) {
    translate: none;
  }
  [data-side="center"]:is([data-starting-style], [data-ending-style]) {
    scale: none;
  }
  [data-slot="sidebar"][data-mobile="true"] {
    transition: opacity var(--motion-sidebar) var(--ease-out-soft);
  }
  /* The day / dark switch: the new look fades in over the whole screen instead of growing as a circle. */
  .device-theme-veil,
  .device-theme-veil[data-state] {
    -webkit-clip-path: none;
    clip-path: none;
    transition: opacity var(--motion-theme-fade) var(--ease-out-soft);
  }
  .device-theme-veil {
    opacity: 0;
  }
  .device-theme-veil[data-state="grow"] {
    opacity: 1;
  }
}
@keyframes device-sheen-glow {
  50% {
    opacity: 1;
  }
}

/* --- Lines (owner decision Nov 23, 2026): every border and divider is 1.5px. Thicker accents like border-2 stay.
 * In the same layer as the utilities and no more specific than them, so "no border" variants such as last:border-0 still win. --- */
:root {
  --device-line: 1.5px;
}
@layer utilities {
  .border:where(:not([class~="border-0"], [class~="border-2"], [class~="border-4"], [class~="border-t-0"], [class~="border-t-2"], [class~="border-b-2"], [class~="border-l-2"], [class~="border-l-4"])) {
    border-width: var(--device-line);
  }
  .border-t:where(:not([class~="border-t-0"], [class~="border-t-2"])) {
    border-top-width: var(--device-line);
  }
  .border-b:where(:not([class~="border-b-0"], [class~="border-b-2"])) {
    border-bottom-width: var(--device-line);
  }
  .border-l:where(:not([class~="border-l-0"], [class~="border-l-2"], [class~="border-l-4"])) {
    border-left-width: var(--device-line);
  }
  .border-r:where(:not([class~="border-r-0"])) {
    border-right-width: var(--device-line);
  }
  [data-slot="table-header"] tr {
    border-bottom-width: var(--device-line);
  }
  :where(.divide-y > :not(:last-child)) {
    border-block-end-width: var(--device-line);
  }
  .ring-1:where(:not(:focus-visible)) {
    --tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(var(--device-line) + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
  }
  [data-slot="sheet-content"][data-side="left"] {
    border-right-width: var(--device-line);
  }
  [data-slot="sheet-content"][data-side="right"] {
    border-left-width: var(--device-line);
  }
  [data-slot="sheet-content"][data-side="bottom"] {
    border-top-width: var(--device-line);
  }
  [data-slot="sheet-content"][data-side="top"] {
    border-bottom-width: var(--device-line);
  }
  [data-side="left"] > [data-slot="sidebar-container"] {
    border-right-width: var(--device-line);
  }
  [data-side="right"] > [data-slot="sidebar-container"] {
    border-left-width: var(--device-line);
  }
}

/* --- Pressed (owner request Nov 24, 2026): every button, link, tab, chip and card reacts to a finger or a mouse, on
 * phones, tablets and laptops (components/press-feedback.tsx marks it for at least a moment, so a quick tap is seen).
 * Icons shrink the most, buttons and phone-wide rows clearly, wide laptop rows and cards only dip (lib/press.ts).
 * A press always wins over a hover grow, and it stays when the device asks for less motion (owner decision Nov 25). --- */
[data-pressed] {
  transition-property: scale, opacity, translate, background-color, border-color, color, box-shadow;
  transition-duration: 90ms;
  transition-timing-function: var(--ease-out-soft);
}
[data-pressed="small"] {
  scale: 0.9 !important;
  opacity: 0.8;
}
[data-pressed="medium"] {
  scale: 0.96 !important;
  opacity: 0.85;
}
[data-pressed="wide"] {
  scale: 0.99 !important;
  opacity: 0.88;
}
