/* ============================================================
   Service / Institution / Job detail pages — shared styling layer
   ------------------------------------------------------------
   Loaded AFTER each page's own sheet, so it can normalise three
   pages that had drifted apart: gradients on the job hero (5) and
   institution sheet (15), 20+ hardcoded hexes, one treatment per
   button, and three different card rhythms.

   Everything is scoped to #main-content so it cannot leak into the
   header, modals are handled separately on <body>, and every colour
   comes from tokens.css / theme.css so dark mode and the theme
   editor keep working.

   Rule of thumb applied throughout: 90% neutral surface, accent only
   on the single primary action, semantic colour only for status.
   ============================================================ */

/* ---------- page shell ---------- */

#main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px clamp(12px, 2.5vw, 28px) 56px;
}

/* ---------- shared heading + text rhythm ---------- */

#main-content h1 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--color-on-surface, #24344a);
  overflow-wrap: anywhere;
}

#main-content h2 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-on-surface, #24344a);
}

/* ---------- shared cards ---------- */

#main-content .job-section,
#main-content .job-card-side,
#main-content .job-owner-card,
#main-content .caution {
  background: var(--color-surface, var(--white));
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius-lg, 14px);
  box-shadow: none;
}

/* ============================================================
   JOB PAGE
   ============================================================ */

#main-content .job-hero {
  background: var(--color-surface, var(--white));
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius-lg, 14px);
  padding: clamp(16px, 2.4vw, 24px);
  box-shadow: none;
  background-image: none;
}

#main-content .job-hero-inner { max-width: none; }

#main-content .job-hero h1,
#main-content #job-title-js {
  margin: 6px 0 4px;
  font-size: clamp(2rem, 1.6rem + 1vw, 2.6rem);
  font-weight: 600;
}

#main-content .job-company {
  margin: 0 0 10px;
  font-size: 1.35rem;
  color: var(--color-on-muted, #5b6b80);
}

/* Chips: one neutral pill style, no coloured variants. */
#main-content .job-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

#main-content .job-chip,
#main-content .job-chip.exp,
#main-content .job-chip.reg {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--color-border, var(--line));
  background: var(--neutral-100, var(--neutral-100));
  color: var(--color-on-muted, #5b6b80);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

#main-content .job-salary {
  margin: 4px 0 0;
  font-size: clamp(1.8rem, 1.5rem + 0.7vw, 2.2rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-on-surface, #24344a);
}

#main-content .job-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

#main-content .job-apply-btn,
#main-content .job-report-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--radius-md, 10px);
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 600;
  cursor: pointer;
  background-image: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#main-content .job-apply-btn {
  background: var(--brand-orange-500, var(--brand-orange-500));
  border: 1px solid var(--brand-orange-500, var(--brand-orange-500));
  color: var(--color-on-accent, #1a0d00);
}

#main-content .job-apply-btn:hover { background: var(--brand-orange-600, var(--brand-orange-600)); border-color: var(--brand-orange-600, var(--brand-orange-600)); }

#main-content .job-report-btn {
  background: transparent;
  border: 1px solid var(--color-border, var(--line));
  color: var(--color-on-surface, #24344a);
  font-weight: 500;
}

#main-content .job-report-btn:hover { background: var(--neutral-100, var(--neutral-100)); }

#main-content .job-apply-btn .ic,
#main-content .job-report-btn .ic { width: 16px; height: 16px; }

#main-content .job-apply-btn:focus-visible,
#main-content .job-report-btn:focus-visible,
#main-content .job-modal-submit:focus-visible {
  outline: 2px solid var(--color-ring, var(--brand-orange-700));
  outline-offset: 2px;
}

/* Body: 8/4 split, sticky aside. */
#main-content .job-body {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

#main-content .job-main { display: grid; gap: 12px; min-width: 0; }

#main-content .job-section {
  padding: clamp(14px, 1.8vw, 20px);
  margin: 0;
}

#main-content .job-section h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

#main-content .job-desc {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.7;
  color: var(--color-on-surface, #24344a);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

#main-content .job-reqs {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 1.3rem;
  line-height: 1.6;
  color: var(--color-on-surface, #24344a);
}

#main-content .job-reqs li::marker { color: var(--color-on-muted, #5b6b80); }

#main-content .job-docs-note,
#main-content .job-howto {
  margin: 0 0 8px;
  font-size: 1.25rem;
  line-height: 1.6;
  color: var(--color-on-muted, #5b6b80);
}

#main-content .job-contact {
  font-size: 1.3rem;
  color: var(--color-on-surface, #24344a);
  overflow-wrap: anywhere;
}

#main-content .job-side {
  display: grid;
  gap: 12px;
  position: sticky;
  top: calc(var(--ws-header-h, 16px) + 12px);
}

#main-content .job-card-side { padding: 4px 14px; }

#main-content .job-card-side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--color-border, var(--line));
  font-size: 1.25rem;
}

#main-content .job-card-side-head:last-child { border-bottom: 0; }
#main-content .job-card-side-label { color: var(--color-on-muted, #5b6b80); }
#main-content .job-card-side-head b {
  font-weight: 600;
  color: var(--color-on-surface, #24344a);
  text-align: right;
  overflow-wrap: anywhere;
}

#main-content .job-owner-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

#main-content .inst-owner-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--neutral-100, var(--neutral-100));
  border: 1px solid var(--color-border, var(--line));
}

#main-content .inst-owner-avatar img { width: 100%; height: 100%; object-fit: cover; }

#main-content .job-owner-id { display: grid; gap: 2px; min-width: 0; }
#main-content .job-owner-id b { font-size: 1.35rem; font-weight: 600; color: var(--color-on-surface, #24344a); }

#main-content .job-profile-link {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--brand-navy-800, #06426e);
  text-decoration: none;
}

#main-content .job-profile-link:hover { text-decoration: underline; }

#main-content .caution { padding: 12px 14px; }

#main-content .caution-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-on-surface, #24344a);
}

#main-content .caution ol {
  margin: 0 0 0 16px;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 1.2rem;
  line-height: 1.55;
  color: var(--color-on-muted, #5b6b80);
}

#main-content .job-similar { margin-top: 18px; }

#main-content .inst-section-head { margin-bottom: 10px; }
#main-content .inst-section-head h2 { margin: 0; font-size: 1.6rem; }
#main-content .inst-section-sub { margin: 2px 0 0; font-size: 1.25rem; color: var(--color-on-muted, #5b6b80); }

/* ============================================================
   INSTITUTION PAGE
   ============================================================ */

#main-content .inst-title-wrap h1 {
  margin: 4px 0 6px;
  font-size: clamp(2.1rem, 1.7rem + 1vw, 2.8rem);
  font-weight: 600;
}

#main-content .inst-type-ribbon {
  display: inline-block;
  padding: 3px 9px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--color-border, var(--line));
  background: var(--neutral-100, var(--neutral-100));
  color: var(--color-on-muted, #5b6b80);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background-image: none;
}

#main-content .inst-fact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius-md, 10px);
  background: var(--color-surface, var(--white));
  font-size: 1.25rem;
  color: var(--color-on-surface, #24344a);
}

#main-content .inst-fact-ic svg,
#main-content .inst-fact-ic .ic {
  width: 16px;
  height: 16px;
  color: var(--color-on-muted, #5b6b80);
}

#main-content .inst-thumbs img {
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--color-border, var(--line));
  object-fit: cover;
}

#main-content .inst-rooms,
#main-content .inst-rooms-grid { gap: 10px; }

#main-content .inst-similar { margin-top: 18px; }
#main-content .inst-sim-grid { gap: 12px; }

#main-content .inst-cal-key {
  font-size: 1.15rem;
  color: var(--color-on-muted, #5b6b80);
}

/* Owner blocks shared by the institution and job pages. */
#main-content .owner-actions { display: flex; flex-wrap: wrap; gap: 8px; }

#main-content .owner-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--color-border, var(--line));
  background: var(--color-surface, var(--white));
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--color-on-surface, #24344a);
  background-image: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

#main-content .owner-action a { color: inherit; text-decoration: none; }
#main-content .owner-action:hover { background: var(--neutral-100, var(--neutral-100)); border-color: var(--neutral-300, var(--neutral-300)); }

/* Report actions stay semantic: red text, neutral surface. */
#main-content .owner-action.danger,
#main-content .owner-action.danger-alt {
  background: transparent;
  color: var(--color-destructive, var(--color-destructive));
  border-color: var(--color-border, var(--line));
}

#main-content .owner-action.danger:hover,
#main-content .owner-action.danger-alt:hover {
  border-color: var(--color-destructive, var(--color-destructive));
  background: rgba(201, 42, 47, 0.06);
}

/* ============================================================
   SERVICE PAGE
   (buttons and the details container come from retail-detail.css,
    which this page also loads; only the hero typography is tuned here)
   ============================================================ */

#main-content .layer1 {
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius-lg, 14px);
  box-shadow: none;
  background: var(--color-surface, var(--white));
}

#main-content .sName,
#main-content .productName .sName {
  font-size: clamp(2rem, 1.7rem + 1vw, 2.6rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-on-surface, #24344a);
}

#main-content .layer1 .productSummary .productDescription {
  font-size: 1.35rem;
  line-height: 1.68;
  color: var(--color-on-surface, #24344a);
  overflow-wrap: anywhere;
}

#main-content .productInformation {
  background: var(--neutral-50, var(--neutral-50));
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius-md, 10px);
  padding: 10px;
  gap: 8px;
}

#main-content .productInfo .info {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius-sm, 6px);
  background: var(--color-surface, var(--white));
  padding: 6px 10px;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--color-on-muted, #5b6b80);
  box-shadow: none;
}

#main-content .productInfo .info span {
  color: var(--color-on-surface, #24344a);
  font-weight: 600;
}

#main-content .productInfo .info .ic { width: 14px; height: 14px; color: var(--color-on-muted, #5b6b80); }

#main-content .posted { font-size: 1.2rem; color: var(--color-on-muted, #5b6b80); }

/* ============================================================
   MODALS (outside #main-content, so scoped to body)
   ============================================================ */

/* The two pages nest their modals differently, so the overlay and the panel
   are separate targets here:
     job        -> .job-modal (overlay)       > .job-modal-card (panel)
     institution-> .inst-modal-backdrop (overlay) > .inst-modal (panel)
   Styling .inst-modal as the overlay would have turned the card itself into a
   full-screen fixed layer. */
body .job-modal,
body .inst-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(1, 42, 70, 0.55);
}

body .job-modal[hidden],
body .inst-modal-backdrop[hidden] { display: none; }

body .job-modal-card,
body .inst-modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: clamp(16px, 2.4vw, 24px);
  border-radius: var(--radius-lg, 14px);
  border: 1px solid var(--color-border, var(--line));
  background: var(--color-surface, var(--white));
  color: var(--color-on-surface, #24344a);
  box-shadow: 0 18px 44px rgba(1, 42, 70, 0.18);
}

/* The institution sheet has a wide calendar variant; keep it wider. */
body .inst-modal { max-width: 480px; }
body .inst-modal-wide { max-width: 720px; }

body .job-modal-card h3,
body .inst-modal h3 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--color-on-surface, #24344a);
}

body .job-modal-sub,
body .inst-modal-sub,
body .inst-modal-sub {
  margin: 0 0 14px;
  font-size: 1.25rem;
  color: var(--color-on-muted, #5b6b80);
}

body .job-modal-close,
body .inst-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid transparent;
  background: transparent;
  color: var(--color-on-muted, #5b6b80);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

body .job-modal-close svg,
body .inst-modal-close svg { width: 18px; height: 18px; }

body .job-modal-close:hover,
body .inst-modal-close:hover { background: var(--neutral-100, var(--neutral-100)); }

/* Fields: visible labels, 44px controls, no placeholder-only inputs. */
body .job-field,
body .inst-book-field { display: grid; gap: 4px; }

body .job-field > span,
body .inst-book-field > span,
body .job-field > label,
body .inst-book-field > label {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--color-on-muted, #5b6b80);
}

body .job-field input,
body .job-field textarea,
body .job-field select,
body .inst-book-field input,
body .inst-book-field textarea,
body .inst-book-field select,
body .inst-modal input,
body .inst-modal select,
body .inst-modal textarea,
body .job-modal-card > textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--color-border, var(--line));
  border-radius: var(--radius-sm, 6px);
  background: var(--color-surface, var(--white));
  color: var(--color-on-surface, #24344a);
  font-family: inherit;
  font-size: 1.3rem;
  line-height: 1.45;
}

body .job-field textarea,
body .inst-book-field textarea,
body .inst-modal textarea,
body .job-modal-card > textarea { min-height: 96px; resize: vertical; }

body .job-field input:focus,
body .job-field textarea:focus,
body .inst-book-field input:focus,
body .inst-book-field textarea:focus,
body .inst-modal input:focus,
body .inst-modal textarea:focus,
body .job-modal-card > textarea:focus {
  outline: none;
  border-color: var(--brand-orange-500, var(--brand-orange-500));
  box-shadow: var(--shadow-focus, 0 0 0 3px rgba(168, 65, 10, 0.35));
}

body .job-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
body .job-gap { margin-top: 12px; }

body .job-field-hint,
body .job-modal-note,
body .inst-book-note {
  margin: 4px 0 0;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--color-on-muted, #5b6b80);
}

body .job-req-flag { color: var(--color-destructive, var(--color-destructive)); font-weight: 600; }

body .job-modal-submit,
body .inst-book-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  padding: 10px 16px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--brand-orange-500, var(--brand-orange-500));
  background: var(--brand-orange-500, var(--brand-orange-500));
  color: var(--color-on-accent, #1a0d00);
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 600;
  cursor: pointer;
  background-image: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

body .job-modal-submit:hover,
body .inst-book-submit:hover {
  background: var(--brand-orange-600, var(--brand-orange-600));
  border-color: var(--brand-orange-600, var(--brand-orange-600));
}

/* Destructive actions are outlined, never a second solid colour. */
body .job-modal-submit.danger {
  background: transparent;
  border-color: var(--color-destructive, var(--color-destructive));
  color: var(--color-destructive, var(--color-destructive));
}

body .job-modal-submit.danger:hover { background: rgba(201, 42, 47, 0.08); }

body .job-modal-submit:disabled,
body .inst-book-submit:disabled { opacity: 0.55; cursor: not-allowed; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 900px) {
  #main-content .job-body { grid-template-columns: 1fr; }
  #main-content .job-side { position: static; }
}

@media (max-width: 560px) {
  #main-content .job-hero-actions > * { flex: 1 1 100%; }
  #main-content .job-card-side-head { font-size: 1.2rem; }
  body .job-field-grid { grid-template-columns: 1fr; }
  body .job-modal-card,
  body .inst-modal { max-height: 86vh; }
}

/* ============================================================
   DARK MODE
   ============================================================ */

[data-theme="dark"] #main-content .job-chip,
[data-theme="dark"] #main-content .inst-type-ribbon {
  background: #17223a;
  border-color: #24314b;
  color: #aebdd2;
}

[data-theme="dark"] #main-content .job-card-side,
[data-theme="dark"] #main-content .job-owner-card,
[data-theme="dark"] #main-content .job-section,
[data-theme="dark"] #main-content .job-hero,
[data-theme="dark"] #main-content .caution,
[data-theme="dark"] #main-content .inst-fact,
[data-theme="dark"] #main-content .layer1 {
  background: #121a2b;
  border-color: #24314b;
}

[data-theme="dark"] #main-content .productInformation { background: #17223a; border-color: #24314b; }

[data-theme="dark"] #main-content .productInfo .info,
[data-theme="dark"] #main-content .owner-action {
  background: #121a2b;
  border-color: #24314b;
  color: #dbe6f3;
}

[data-theme="dark"] #main-content .owner-action:hover { background: #1b2540; }

[data-theme="dark"] body .job-modal-card,
[data-theme="dark"] body .inst-modal {
  background: #121a2b;
  border-color: #24314b;
  color: #dbe6f3;
}

[data-theme="dark"] body .job-field input,
[data-theme="dark"] body .job-field textarea,
[data-theme="dark"] body .inst-book-field input,
[data-theme="dark"] body .inst-book-field textarea,
[data-theme="dark"] body .inst-modal input,
[data-theme="dark"] body .inst-modal textarea,
[data-theme="dark"] body .job-modal-card > textarea {
  background: #0a101d;
  border-color: #24314b;
  color: #dbe6f3;
}

[data-theme="dark"] #main-content .job-profile-link { color: #7fb0e0; }

/* ============================================================
   MOTION + CONTRAST
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  #main-content .job-apply-btn,
  #main-content .job-report-btn,
  #main-content .owner-action,
  body .job-modal-submit,
  body .inst-book-submit { transition: none; }
}

@media (forced-colors: active) {
  #main-content .job-section,
  #main-content .job-card-side,
  #main-content .job-owner-card,
  #main-content .caution,
  #main-content .inst-fact,
  #main-content .owner-action,
  body .job-modal-card,
  body .inst-modal { border: 1px solid CanvasText; }

  #main-content .job-apply-btn,
  body .job-modal-submit,
  body .inst-book-submit { border: 2px solid Highlight; }
}
