/* ============================================================
   CHRISEN PIPEFLOW CHECKER — VISUAL IDENTITY
   Branded for Chrisen Consulting: Civil · Structural · Transport
   · Engineers. Uses the Chrisen red (#cc2027) as the primary
   accent, with a neutral charcoal/grey palette for text and
   chrome. Layout is compacted for single-screen visibility at
   100% browser zoom.
   ============================================================ */

:root {
  /* --- Chrisen Consulting Palette --- */
  --ink:        #2b2b2b;   /* charcoal — primary text, chrome */
  --ink-soft:   #6b6b6b;   /* warm grey for secondary text */
  --paper:      #f5f5f5;   /* neutral light grey background */
  --paper-line: #e0e0e0;   /* faint grid lines */
  --card:       #ffffff;   /* card surface */
  --brand:      #cc2027;   /* Chrisen red — primary accent */
  --brand-soft: #fce8e8;   /* pale red tint for highlights */
  --ok:         #2f6d4f;   /* pass state (green, desaturated) */
  --ok-bg:      #e3efe8;
  --warn:       #b45309;   /* amber — fail state */
  --warn-bg:    #fef3c7;   /* warm light amber background */

  /* --- Type --- */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-data:    "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --font-ui:      "Inter", "Segoe UI", -apple-system, sans-serif;

  --radius: 3px;
}

@media (prefers-reduced-motion: no-preference) {
  .result-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    linear-gradient(var(--paper-line) 1px, transparent 1px) 0 0 / 100% 24px,
    linear-gradient(90deg, var(--paper-line) 1px, transparent 1px) 0 0 / 24px 100%,
    var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.4;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ============================================================
   HEADER / TITLE BLOCK — Chrisen Red
   ============================================================ */

.titleblock {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 8px 24px;
  background: var(--brand);
  color: #ffffff;
  border-bottom: 3px solid var(--ink);
}

.titleblock__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.titleblock__logo {
  height: 34px;
  width: auto;
  object-fit: contain;
}

.titleblock__brand h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0;
  color: #ffffff;
}

.titleblock__sub {
  margin: 1px 0 0;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.3px;
}

.titleblock__right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.titleblock__meta {
  display: flex;
  gap: 12px;
}

.btn--header-download {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border: 1.5px solid rgba(255, 255, 255, 0.5);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius);
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: background 0.15s ease;
}

.btn--header-download:hover {
  background: rgba(255, 255, 255, 0.3);
}

.titleblock__meta label {
  display: flex;
  flex-direction: row;
  align-items: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
  gap: 6px;
  white-space: nowrap;
}

.titleblock__meta input {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-family: var(--font-data);
  font-size: 12px;
  padding: 3px 2px;
  min-width: 80px;
}

.titleblock__meta input:focus {
  outline: none;
  border-bottom-color: #ffffff;
}

.titleblock__meta input::placeholder { color: rgba(255, 255, 255, 0.45); }

/* ============================================================
   LAYOUT — compact for single-screen visibility
   ============================================================ */

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  padding: 12px 24px 16px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
}

/* ============================================================
   INPUT PANEL — compact
   ============================================================ */

.panel {
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 16px;
  /* Not sticky — prevents covering reference tables below */
}

@media (max-width: 860px) {
  .panel { position: static; }
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--brand);
}

.field { margin-bottom: 8px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.field__row {
  display: flex;
  align-items: center;
  border: 1px solid #c7d2ce;
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

/* Shared layout for all field inputs */
.field__row input,
.field__row select {
  flex: 1;
  border: none;
  padding: 7px 10px;
  font-family: var(--font-data);
  font-size: 14px;
  color: var(--ink);
  width: 100%;
  min-width: 0;
  background: #fff;
}

/* Hide native number spinner arrows */
.field__row input[type="number"]::-webkit-inner-spin-button,
.field__row input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field__row input[type="number"] {
  -moz-appearance: textfield;
}

/* Dropdown-specific styles — NOT applied to regular number inputs */
.field__row select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b6b' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

.field__row input:focus,
.field__row select:focus {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.field__row .unit {
  padding: 0 8px;
  font-size: 11px;
  color: var(--ink-soft);
  background: #f3f6f5;
  border-left: 1px solid #c7d2ce;
  white-space: nowrap;
  align-self: stretch;
  display: flex;
  align-items: center;
}

.btn {
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
}

.btn--primary {
  background: var(--brand);
  color: #ffffff;
}

.btn--primary:hover { background: #a91b21; }
.btn--primary:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.btn--green {
  background: var(--ok);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 8px 16px;
}

.btn--green:hover { background: #23523b; }
.btn--green:focus-visible { outline: 3px solid var(--ok); outline-offset: 2px; }

.download-section {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.error {
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  min-height: 16px;
  margin: 8px 0 0;
}

.hint {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--paper-line);
  line-height: 1.45;
}

.field__linked-note {
  font-size: 10px;
  color: var(--ink-soft);
  margin: 4px 0 0;
  line-height: 1.4;
}

/* ============================================================
   RESULTS — compact cards
   ============================================================ */

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  align-content: start;
}

.result-card {
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  padding: 10px 12px;
  border-top: 3px solid var(--brand);
}

.result-card__title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px;
}

.result-card__depth {
  font-size: 11px;
  color: var(--ink-soft);
  margin: 0 0 10px;
  font-family: var(--font-data);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px dashed var(--paper-line);
  font-size: 12px;
}

.result-row:last-of-type { border-bottom: none; }

.result-row__label { color: var(--ink-soft); }

.result-row__value {
  font-family: var(--font-data);
  font-weight: 600;
  color: var(--ink);
  text-align: right;
}

.result-row__value .num {
  color: var(--brand);
}

.badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge--ok    { background: var(--ok-bg);   color: var(--ok); }
.badge--warn  { background: var(--warn-bg); color: var(--warn); }

/* ============================================================
   MAIN CONTENT COLUMN
   ============================================================ */

.main-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: start; /* Prevents vertical stretching in grid layout, keeping the button close to the tables */
}

/* ============================================================
   REFERENCE TABLES — compact, branded
   ============================================================ */

.reference-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.reference-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: start;
}

.ref-table-title {
  font-family: var(--font-display);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-soft);
  margin: 0;
  text-align: center;
  font-weight: 700;
}

.table-container {
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  max-height: calc(100vh - 360px); /* Dynamically fill the remaining viewport height */
  overflow-y: auto;  /* Enable vertical scrolling inside the tables */
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 10px;
  line-height: 1.2;
}

.ref-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--brand-soft);
  color: var(--ink);
  padding: 5px 6px;
  font-weight: 600;
  font-size: 10px;
  border-bottom: 2px solid var(--brand);
}

.ref-table td {
  padding: 3px 6px;
  border-bottom: 1px solid var(--paper-line);
  color: var(--ink-soft);
}

.ref-table tr:last-child td {
  border-bottom: none;
}

/* Make numbers monospaced */
.ref-table td:last-child {
  font-family: var(--font-data);
  font-weight: 600;
  color: var(--ink);
}

/* Surface material names left-aligned */
.ref-table td:first-child:not(:last-child) {
  text-align: left;
}

/* ============================================================
   FOOTER — branded
   ============================================================ */

.footer {
  padding: 14px 28px 20px;
  font-size: 11px;
  color: var(--ink-soft);
  border-top: 1px solid var(--paper-line);
  max-width: 100%;
}

.footer__brand {
  color: var(--brand);
  font-weight: 600;
}
