/* OroLog on the web: the app's look (docs/analisi.md §7): Material 3 Fidelity palette from #FF8C00,
   Nunito, OpenMoji line icons, pill shapes. Light and dark, following the system or the choice in
   Settings (data-theme on <html>). */

@font-face {
  font-family: "Nunito";
  src: url("/web/fonts/nunito.ttf") format("truetype");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  color-scheme: light;
  --primary: #904d00;
  --on-primary: #ffffff;
  --primary-container: #ff8c00;
  --on-primary-container: #623200;
  --secondary-container: #fdb881;
  --on-secondary-container: #78471a;
  --bg: #fff8f5;
  --surface-low: #fff1e9;
  --surface: #ffeadd;
  --surface-high: #f9e4d7;
  --surface-highest: #f3dfd1;
  --on-surface: #241912;
  --on-surface-variant: #564334;
  --outline: #897362;
  --outline-variant: #ddc1ae;
  --error: #ba1a1a;
  --badge: #ffdcc3;
  --scrim: rgb(0 0 0 / 0.4);
  --inverse-surface: #3a2e25;
  --inverse-on-surface: #ffede3;
  --inverse-primary: #ffb77d;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.12), 0 4px 16px rgb(0 0 0 / 0.08);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --primary: #ffb77d;
    --on-primary: #4d2600;
    --secondary-container: #6a3b0f;
    --on-secondary-container: #e9a771;
    --bg: #1b110a;
    --surface-low: #241912;
    --surface: #281d15;
    --surface-high: #33281f;
    --surface-highest: #3f3229;
    --on-surface: #f3dfd1;
    --on-surface-variant: #ddc1ae;
    --outline: #a48c7a;
    --outline-variant: #564334;
    --error: #ffb4ab;
    --inverse-surface: #f3dfd1;
    --inverse-on-surface: #3a2e25;
    --inverse-primary: #904d00;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 4px 16px rgb(0 0 0 / 0.4);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #ffb77d;
  --on-primary: #4d2600;
  --secondary-container: #6a3b0f;
  --on-secondary-container: #e9a771;
  --bg: #1b110a;
  --surface-low: #241912;
  --surface: #281d15;
  --surface-high: #33281f;
  --surface-highest: #3f3229;
  --on-surface: #f3dfd1;
  --on-surface-variant: #ddc1ae;
  --outline: #a48c7a;
  --outline-variant: #564334;
  --error: #ffb4ab;
  --inverse-surface: #f3dfd1;
  --inverse-on-surface: #3a2e25;
  --inverse-primary: #904d00;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 4px 16px rgb(0 0 0 / 0.4);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--on-surface);
  font: 400 16px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--primary); }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--on-surface-variant); }
[hidden] { display: none !important; }

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

/* Line icons: OpenMoji black SVGs as masks, so they take the text color. */
.i {
  display: inline-block;
  flex: none;
  width: 24px;
  height: 24px;
  background-color: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat;
  mask: var(--i) center / contain no-repeat;
}
.i-sm { width: 20px; height: 20px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-surface-variant);
}
.icon-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--on-surface) 8%, transparent); }
.icon-btn:disabled { opacity: 0.38; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  background: var(--primary);
  color: var(--on-primary);
}
.btn:disabled { background: color-mix(in srgb, var(--on-surface) 12%, transparent); color: color-mix(in srgb, var(--on-surface) 38%, transparent); }
.btn-tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn-text { background: transparent; color: var(--primary); padding: 10px 14px; }
.btn-text:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.btn-danger { background: transparent; color: var(--error); }
.btn-danger:hover { background: color-mix(in srgb, var(--error) 8%, transparent); }
.btn-big {
  background: var(--primary-container);
  color: var(--on-primary-container);
  min-height: 56px;
  padding: 14px 24px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

/* ---- Page */

.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--outline-variant);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--on-surface); font-weight: 800; font-size: 22px; }
.brand img { width: 32px; height: 32px; }
.spacer { flex: 1; }
.account { color: var(--on-surface-variant); font-size: 14px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  font-size: 14px;
  font-weight: 700;
}

main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 16px; }

.layout { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.layout .list-col { position: sticky; top: 77px; max-height: calc(100vh - 93px); display: flex; flex-direction: column; }
.layout .list-scroll { overflow-y: auto; padding: 4px 4px 16px; margin: 0 -4px; }

footer.site {
  padding: 20px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--on-surface-variant);
}
.credits {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--outline-variant);
  text-align: center;
  font-size: 13px;
  color: var(--on-surface-variant);
}

/* ---- Sign in */

.signin {
  max-width: 520px;
  margin: 8vh auto 0;
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.signin img { width: 112px; height: 112px; }
.signin h1 { font-size: 34px; font-weight: 800; }
.signin p { color: var(--on-surface-variant); font-size: 18px; }
.error-text { color: var(--error); }

/* ---- Lists of projects */

.list-col { container: list / inline-size; }
.list-head { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.tabs { display: flex; gap: 8px; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--on-surface-variant);
  font-weight: 700;
  border: 1px solid var(--outline-variant);
}
.tab[aria-current="page"] { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.new-btn {
  margin-left: auto;
  padding: 8px 16px 8px 12px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  box-shadow: var(--shadow);
}
/* Narrower than the desktop column (a phone): the button keeps only ➕. */
@container list (max-width: 389px) {
  .new-btn { width: 44px; padding: 0; }
  .new-btn .label { display: none; }
}

.cards { display: flex; flex-direction: column; gap: 10px; }
.card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 32px 12px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--on-surface);
  text-decoration: none;
  border: 2px solid transparent;
}
.card:hover { background: var(--surface-high); }
.card[aria-current="true"] { border-color: var(--primary-container); background: var(--surface-high); }
.card-titles { display: flex; flex-direction: column; min-width: 0; }
.card-name { font-size: 19px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-total { color: var(--on-surface-variant); font-size: 16px; }

.project-img { display: inline-grid; place-items: center; flex: none; object-fit: contain; }
.project-img.photo { border-radius: 50%; object-fit: cover; }
.project-img.missing { color: var(--on-surface-variant); }
.img-sm { width: 40px; height: 40px; }
.img-md { width: 56px; height: 56px; }
.img-lg { width: 64px; height: 64px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 24px; }
.empty img { width: 112px; height: 112px; margin-bottom: 12px; }
.empty h2 { font-size: 22px; font-weight: 700; }
.empty p { color: var(--on-surface-variant); }

/* ---- Project */

.detail { min-width: 0; padding-bottom: 96px; }
.detail-head { display: flex; align-items: center; gap: 4px; min-height: 52px; margin: 0 0 12px; }
.detail-head h1 { flex: 1; min-width: 0; font-size: 26px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 4px; }
.detail-actions { display: flex; align-items: center; gap: 4px; }

.stats {
  border-radius: 24px;
  padding: 18px;
  background: var(--primary-container);
  color: var(--on-primary-container);
}
.stats-title { display: flex; align-items: center; gap: 14px; font-size: 22px; font-weight: 700; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 12px; text-align: center; }
.totals strong { display: block; font-size: 28px; font-weight: 800; line-height: 1.2; }
.totals span { font-weight: 600; font-size: 14px; }
.span-labels { display: flex; justify-content: space-between; margin-top: 14px; }
.span-line { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.span-line .between { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; font-size: 14px; font-weight: 600; text-align: center; }
.span-line .between::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid color-mix(in srgb, currentColor 40%, transparent); }
.span-line .between span { position: relative; background: var(--primary-container); padding: 0 8px; }
.span-line .end { text-align: right; }
.archived-line { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 600; }

.add-row { margin: 16px 0 4px; }

.section-head {
  position: sticky;
  top: 61px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  padding: 20px 4px 8px;
  background: var(--bg);
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
}
.logs { display: flex; flex-direction: column; gap: 8px; }
.logs.ungrouped { margin-top: 16px; }

.log {
  display: flex;
  align-items: stretch;
  min-height: 72px;
  border-radius: 36px;
  background: var(--surface-low);
  color: var(--on-surface);
}
.log:has(button.log-main:hover) { background: var(--surface); }
.log-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: stretch;
  border: 0;
  border-radius: 36px;
  padding: 0;
  background: transparent;
  text-align: left;
}
.log-hours {
  flex: none;
  align-self: flex-start;
  height: 72px;
  width: 112px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px 8px 12px;
  color: var(--primary);
  font-weight: 800;
  line-height: 1;
}
.log-hours .main { font-size: 34px; }
.log-hours .main.long { font-size: 26px; }
.log-hours .rest { font-size: 18px; margin-top: 2px; }
.log-text { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; padding: 12px 24px 12px 4px; }
.log-day { font-weight: 700; }
.log-note { color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log.expanded .log-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-expand { align-self: flex-start; margin: 14px 10px 0 -16px; }
.log-expand .i { transition: transform 0.2s; }
.log.expanded .log-expand .i { transform: rotate(180deg); }
.count { text-align: center; color: var(--on-surface-variant); padding: 16px 0 8px; }

.fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 4;
}

/* ---- Dialogs */

.dialog {
  border: 0;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border-radius: 28px;
  background: var(--bg);
  color: var(--on-surface);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: var(--scrim); }
.dialog-body { display: flex; flex-direction: column; gap: 16px; padding: 20px 24px 24px; max-height: calc(100vh - 48px); overflow-y: auto; }
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-titles { flex: 1; min-width: 0; }
.sheet-titles h2 { font-size: 22px; font-weight: 700; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.field-label { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--on-surface-variant); }

@media (max-width: 599px) {
  .dialog {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: 28px 28px 0 0;
    max-height: 92vh;
  }
  .dialog-body { max-height: 92vh; }
}

.input, textarea.input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--outline);
  border-radius: 14px;
  background: transparent;
}
.input:focus { outline: 2px solid var(--primary); border-color: transparent; }
textarea.input { resize: vertical; min-height: 52px; }
.counter { align-self: flex-end; font-size: 13px; color: var(--on-surface-variant); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
/* On a computer there's room for all of them: they wrap instead of scrolling (on a phone they scroll, like the app). */
@media (min-width: 600px) {
  .chips.scroll.wrap-wide { flex-wrap: wrap; overflow-x: visible; }
  /* Hour shortcuts: an even grid across the whole sheet (30 min … 10 h on two rows). */
  .chips.scroll.shortcut-grid { display: grid; grid-template-columns: repeat(6, 1fr); overflow-x: visible; }
  .shortcut-grid .chip { justify-content: center; padding-left: 4px; padding-right: 4px; }
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 7px 16px;
  border-radius: 10px;
  border: 1px solid var(--outline);
  background: transparent;
  color: var(--on-surface-variant);
  font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }

/* Hours sheet */
.stepper { display: flex; align-items: center; justify-content: center; gap: 16px; }
.round-btn {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}
.round-btn:disabled { background: var(--surface-high); color: var(--outline); }
.duration-value { min-width: 150px; text-align: center; font-size: 40px; font-weight: 800; color: var(--primary); }
.day-row { display: flex; align-items: center; gap: 4px; }
.day-btn { flex: 1; min-height: 48px; border: 1px solid var(--outline); border-radius: 14px; background: transparent; font-weight: 700; }
.date-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* Project editor */
.name-row { display: flex; align-items: center; gap: 14px; }
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px;
  border-radius: 16px;
  background: var(--surface-low);
}
.icon-cell { display: grid; place-items: center; aspect-ratio: 1; border: 2px solid transparent; border-radius: 14px; background: transparent; padding: 6px; }
.icon-cell:hover { background: var(--surface); }
.icon-cell[aria-pressed="true"] { border-color: var(--primary-container); background: var(--badge); }
.icon-cell img { width: 100%; height: 100%; }
.search-row { display: flex; align-items: center; gap: 4px; }
.notice { padding: 16px; border-radius: 16px; background: var(--surface-low); color: var(--on-surface-variant); text-align: center; }

/* Settings and choices */
.setting { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.setting-title { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.setting-body { color: var(--on-surface-variant); font-size: 14px; margin-top: -6px; }
.settings-section { font-size: 15px; font-weight: 700; color: var(--primary); margin-top: 8px; }
.amount-stepper { display: flex; align-items: center; gap: 8px; }
.amount-stepper strong { min-width: 90px; text-align: center; font-size: 18px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 8px; border-radius: 14px; cursor: pointer; }
.choice:hover { background: var(--surface-low); }
.choice input { margin-top: 5px; accent-color: var(--primary); width: 18px; height: 18px; }
.choice strong { display: block; }

/* Messages */
.toast-region { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 10; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 560px;
  padding: 12px 12px 12px 20px;
  border-radius: 12px;
  background: var(--inverse-surface);
  color: var(--inverse-on-surface);
  box-shadow: var(--shadow);
  pointer-events: auto;
}
.toast-action { border: 0; background: transparent; color: var(--inverse-primary); font-weight: 800; padding: 6px 10px; border-radius: 8px; }

@media (max-width: 599px) {
  main { padding: 12px; }
  .account { display: none; }
  .card { padding-right: 24px; }
  .log-hours { width: 92px; }
  .log-hours .main { font-size: 28px; }
  .totals strong { font-size: 22px; }
  .detail-head h1 { font-size: 22px; }
}
