/* Shared UI: the arrival capsule, the expense sheet, the category form. */

/* ================================================================ Arrival capsule (js/ui/island.js) */
.island { position: fixed; left: 50%; top: 11px; z-index: var(--z-island); width: 0; height: 50px; }
.island__shape { position: absolute; left: 0; top: 0; height: 50px; transform-origin: 50% 0; }
.island__cap, .island__mid { position: absolute; top: 0; height: 50px; background: var(--island); }
.island__cap { width: 50px; border-radius: 50%; }
.island__cap:first-child { left: 0; }
.island__cap:last-child { right: 0; }
.island__mid { left: 25px; transform-origin: 50% 50%; }
.island__content {
  position: absolute; left: 0; top: 0; height: 50px; transform-origin: 50% 0;
  display: flex; align-items: center; gap: 10px; padding: 0 18px 0 8px; white-space: nowrap;
  color: var(--on-island); opacity: 0; cursor: pointer;
}
.island__tile { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: rgba(255, 255, 255, .13); flex: none; }
.island__tile .ico { width: 19px; height: 19px; }
.island__text { min-width: 0; flex: 1; }
.island__text b { display: block; font-size: 15px; font-weight: 650; line-height: 18px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; }
.island__text span { display: block; font-size: 12px; line-height: 16px; color: var(--on-island-2); }
.island__amount { padding-left: 12px; color: var(--on-island); font-size: 17px; font-weight: 760; font-stretch: 108%; letter-spacing: -.01em; }

/* Dark: the capsule would vanish into the page; a 0.5 px light edge keeps its shape. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .island__shape { filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .5)); } }
:root[data-theme="dark"] .island__shape { filter: drop-shadow(0 0 .5px rgba(255, 255, 255, .5)); }

/* The compact bar stays readable above an open sheet: Thomas sees the figure move as he sorts. */
.is-sheet-compact .compact { z-index: calc(var(--z-scrim) + 1); }
.is-sheet-compact .compact__bg { background: var(--chalk); }
.is-sheet-compact .compact__bg, .is-sheet-compact .compact__title, .is-sheet-compact .compact__fig { opacity: 1 !important; transform: none !important; }

/* ================================================================ Expense sheet (js/ui/expense-sheet.js)
   The sheet title carries the time; the merchant and « 48,00 AED dans Manger » share one block
   with the category disc, so the whole grid (ending on the « Nouvelle catégorie » tile) fits
   the medium detent. */
.xs-ident { display: grid; grid-template-columns: 52px minmax(0, 1fr); align-items: center; column-gap: 14px; margin-top: 2px; }
.xs-ident__text { min-width: 0; container-type: inline-size; }
.xs-ident__merchant { font-size: 17px; font-weight: 680; letter-spacing: -.005em; line-height: 1.2; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xs-amount { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; row-gap: 0; margin-top: 2px; white-space: nowrap; }
/* « dans Perso » is the key information: when the figure is long (or the text zoomed), it goes to
   the next line whole instead of being ellipsed away; the figure shrinks to the column */
.xs-amount__fig { font-size: min(32px, calc(100cqi / 7)); font-weight: 800; font-stretch: 112%; letter-spacing: -.03em; line-height: 1.02; }
.xs-amount__unit { font-size: 14px; font-weight: 560; font-stretch: 104%; letter-spacing: .02em; color: var(--ink-2); }
.xs-amount__where { font-size: var(--t-sub); font-weight: 600; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.xs-flags:not(:empty) { display: grid; gap: 8px; margin-top: 14px; }
.xs-flag { background: var(--chalk); }
.xs-rule { margin-top: 14px; background: var(--chalk); }
.xs-rule .switch-row__text small { transition: opacity var(--d-snappy) var(--e-snappy); }
.xs-groups { position: relative; margin-top: 14px; }
.xs-group + .xs-group { margin-top: 10px; }
.xs-group__h { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 0 0 6px; border-bottom: 1px solid var(--hair-2); font-size: 15px; font-weight: 680; }
.xs-group__aside { font-size: 14px; font-weight: 480; color: var(--ink-2); }
.xs-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 2px; margin-top: 6px; margin-inline: -4px; }
.xs-cat {
  position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-height: 70px; padding: 4px 0 2px; border-radius: var(--r-s);
  transition: transform var(--d-snappy) var(--e-snappy);
}
.xs-cat:active { transform: scale(.93); transition-duration: var(--d-press); transition-timing-function: var(--e-press); }
.xs-cat__dot { width: 44px; height: 44px; transition: background-color var(--d-smooth) var(--e-smooth), color var(--d-smooth) var(--e-smooth); }
.xs-cat__dot .ico { width: 21px; height: 21px; }
.xs-cat__label {
  font-size: 12px; font-weight: 560; line-height: 1.15; text-align: center; max-width: 100%; padding: 0 1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  /* the condensed width lets every real word fit (« Abonnements »), so a name breaks at its
     spaces; only a single word wider than the tile is cut, and the clamp ends it with « … »
     (never a letter sliced at the tile's edge) */
  hyphens: manual; overflow-wrap: anywhere; word-break: normal; font-stretch: 86%; letter-spacing: -.01em; text-wrap: balance;
}
/* selected: the disc fills with its accent; an ink ring (the lens) travels to it */
.xs-cat[aria-checked="true"] .xs-cat__dot { background: var(--acc); color: var(--on-acc); }
/* a long name (17 to 24 characters, the server's limit) steps down a little, so it fits whole on
   two lines of the 5-column tile instead of ending on « … » */
.xs-cat__label[data-long] { font-size: 11px; font-stretch: 78%; letter-spacing: -.005em; }
.xs-cat[aria-checked="true"] .xs-cat__label { font-weight: 700; }
.xs-lens { position: absolute; left: 0; top: 0; z-index: 0; width: 52px; height: 52px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--ink); pointer-events: none; opacity: 0; transition: opacity var(--d-snappy) var(--e-snappy); }
/* « Nouvelle catégorie »: the last tile of the grid, a dashed + disc */
.xs-cat--new .xs-cat__dot { background: transparent; color: var(--ink); border: 1.5px dashed var(--ink-2); }
.xs-cat--new .xs-cat__label { color: var(--ink); font-weight: 620; }
.xs-foot { font-size: 14px; color: var(--ink-2); margin: 10px 0 0; }
.xs-actions { margin-top: 22px; background: var(--chalk); }
.xs-action { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 0 16px; font-size: var(--t-body); font-weight: 600; color: var(--ink); }
.xs-action .ico { width: 20px; height: 20px; color: var(--ink-2); }
.xs-action:active { background: var(--sunk); }

/* ================================================================ Category form (js/ui/category-form.js) */
.cf-preview { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 0 18px; }
.cf-preview__disc { transition: background-color var(--d-smooth) var(--e-smooth); }
/* a 24-character name is shown whole: two balanced lines rather than an ellipsis */
.cf-preview__name { margin-top: 12px; font-size: 26px; font-weight: 760; font-stretch: 104%; letter-spacing: -.02em; line-height: 1.15; text-align: center; max-width: 100%; overflow-wrap: anywhere; text-wrap: balance; }
.cf-preview__name[data-placeholder] { color: var(--ink-2); font-weight: 600; }
.cf-preview__bucket { font-size: 14px; color: var(--ink-2); }
.cf-label { margin-top: 22px; }
.cf-colors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.cf-color {
  position: relative; justify-self: center; width: 40px; height: 40px; border-radius: 50%;
  background: radial-gradient(circle closest-side, var(--c) 0 calc(100% - 5px), transparent calc(100% - 4.5px));
  transition: transform var(--d-snappy) var(--e-snappy);
}
.cf-color::before { content: ""; position: absolute; inset: -2px; }
.cf-color::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--ink); opacity: 0; transform: scale(.8); transition: opacity var(--d-smooth) var(--e-smooth), transform var(--d-snappy) var(--e-snappy); }
.cf-color[aria-checked="true"]::after { opacity: 1; transform: none; }
.cf-color:active { transform: scale(.88); transition-duration: var(--d-press); }
.cf-icons { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.cf-icon {
  display: grid; place-items: center; aspect-ratio: 1; min-height: 44px; border-radius: var(--r-s); color: var(--ink);
  transition: transform var(--d-snappy) var(--e-snappy), background-color var(--d-smooth) var(--e-smooth), box-shadow var(--d-smooth) var(--e-smooth);
}
.cf-icon .ico { width: 24px; height: 24px; }
.cf-icon[aria-checked="true"] { background: color-mix(in srgb, var(--acc) 16%, var(--surface)); color: color-mix(in srgb, var(--acc) 85%, var(--ink)); box-shadow: inset 0 0 0 2px var(--ink); }
.cf-icon:active { transform: scale(.88); transition-duration: var(--d-press); }
.cf-archive { margin: 26px -12px 0; color: var(--ink-2); }

/* ---------------------------------------------------------------- « Et si je dépense… » (js/ui/simulator.js), on Aujourd'hui and Mois */
.sim__card { margin-top: var(--s3); padding: 20px 18px 18px; }
/* last day of the month (sim.month_end): only the server's sentence, no slider, no formula */
.sim__card[data-end] > :not(.sim__note) { display: none; }
.sim__note { font-size: var(--t-body); font-weight: 520; line-height: 1.4; }
.sim__amount { display: flex; align-items: baseline; gap: 8px; }
.sim__odo { font-size: var(--t-figure); font-weight: 800; font-stretch: 114%; letter-spacing: -.035em; line-height: 1; }
.sim__unit { font-size: 16px; font-weight: 660; font-stretch: 112%; color: var(--ink-2); }
.sim__slider { position: relative; height: 48px; margin-top: 12px; touch-action: pan-y; }
.sim__input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; -webkit-appearance: none; appearance: none; }
.sim__input::-webkit-slider-thumb { -webkit-appearance: none; width: 44px; height: 48px; }
.sim__track { position: absolute; left: 0; right: 0; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; background: var(--sunk); overflow: hidden; pointer-events: none; }
.sim__fill { position: absolute; inset: 0; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); }
.sim__thumb {
  position: absolute; top: 50%; left: 0; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 0 0 1.5px var(--ink), 0 2px 6px rgba(20, 32, 26, .16);
  pointer-events: none; transition: scale var(--d-snappy) var(--e-snappy);
}
.sim__slider[data-active] .sim__thumb { scale: 1.16; }
.sim__slider:has(input:focus-visible) .sim__thumb { box-shadow: 0 0 0 2px var(--ink), 0 0 0 6px var(--hair-2); }
.sim__scale { position: relative; height: 14px; font-size: var(--t-micro); color: var(--ink-2); margin-top: -4px; }
.sim__scale span { position: absolute; top: 0; translate: -50% 0; }
.sim__bar { position: relative; height: 12px; margin-top: 22px; border-radius: 6px; background: var(--sunk); overflow: hidden; }
.sim__bar-fill { position: absolute; inset: 0; border-radius: 6px; background: var(--pace-mark); box-shadow: inset 0 0 0 .75px var(--mark-edge); transform-origin: 0 50%; transition: background-color var(--d-smooth) var(--e-smooth); }
.sim__bar-ghost { position: absolute; inset: 0; border-radius: 6px; box-shadow: inset -2px 0 0 var(--ink); background: color-mix(in srgb, var(--pace) 22%, transparent); opacity: 0; transition: opacity var(--d-smooth) var(--e-smooth); }
.sim__bar-ghost[data-on] { opacity: 1; }
.sim__caps { display: flex; justify-content: space-between; font-size: var(--t-micro); color: var(--ink-2); margin-top: 6px; }
.sim__result { margin-top: var(--s3); padding-top: 14px; border-top: 1px solid var(--hair-2); font-size: var(--t-sub); color: var(--ink-2); }
.sim__result strong { display: flex; align-items: baseline; color: var(--ink); font-size: 30px; font-weight: 790; font-stretch: 110%; letter-spacing: -.025em; line-height: 1.1; }
.sim__pd { font-size: 17px; font-weight: 640; letter-spacing: 0; margin-left: 6px; font-stretch: 100%; }
.sim__reset { margin: 8px -12px 0; }

.view[data-stale] .sim__odo,
.view[data-stale] .sim__result strong { color: var(--ink-2); }
/* stale or offline: the simulator's level bar greys with every other carrier */
.view[data-stale] .sim__bar-fill { background: var(--dry); box-shadow: inset 0 0 0 .75px var(--hair-2); }

