/* ============================================================
   Mirath: Components
   Buttons (wax seal, secondary, destructive) · card · field ·
   share chip · scholar banner · progress segments · heir row ·
   empty state · modal sheet · quiet confirmations.
   All colors via css/tokens.css custom properties.
   Owner: SHELL agent.
   ============================================================ */

/* ---------- Button: shared ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  min-width: 44px;
  padding-inline: var(--space-6);
  font-family: var(--font-sans-display);
  font-size: var(--text-headline);
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition:
    background var(--dur-micro) ease,
    color var(--dur-micro) ease,
    border-color var(--dur-micro) ease,
    transform 80ms var(--ease-settle),
    box-shadow var(--dur-micro) ease;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.btn:active { transform: scale(0.97); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.38;
  cursor: not-allowed;
}

/* ---------- Primary: wax seal (commitment only) ---------- */

.btn--commit {
  background: var(--color-commit);
  color: var(--color-commit-text);
  border: none;
}

@media (hover: hover) and (pointer: fine) {
  .btn--commit:hover {
    background: var(--color-commit-hover);
    box-shadow: var(--shadow-commit);
  }
}

.btn--commit:active {
  box-shadow: var(--shadow-commit);
}

/* ---------- Secondary ---------- */

.btn--secondary {
  background: transparent;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
}

@media (hover: hover) and (pointer: fine) {
  .btn--secondary:hover {
    background: var(--color-surface-raised);
  }
}

.btn--secondary:active {
  border-width: 2px;
}

/* ---------- Destructive: confirm sheets only ----------
   The wax seal is reserved for commitment; removal and erasure
   speak in the error-sepia register instead. */

.btn--destructive {
  background: transparent;
  color: var(--color-error);
  border: 1.5px solid var(--color-error);
}

@media (hover: hover) and (pointer: fine) {
  .btn--destructive:hover {
    background: var(--color-surface-raised);
    background: color-mix(in srgb, var(--color-error) 8%, transparent);
  }
}

.btn--destructive:active {
  border-width: 2px;
}

/* ---------- Icon base (inline SVG, 1.5px stroke) ---------- */

.icon {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Card: ledger entry ---------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

/* Ledger tab: a single brass rule along the top edge. */
.card--ledger {
  border-top: 2px solid var(--color-accent);
}

.card-title {
  font-size: var(--text-h2);
  margin-bottom: var(--space-3);
}

@media (hover: hover) and (pointer: fine) {
  .card--interactive:hover {
    box-shadow: var(--shadow-raised);
  }
}

/* ---------- Field: parchment input, label above ---------- */

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

.field + .field {
  margin-top: var(--space-4);
}

.field-label {
  font-family: var(--font-sans);
  font-size: var(--text-subhead);
  font-weight: 600;
  color: var(--color-text-primary);
}

.field-optional {
  font-weight: 400;
  color: var(--color-text-faint);
}

.field-input {
  width: 100%;
  min-height: 48px;
  padding-inline: var(--space-4);
  font: inherit;
  font-size: var(--text-body);
  color: var(--color-text-primary);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur-micro) ease, box-shadow var(--dur-micro) ease;
}

textarea.field-input {
  min-height: 96px;
  padding-block: var(--space-3);
  resize: vertical;
}

.field-input::placeholder {
  color: var(--color-text-faint);
}

/* The border is the focus ring (design-system §Input). The inset
   shadow thickens it to 2px without shifting layout. */
.field-input:focus,
.field-input:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: inset 0 0 0 1px var(--color-accent);
}

.field--error .field-input {
  border-color: var(--color-error);
}

.field--error .field-input:focus,
.field--error .field-input:focus-visible {
  border-color: var(--color-error);
  box-shadow: inset 0 0 0 1px var(--color-error);
}

.field-note {
  font-size: var(--text-footnote);
  color: var(--color-text-secondary);
  line-height: 1.4;
}

/* Collaborative amber tone: never "Invalid", never accusatory.
   Copy pattern: "We need [X] to calculate your [Y]." */
.field-error {
  font-size: var(--text-footnote);
  color: var(--color-awl);
  line-height: 1.4;
}

/* ---------- Share chip: Quranic fraction pill ---------- */

.share-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 28px;
  padding-inline: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--text-footnote);
  color: var(--color-text-primary);
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* Interactive chips stay under 44px visually; extend the hit area. */
button.share-chip::after,
a.share-chip::after {
  content: '';
  position: absolute;
  inset: -8px;
}

.share-chip--active {
  border: 2px solid var(--color-accent);
  background: var(--color-surface-raised);
  background: color-mix(in srgb, var(--color-accent) 8%, transparent);
}

/* ---------- Scholar-referral banner ---------- */

.scholar-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-inline-start: 3px solid var(--color-scholar);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  background: color-mix(in srgb, var(--color-scholar) 7%, transparent);
}

.scholar-banner-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--color-scholar);
}

.scholar-banner-text {
  font-size: var(--text-callout);
  line-height: 1.45;
  color: var(--color-text-primary);
}

.scholar-banner-text a {
  color: var(--color-accent);
}

/* ---------- Progress segments: ink filling the page ----------
   Five named chapters: You · Family · Estate · Wasiyyah · Papers.
   Location, not countdown: no percentage numbers. Each segment is
   a doorway: a link to its room (markup: nav > ol > li > a, with
   aria-current="step" on the present chapter). */

.progress-segments-list {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.progress-segment {
  flex: 1;
  min-width: 0;
  display: flex;
}

.progress-segment-link {
  flex: 1;
  min-width: 0;
  min-height: var(--tap-target-min);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-1);
  border-radius: var(--radius-sm);
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .progress-segment-link:hover .progress-segment-label {
    color: var(--color-text-primary);
  }
}

.progress-segment-bar {
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-separator);
  transition: background var(--dur-small) ease;
}

.progress-segment--done .progress-segment-bar {
  background: var(--color-accent);
}

.progress-segment--active .progress-segment-bar {
  background: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 55%, transparent);
}

.progress-segment-label {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  text-align: center;
  color: var(--color-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-segment--done .progress-segment-label {
  color: var(--color-text-secondary);
}

.progress-segment--active .progress-segment-label {
  color: var(--color-text-primary);
  font-weight: 600;
}

/* ---------- Heir row ---------- */

.heir-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.heir-row + .heir-row {
  margin-top: var(--space-3);
}

.heir-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.heir-row-name {
  font-size: var(--text-headline);
  font-weight: 600;
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.heir-row-relation {
  font-size: var(--text-footnote);
  color: var(--color-text-secondary);
}

/* Excluded heir (mahjub): dignified fading, never strikethrough.
   The person is not erased; their share passes to a closer heir.
   The fade lands on the descriptive content only (name, relation,
   status chip, notes), never on interactive children. The
   "Why is … excluded?" disclosure (<details> in .heir-row-main)
   and the Edit/Remove actions keep full opacity so their text
   stays WCAG AA legible in both modes. */
.heir-row--mahjub {
  transform: scale(0.97);
  transition: transform 300ms ease;
}

.heir-row--mahjub > .share-chip,
.heir-row--mahjub .heir-row-main > :not(details) {
  opacity: 0.45;
  transition: opacity 300ms ease;
}

.heir-row-status {
  font-size: var(--text-caption);
  font-style: italic;
  color: var(--color-hajb);
}

/* ---------- Empty state: line-art companion ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  max-width: 28rem;
  margin-inline: auto;
  padding: var(--space-12) var(--space-5);
  text-align: center;
}

.empty-state-icon {
  display: block;
  width: 56px;
  height: 56px;
  color: var(--color-text-faint);
}

.empty-state-title {
  font-size: var(--text-h2);
}

.empty-state-body {
  font-size: var(--text-callout);
  line-height: 1.5;
  color: var(--color-text-secondary);
}

/* ---------- Modal sheet: bottom panel, focus-trapped ----------
   Markup is built by Mirath.ui.openSheet (js/app.js). */

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: var(--midnight-vellum);
  opacity: 0;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: opacity 280ms ease;
}

.sheet-layer--open .sheet-backdrop {
  opacity: 0.55;
}

.sheet-layer--closing .sheet-backdrop {
  opacity: 0;
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: calc(100% - var(--space-12));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--color-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-raised);
  padding: var(--space-2) var(--space-5)
           calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%);
  transition: transform 450ms var(--ease-ios-present);
}

.sheet-layer--open .sheet {
  transform: translateY(0);
}

.sheet-layer--closing .sheet {
  transform: translateY(100%);
  transition: transform 280ms var(--ease-ios-dismiss);
}

.sheet-handle {
  width: 36px;
  height: 4px;
  margin: var(--space-2) auto var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-separator);
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.sheet-title {
  font-size: var(--text-h2);
  min-width: 0;
}

.sheet-close {
  flex-shrink: 0;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-inline-start: auto;
  margin-inline-end: calc(-1 * var(--space-2));
  border-radius: var(--radius-pill);
  color: var(--color-text-secondary);
  transition: color var(--dur-micro) ease, background var(--dur-micro) ease;
}

@media (hover: hover) and (pointer: fine) {
  .sheet-close:hover { color: var(--color-accent); }
}

.sheet-close:active {
  background: var(--color-surface-raised);
}

.sheet-close-icon {
  display: block;
  width: 18px;
  height: 18px;
}

.sheet-message {
  font-size: var(--text-body);
  line-height: 1.5;
  color: var(--color-text-primary);
  margin-bottom: var(--space-6);
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ---------- Unsaved-writing guard: quiet inline strip ----------
   Raised by a backdrop tap / Escape / chrome close on a changed form.
   Collaborative amber register, never an accusation. Built by
   Mirath.ui internals (js/app.js). */

.sheet-guard {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-inline-start: 3px solid var(--color-awl);
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
  background: color-mix(in srgb, var(--color-awl) 8%, transparent);
}

.sheet-guard-message {
  font-size: var(--text-callout);
  line-height: 1.45;
  color: var(--color-text-primary);
}

.sheet-guard-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-3);
}

.sheet-guard .btn {
  min-height: var(--tap-target-min);
  font-size: var(--text-subhead);
  padding-inline: var(--space-4);
}

/* The chamber holds still behind an open sheet. */
html.mirath-sheet-open .main-content {
  overflow: hidden;
}

/* ---------- Quiet inline confirmation: no toasts in this chamber ---------- */

.quiet-confirm {
  font-size: var(--text-footnote);
  color: var(--color-success);
  line-height: 1.4;
}
