/*
 * Copyright (c) 2026 by Gabriele Proietti Mattia <pm.gabriele@gmail.com>.
 *
 * All Rights Reserved.
 */

/*
 * The stylesheet of Part 3 of W2: the portions: the Portions tab and the web page of the portions
 * (Porzioni, WebPorzioni). It is linked after kit.css, whose tokens and pieces it uses, and only adds
 * to them.
 */

/* the screen's title is fixed in index.html (a heading is a heading): the date above it is drawn into
   the root, and the order puts it first; the root itself gives its children to the screen's column */
#portions-root { display: contents; }

#portions-root > * { order: 1; }

#portions-root > .portions-eyebrow { order: -1; margin-bottom: calc(-1 * var(--space-3)); }

/* ------------------------------------------------------------------------ a phone */

.portions-group { display: flex; flex-direction: column; gap: var(--space-2); }

.portions-group__head { display: flex; justify-content: space-between; gap: var(--space-3); }

.portions-group__count { font-variant-numeric: tabular-nums; }

.portions-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 72px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.portions-row:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.portions-row__n {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  font-size: var(--fs-h2);
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

.portions-row--fridge .portions-row__n { background: var(--accent-soft); color: var(--accent); }
.portions-row--freezer .portions-row__n { background: var(--cold-soft); color: var(--cold); }

.portions-row__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.portions-row__recipe { font-weight: var(--fw-medium); }

.portions-row__when, .portions-row__line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  font-size: var(--fs-body-sm);
  color: var(--text-muted);
}

.portions-row__when .icon { width: 14px; height: 14px; color: var(--cold); }

.portions-also {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  font-size: var(--fs-caption);
  color: var(--text-muted);
}

.portions-also .icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------------------ one batch */

.portions-facts { display: flex; flex-direction: column; gap: var(--space-2); }
.portions-facts p { margin: 0; }
.portions-facts__chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.portions-facts__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.portions-facts__label { font-size: var(--fs-body-sm); color: var(--text-muted); }

.portions-howmany { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.portions-howmany__label { font-weight: var(--fw-medium); }

.portions-throw { color: var(--warn); }

/* ------------------------------------------------------------------------ the wide page */

.portions-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
  gap: var(--space-3);
}

.portions-stat { gap: var(--space-1); min-width: 0; }

.portions-stat__value {
  font-size: var(--fs-display-lg);
  line-height: var(--lh-tight);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-tight);
  font-variant-numeric: tabular-nums;
}

.portions-stat--fridge .portions-stat__value { color: var(--accent); }
.portions-stat--freezer .portions-stat__value { color: var(--cold); }
.portions-stat--soon .portions-stat__value { color: var(--warn); }

.portions-tablewrap { padding: 0; overflow-x: auto; }

.portions-table { width: 100%; min-width: 520px; border-collapse: collapse; }

.portions-table__head {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-mono-label);
  font-weight: var(--fw-medium);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
  color: var(--text-muted);
}

.portions-table td { padding: 0 var(--space-4); border-top: 1px solid var(--border); }

.portions-table__row { cursor: pointer; }
.portions-table__row.is-selected { background: var(--accent-soft); }

.portions-table__num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.portions-table__meal { color: var(--text-muted); }

.portions-pick {
  min-height: 56px;
  min-width: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: var(--fw-medium);
  text-align: left;
  cursor: pointer;
}

.portions-pick:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--radius-sm); }
