/* PETRA theme. Bootstrap variables only — no build step, no preprocessor. */

:root {
  --petra-brand: #1b4965;
  --bs-link-color: var(--petra-brand);
  --bs-link-hover-color: #143a50;
}

body {
  background-color: #f7f8fa;
}

.navbar-brand {
  color: var(--petra-brand);
  letter-spacing: .04em;
}

.btn-primary {
  --bs-btn-bg: var(--petra-brand);
  --bs-btn-border-color: var(--petra-brand);
  --bs-btn-hover-bg: #143a50;
  --bs-btn-hover-border-color: #143a50;
  --bs-btn-active-bg: #102d3f;
  --bs-btn-active-border-color: #102d3f;
}

.card {
  border-color: #e3e6ea;
}

/* Placeholder panels for modules that land in a later phase. */
.border-dashed {
  border-style: dashed !important;
}

.petra-public {
  background-color: #eef1f5;
}

/* htmx: dim a fragment while its request is in flight.

   htmx puts .htmx-request on whatever triggered the request, so this needs
   no markup — a button fades while it waits. */
.htmx-request {
  opacity: .6;
  transition: opacity .15s ease-in;
}

/* htmx: an indicator is hidden until there is something to indicate.

   The other half of the same convention, and it was missing: htmx ships no
   CSS of its own, so an element marked .htmx-indicator stayed visible for
   ever and "Spyr AI…" sat under the Lýsing field before anybody had asked
   anything. htmx adds .htmx-request to the element named by hx-indicator
   for the life of the request, which is what reveals it. */
.htmx-indicator {
  display: none;
}

.htmx-request.htmx-indicator,
.htmx-request .htmx-indicator {
  display: inline-flex;
  align-items: center;
  /* Full strength: this one is the thing being read, not a fragment being
     waited on, so the dimming above does not apply to it. */
  opacity: 1;
}

/* Time entry form: fixed four-column grid of header row / value row. */
.petra-entry > tbody > tr > td,
.petra-entry > tbody > tr > th {
  padding: .35rem .5rem;
  vertical-align: top;
}

.petra-entry-head > th {
  background-color: #eef1f5;
  border-radius: .25rem;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #4a5b6a;
  white-space: nowrap;
}

.petra-entry .form-text {
  margin-top: .15rem;
  font-size: .75rem;
}

/* Field-level help: a quiet icon that opens a popover. */
.petra-info {
  background: none;
  border: 0;
  padding: 0 0 0 .15rem;
  line-height: 1;
  color: #8a9aa8;
  vertical-align: text-bottom;
  cursor: pointer;
}

.petra-info:hover,
.petra-info:focus {
  color: var(--petra-brand);
}

.petra-info:focus-visible {
  outline: 2px solid var(--petra-brand);
  outline-offset: 2px;
  border-radius: 50%;
}

.popover-body ul {
  margin-bottom: .25rem;
}

/* Entry lists: one line per description, so every row is the same height.
   The table already scrolls sideways, so nothing is lost off the edge. */
.petra-truncate {
  white-space: nowrap;
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Icon-only row actions: square, and the glyph centred on the button. */
.petra-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  padding-inline: 0;
}

/* Fields a copied entry wants looked at before saving. */
.petra-highlight {
  border-color: #dc3545;
  box-shadow: 0 0 0 .2rem rgba(220, 53, 69, .15);
}

/* Placeholders are a hint about the format, not something to read past what
   is being typed: "1h30m" sitting behind the cursor in Tímaskráning looks
   like a value that is already there. Clear it the moment the field is
   focused rather than waiting for the first keystroke, and fade it so the
   change is not a flicker. */
.form-control::placeholder {
  transition: color .12s ease-out;
}

.form-control:focus::placeholder {
  color: transparent;
}

/* A select turned into a type-ahead by initSearchableSelect(). The list is
   a plain Bootstrap dropdown shown by hand rather than by Bootstrap's own
   dropdown JS, which expects a toggle button rather than a text field. */
.petra-combo-list {
  /* Bootstrap only gives .dropdown-menu a top/left when Popper has placed
     it, and nothing places this one, so it is pinned under the field here. */
  top: 100%;
  left: 0;
  max-height: 16rem;
  overflow-y: auto;
}

/* The row the arrow keys are on. Its own class rather than Bootstrap's
   .active, which marks the row that is already chosen. */
.petra-combo-list .dropdown-item.petra-combo-active {
  background-color: var(--bs-tertiary-bg);
}

/* The calendar under a typed date field. It is attached to <body> and
   positioned by hand, because several of these fields sit inside a
   .table-responsive whose overflow would clip a panel anchored beside
   them, and one lives in the entry dialog. */
.petra-calendar {
  position: fixed;
  z-index: 1080;          /* above a Bootstrap modal's 1055 */
  /* An explicit width, not min-width: the grid inside is width:100%, and a
     percentage inside a shrink-to-fit box resolves against the viewport —
     which stretched the panel across the screen. */
  width: 16rem;
  max-width: calc(100vw - 1rem);
}

.petra-calendar-grid {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.petra-calendar-grid th {
  font-weight: 400;
  font-size: .75rem;
  text-align: center;
  padding-bottom: .25rem;
}

.petra-calendar-grid td {
  padding: 1px;
  text-align: center;
  width: 14.2857%;        /* 1/7, so the columns stay even */
}

.petra-calendar-day {
  font-variant-numeric: tabular-nums;
}

.petra-calendar-day:hover {
  background-color: var(--bs-tertiary-bg);
}

/* Today is outlined rather than filled, so it cannot be mistaken for the
   day that is actually selected. */
.petra-calendar-day.petra-calendar-today {
  box-shadow: inset 0 0 0 1px var(--bs-primary);
}

.petra-date {
  position: relative;
}

.petra-date-button {
  display: inline-flex;
  align-items: center;
}

/* The from–to picker on the clock field: a 24-hour dial where the wedge
   between the two points is the time being registered. Same fixed
   positioning as the calendar, and for the same reason. */
.petra-clock {
  position: fixed;
  z-index: 1080;
  width: 15rem;
  max-width: calc(100vw - 1rem);
}

.petra-clock-face {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  touch-action: manipulation;
}

.petra-clock-dial {
  fill: var(--bs-body-bg);
  stroke: var(--bs-border-color);
  stroke-width: 1;
}

.petra-clock-wedge {
  fill: var(--bs-primary);
  opacity: .16;
  stroke: none;
}

.petra-clock-tick {
  stroke: var(--bs-secondary-color);
  stroke-width: 1;
}

.petra-clock-tick-major {
  stroke: var(--bs-body-color);
  stroke-width: 1.6;
}

.petra-clock-hour {
  font-size: 11px;
  fill: var(--bs-secondary-color);
}

.petra-clock-hand {
  stroke: var(--bs-primary);
  stroke-width: 2;
  stroke-linecap: round;
}

/* The start is hollow and the end solid, so which is which is readable
   without moving anything. */
.petra-clock-knob {
  stroke: var(--bs-primary);
  stroke-width: 2;
}

.petra-clock-knob-from {
  fill: var(--bs-body-bg);
}

.petra-clock-knob-to {
  fill: var(--bs-primary);
}

.petra-clock-pin {
  fill: var(--bs-body-color);
}

/* Sortable column headings. They are links, but a table heading that looks
   like a link in a page full of links reads as navigation, so the styling
   stays flat until it is the column in use. */
.petra-sort {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.petra-sort:hover {
  text-decoration: underline;
}

.petra-sort-on {
  font-weight: 600;
}

.petra-sort-arrow {
  font-size: .7em;
  margin-inline-start: .25rem;
  opacity: .7;
}

.petra-share-col {
  width: 8rem;
}

/* Lýsing in the time report: at most seventy characters wide, wrapping
   rather than stretching the column.

   The constraint sits on a div inside the cell because max-width on a <td>
   is advisory in an auto-layout table and browsers may widen it anyway.
   `ch` is the width of a "0", so 70ch is seventy characters of the table's
   own font rather than a guess in rem. overflow-wrap breaks a long
   unbroken string — a URL in a description — instead of letting it push
   the column out regardless. */
.petra-wrap-70 {
  max-width: 70ch;
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Figures in the per-employee block of a time report. They share one cell
   so they sit beside the name rather than across the table, and each is a
   fixed-width inline block so the block still reads as columns. */
.petra-sum-cell {
  display: inline-block;
  width: 5rem;
  text-align: right;
  white-space: nowrap;
}

.petra-sum-wide {
  width: 7rem;
}

.petra-sum-travel {
  width: 9rem;
}

/* The labels wrap where the figures under them must not, so a heading as
   long as "Akstur (Höfuðborgarsvæðið)" does not force the column wide
   enough to hold it on one line. */
.petra-sum-head {
  white-space: normal;
  vertical-align: bottom;
}

/* How wide the app runs.

   Bootstrap's .container stops at 1140px, which is generous for prose and
   mean for a table: the entry list alone has eleven columns, and the time
   report has seven plus a description. This is fluid instead, so a wide
   screen is used, with a ceiling because a form stretched across an
   ultrawide monitor is worse than one that is slightly too narrow.

   The nav carries the same class, so the menu lines up with the content
   under it rather than sitting inside a narrower column. */
.petra-shell {
  max-width: 1800px;
}

/* Taxtar verkefnis.

   A rate typed in by hand is a negotiated price rather than a list one, so
   it reads red: in a column where most fields are empty, the exceptions are
   the whole point and should be findable at a glance.

   Behind an empty field sits the price the gjaldskrá would charge, with the
   project's discount already taken off. Unlike other placeholders — which
   are a hint about the format and get out of the way on focus, see above —
   this one is the number being replaced, so it only dims rather than
   disappearing while the new figure is typed next to it. */
.petra-rate::placeholder {
  color: #9aa6b8;
}

.petra-rate:focus::placeholder {
  color: #c7cedb;
}

.petra-rate-own {
  color: #d14343;
}

/* The cross that puts a type-ahead back to "all".

   It sits inside the field rather than beside it so the row of filters
   keeps its rhythm, and the field is padded on that side so a long project
   name does not run underneath it. */
.petra-combo-clear {
  position: absolute;
  top: 50%;
  right: .6rem;
  transform: translateY(-50%);
  z-index: 4;
  padding: .25rem;
  opacity: .45;
}

.petra-combo-clear:hover,
.petra-combo-clear:focus {
  opacity: .9;
}

.petra-combo input {
  padding-right: 2rem;
}

/* The month panel: a year at the top and its twelve months under it.

   Four across rather than three, so the panel is about as wide as the
   field it hangs under instead of a tall column beside it. */
.petra-months {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .15rem;
}

.petra-months .btn {
  padding: .3rem .25rem;
}

.petra-month-on {
  background: var(--bs-primary, #0d6efd);
  color: #fff !important;
  border-radius: .25rem;
}

/* The row you came back to.

   Saving an undanþága or a split on Allar færslur reloads the page, and
   the return carries a #txn-… fragment so the browser lands on the row
   rather than at the top. scroll-margin-top keeps it off the very edge of
   the viewport, and :target says which row it was — a page that has
   scrolled itself somewhere is worth explaining. */
tr[id^="txn-"] {
  scroll-margin-top: 4rem;
}

tr[id^="txn-"]:target > td,
tr[id^="txn-"]:target > th {
  background-color: var(--bs-primary-bg-subtle);
}
