/* =============================================================================
   css/base.css
   The font, a small reset, and the handful of layout helpers every screen uses.

   Nothing here styles a named thing. Buttons, cards and inputs live in
   components.css; where they sit on a screen lives in css/screens/.
   (docs/05-ux-spec.md section 8.)
   ============================================================================= */


/* -----------------------------------------------------------------------------
   THE FONT

   Inter, three weights, served from this repo rather than from Google, because
   the tablet has to open with no internet (CLAUDE.md rule 10, SYNC-06).

   Files came from Google Fonts on 18 September 2026, latin subset only.
   The extended latin subset was left out on purpose: it is 250 KB for glyphs a
   hardware shop in Ja-Ela will never type, and the app shell has to be
   interactive in under two seconds (docs/04-architecture.md, Speed).
   Inter is licensed under the SIL Open Font License 1.1.

   font-display: swap means text appears immediately in the system font and
   swaps to Inter when it has loaded, rather than the screen sitting blank.
   ----------------------------------------------------------------------------- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/inter-400-latin.woff2') format('woff2');
  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: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/inter-500-latin.woff2') format('woff2');
  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: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/inter-700-latin.woff2') format('woff2');
  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;
}


/* -----------------------------------------------------------------------------
   RESET
   Only what is actually needed. A long reset makes CSS harder to read, not
   safer, and this app has one target browser: Chrome on Android and desktop.
   ----------------------------------------------------------------------------- */

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

html {
  /* Never zoom the text when the tablet is rotated or a sheet opens. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body,
h1, h2, h3, h4, p, figure, blockquote, dl, dd {
  margin: 0;
}

/* A list with a class is being used as a layout, such as a menu or a row of
   cards, so it loses its bullets. A list without one is prose and keeps them. */
ul[class],
ol[class] {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* The exception: numbered instructions, where the numbers are half the
   meaning. Used on any list of steps a person has to follow in order.

   Written as ol.steps rather than .steps so it can out-rank the ol[class]
   rule above. A plain class selector loses to an element-plus-attribute one,
   so .steps on its own would be quietly ignored. */
ol.steps {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  list-style: decimal;
}

ol.steps > li {
  margin-bottom: var(--space-2);
  padding-left: var(--space-1);
}

img,
picture,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* The hidden attribute always wins. Without this, any component that sets
   display: flex (a chip row, a segmented control) would stay on screen after
   JavaScript hid it, and each one would need its own [hidden] rule. */
[hidden] {
  display: none !important;
}


/* -----------------------------------------------------------------------------
   THE PAGE
   ----------------------------------------------------------------------------- */

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--text-body);
  font-weight: var(--font-regular);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background: var(--color-bg);

  /* Counter rules, docs/05-ux-spec.md section 2:
     no accidental text selection while tapping fast, no 300ms tap delay, and
     no grey flash box on every touch. */
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* Text the user genuinely might want to copy, such as a bill number or a
   phone number, opts back in. */
input,
textarea,
[data-selectable] {
  -webkit-user-select: text;
  user-select: text;
}

h1 { font-size: var(--text-title);   font-weight: var(--font-bold); line-height: var(--leading-tight); }
h2 { font-size: var(--text-heading); font-weight: var(--font-bold); line-height: var(--leading-tight); }
h3 { font-size: var(--text-line);    font-weight: var(--font-medium); }

a {
  color: var(--color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}


/* -----------------------------------------------------------------------------
   FOCUS
   Visible keyboard focus everywhere, because Shehan works on a laptop, but not
   a ring around every button Dad taps. :focus-visible handles both: the ring
   appears for keyboard and not for touch.
   ----------------------------------------------------------------------------- */

:focus {
  outline: none;
}

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


/* -----------------------------------------------------------------------------
   NUMBERS
   Money and quantities line up in columns only if every digit is the same
   width. Inter has that built in; this switches it on (docs/05-ux-spec.md 10).
   Apply it to any element showing figures.
   ----------------------------------------------------------------------------- */

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

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


/* -----------------------------------------------------------------------------
   LAYOUT HELPERS
   The four from docs/05-ux-spec.md section 8, plus a couple that earn their
   place. They arrange things. They never decorate.

   The gap defaults to --space-4 and can be overridden per instance by setting
   --gap on the element, which is the one dynamic value screens may set.
   ----------------------------------------------------------------------------- */

/* Children in a column. */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap, var(--space-4));
}

/* Children in a row, vertically centred, wrapping when they run out of room. */
.row {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--gap, var(--space-3));
}

.row--tight  { --gap: var(--space-2); }
.row--nowrap { flex-wrap: nowrap; }
.row--between { justify-content: space-between; }
.row--end     { justify-content: flex-end; }
.row--top     { align-items: flex-start; }

/* Takes up whatever space is left. Put it on the middle item of a row to push
   the rest to the edges. */
.grow {
  flex: 1 1 auto;
  min-width: 0;   /* lets long item names shrink instead of forcing a scrollbar */
}

/* A gap that pushes everything after it to the far edge. */
.spacer {
  margin-left: auto;
}


/* -----------------------------------------------------------------------------
   SHOWING AND HIDING BY DEVICE
   docs/05-ux-spec.md section 1. Sell is tablet only; the back office works on
   both. These two classes are how a screen says which is which.
   ----------------------------------------------------------------------------- */

@media (max-width: 480px) {
  .hide-phone { display: none !important; }
}

@media (min-width: 481px) {
  .only-phone { display: none !important; }
}


/* -----------------------------------------------------------------------------
   TEXT UTILITIES
   ----------------------------------------------------------------------------- */

/* One line, with an ellipsis. For item names on a narrow tile. */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* At most two lines, then an ellipsis. Item tiles use this
   (docs/05-ux-spec.md section 4: name, 2 lines max). */
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.muted { color: var(--color-text-muted); }
.faint { color: var(--color-text-faint); }

/* Present for screen readers, invisible on screen. Used for the labels on
   icon-only buttons, so the app is still readable aloud. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}


/* -----------------------------------------------------------------------------
   MOTION
   Some people set "reduce motion" on their device. Honour it everywhere at
   once rather than remembering to in each component.
   ----------------------------------------------------------------------------- */

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