/*
 * THE TIME GRID — a day column per day over an hour rail, with the all-day
 * banners in a band of their own above it.
 *
 * The hour height and the gutter's width are the LAYOUT's numbers (the module
 * places every block against them), so they arrive as data rather than being
 * declared twice: `--lotics-time-grid-view-hour` and `-gutter`.
 */
@layer theme, base, lotics, components, utilities;
@layer lotics.tokens, lotics.reset, lotics.components;

@layer lotics.components {
  .lotics-time-grid-view {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    min-height: 0;
    background-color: var(--card);
  }

  .lotics-time-grid-view__header {
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    padding-top: var(--lotics-space-2);
    padding-bottom: var(--lotics-space-8);
  }

  .lotics-time-grid-view__gutter {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: var(--lotics-time-grid-view-gutter);
  }

  .lotics-time-grid-view__day-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: var(--lotics-space-2);
  }

  .lotics-time-grid-view__badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding-inline: var(--lotics-space-4);
    border-radius: var(--lotics-radius-full);
  }

  .lotics-time-grid-view__badge[data-today] {
    background-color: var(--lotics-accent);
  }

  .lotics-time-grid-view__all-day {
    display: flex;
    flex-direction: row;
    flex-shrink: 0;
    padding-block: var(--lotics-space-4);
    border-top: 1px solid var(--border);
  }

  .lotics-time-grid-view__all-day-gutter {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
    width: var(--lotics-time-grid-view-gutter);
    padding-right: var(--lotics-space-6);
    text-align: right;
  }

  .lotics-time-grid-view__all-day-lanes {
    position: relative;
    flex: 1;
    min-width: 0;
  }

  .lotics-time-grid-view__scroller {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
  }

  .lotics-time-grid-view__canvas {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    flex-shrink: 0;
    height: var(--lotics-time-grid-view-height);
  }

  .lotics-time-grid-view__hours {
    position: relative;
    flex-shrink: 0;
    width: var(--lotics-time-grid-view-gutter);
  }

  /* Centred ON the rule it names, by half its OWN line box rather than by a
     number that has to be re-derived every time the type moves. */
  .lotics-time-grid-view__hour {
    position: absolute;
    right: var(--lotics-space-6);
    transform: translateY(-50%);
    font-family: var(--font-sans);
    font-size: var(--lotics-time-grid-view-hour-text);
    line-height: var(--lotics-leading-xs);
    color: var(--lotics-ink-inactive);
  }

  .lotics-time-grid-view__column {
    position: relative;
    flex: 1;
    min-width: 0;
    border-left: 1px solid var(--border);
  }

  .lotics-time-grid-view__rule {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--border);
  }

  /* One press target per hour: fine-grained enough to mean something, coarse
     enough not to put three hundred tab stops in a week. */
  .lotics-time-grid-view__slot {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--lotics-time-grid-view-hour);
    margin: 0;
    padding: 0;
    border: 0 solid transparent;
    background-color: transparent;
    appearance: none;
    cursor: default;
  }

  .lotics-time-grid-view__slot:focus-visible {
    outline: var(--lotics-ring-width) solid var(--ring);
    outline-offset: 0;
  }

  .lotics-time-grid-view__now {
    position: absolute;
    left: 0;
    right: 0;
    height: var(--lotics-time-grid-view-line);
    background-color: var(--lotics-tone-red-solid);
  }

  .lotics-time-grid-view__now-dot {
    position: absolute;
    /* Centred ON the line's left end: half its own width out, and half the
       difference between the two heights up. */
    left: calc(var(--lotics-time-grid-view-dot) / -2);
    top: calc(
      (var(--lotics-time-grid-view-line) - var(--lotics-time-grid-view-dot)) / 2
    );
    width: var(--lotics-time-grid-view-dot);
    height: var(--lotics-time-grid-view-dot);
    border-radius: var(--lotics-radius-full);
    background-color: var(--lotics-tone-red-solid);
  }
}
