/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Override Pico's default font with Inter */
:root {
  --pico-font-family-sans-serif: "Inter", system-ui, -apple-system, sans-serif;
  --pico-font-size: 16px;
}

/* Source Serif 4 Condensed for tables; block display enables overflow-x */
table {
  font-family: "Source Serif 4", Georgia, serif;
  font-stretch: condensed;
  font-size: 0.875rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* App header in the style of the "Das Neue Geld" book cover:
   red title sitting directly on a red band */
:root {
  --ndg-red: #c61452;
}

.app-header {
  padding-block: 0;
  margin-bottom: 0;
}

.app-header .brand {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  padding-top: 1.25rem;
}

.app-header .brand-kicker {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--pico-muted-color);
  padding-bottom: 0.3rem;
}

.app-header .brand-title {
  font-family: "Anton", sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.75rem);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ndg-red);
  line-height: 1;
  text-box: trim-both cap alphabetic; /* trims the box exactly to the baseline */
  margin-bottom: -1px;                /* avoids a hairline gap to the band */
}

@supports not (text-box: trim-both cap alphabetic) {
  .app-header .brand-title {
    line-height: 0.8;
    margin-bottom: -0.1em;
  }
}

.app-header .brand-band {
  background: var(--ndg-red);
  flex-wrap: wrap;
}

/* Let the menu entries wrap on narrow screens instead of overflowing
   the band (which left them white-on-white outside the red background) */
.app-header .brand-band > ul {
  flex-wrap: wrap;
}

.app-header .brand-band a,
.app-header .brand-band summary {
  font-size: 0.875rem;
}

.app-header .brand-band > ul > li > a {
  color: #fff;
}

/* Pico styles the dropdown summary like a form field (white background,
   border, focus shadow); make it look like a plain nav link on the band */
.app-header .brand-band details.dropdown > summary:not([role]),
.app-header .brand-band details.dropdown > summary:not([role]):focus,
.app-header .brand-band details.dropdown > summary:not([role]):active {
  background-color: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #fff;
}

.app-header .brand-band details.dropdown > summary:not([role]):focus-visible {
  box-shadow: 0 0 0 2px #fff;
}

/* Use the same box metrics as the nav links so "Stammdaten" sits on
   the same baseline as the other menu entries */
.app-header .brand-band details.dropdown {
  display: inline-block;
  margin: 0;
}

.app-header .brand-band details.dropdown > summary:not([role]) {
  height: auto;
  margin: calc(var(--pico-nav-link-spacing-vertical) * -1) calc(var(--pico-nav-link-spacing-horizontal) * -1);
  padding: var(--pico-nav-link-spacing-vertical) var(--pico-nav-link-spacing-horizontal);
  border-width: 0;
}

.app-header .brand-band details.dropdown > summary::after {
  height: calc(1em * var(--pico-line-height));
}

.app-header .brand-band > ul > li > a:hover,
.app-header .brand-band > ul > li > a:focus-visible {
  text-decoration: underline;
  text-decoration-color: #fff;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.3em;
}

/* Chevron: muted white, full white on hover / when open */
.app-header .brand-band summary::after {
  filter: brightness(0) invert(1);
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.app-header .brand-band summary:hover::after,
.app-header .brand-band details[open] summary::after {
  opacity: 1;
}

a.secondary {
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

a.secondary:hover {
  opacity: 1;
}

h1 {
  color: var(--pico-color-sand-500)
}

h2, h3 {
  color: var(--pico-color-sand-400)
}

.icon-sm  { font-size: 0.875rem; }
.icon-md  { font-size: 1.25rem; }
.icon-lg  { font-size: 1.5rem; }
.icon-xl  { font-size: 2rem; }

/* Attribute grid for detail views */
dl.attribute-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem;
  margin: 0;
}

dl.attribute-grid > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

dl.attribute-grid dt {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pico-muted-color);
  margin: 0;
}

dl.attribute-grid dd {
  font-size: 0.9375rem;
  margin: 0;
}

/* Action bar below detail views */
.action-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* Page title with a primary action (e.g. "new") on the right */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: var(--pico-typography-spacing-vertical);
}

.page-header h1 {
  margin-bottom: 0;
}

/* Icon actions (edit, destroy) in the last column of index tables */
.row-actions {
  white-space: nowrap;
}

.row-actions form {
  display: inline;
}

.row-actions button.icon-button,
.row-actions button.icon-button:is(:hover, :active, :focus) {
  --pico-background-color: transparent;
  --pico-border-color: transparent;
  --pico-box-shadow: none;
  --pico-color: var(--pico-secondary);
  width: auto;
  margin: 0 0 0 0.5rem;
  padding: 0;
  vertical-align: baseline;
  line-height: inherit;
}

.row-actions button.icon-button:focus-visible {
  --pico-box-shadow: 0 0 0 var(--pico-outline-width) var(--pico-secondary-focus);
}

.row-actions button.icon-button.danger:hover {
  --pico-color: var(--ndg-red);
}

/* Flash messages */
.flash-notice { color: var(--pico-ins-color); }
.flash-alert  { color: var(--pico-del-color); }

/* Welcome page */
.welcome-hero {
  padding-block: 2rem 1rem;
}

.welcome-hero .lead {
  font-size: 1.125rem;
  max-width: 48rem;
}

.welcome-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
}

.welcome-steps article {
  margin: 0;
}

.welcome-steps .ti {
  color: var(--ndg-red);
}

/* Sign-in card */
.auth-card {
  max-width: 28rem;
  margin: 2rem auto;
}

/* Scenario and user menu: buttons look like dropdown entries */
.app-header .nav-menu form {
  margin: 0;
}

.app-header .nav-menu button {
  font-size: 0.875rem;
  width: 100%;
  margin: 0;
  padding: var(--pico-form-element-spacing-vertical) var(--pico-form-element-spacing-horizontal);
  border: 0;
  background: transparent;
  color: var(--pico-dropdown-color);
  text-align: start;
}

.app-header .nav-menu button:hover {
  background: var(--pico-dropdown-hover-background-color);
}

/* On phones the user menu shows just the icon, not the e-mail address */
@media (max-width: 576px) {
  .app-header .user-menu .user-email {
    display: none;
  }

  .app-header .scenario-menu .scenario-name {
    display: inline-block;
    max-width: 8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
  }
}

.app-header .nav-menu button[aria-current="true"] {
  font-weight: 600;
}

/* Current scenario in the scenario list */
.row-actions button.icon-button.selected,
.row-actions button.icon-button.selected:is(:hover, :active, :focus) {
  --pico-color: var(--ndg-red);
}
