/* ==========================================================================
   ShareForm — compact "one-screen" layout
   Goal: the whole form (name → submit) is visible without scrolling on
   phones, tablets and desktops. Everything below the form (How it works,
   FAQ, footer) stays as normal scrolling page content.
   All class names used by the page JS are unchanged
   (upload-zone, has-files, drag, prog-wrap.show, pill.*, status-msg.show.*,
    submit-btn, proc-*, hidden, sem-other, btn-note).
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --teal:       #0d9488;
  --teal-light: #14b8a6;
  --teal-dark:  #0f766e;
  --teal-xl:    #ccfbf1;
  --ink:        #0f2027;
  --ink2:       #1e3a3a;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --bg:         #f0fdfa;
  --error:      #ef4444;
  --success:    #10b981;
  --r:          12px;

  --nav-h:      58px;   /* sticky navbar */
  --banner-h:   60px;   /* motivation banner */
  --fs-input:   14px;
  --in-h:       42px;
  --gap:        12px;
}

body {
  margin: 0; padding: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Page main ── */
.page-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 32px;
}

/* ── Stage: one viewport tall (capped), card stretches inside it ── */
.form-stage {
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 14px 12px;
  min-height: min(calc(100vh - var(--nav-h) - var(--banner-h)), 740px);
  min-height: min(calc(100dvh - var(--nav-h) - var(--banner-h)), 740px);
}

/* ── Form card ── */
.form-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(13,148,136,.14);
  padding: 20px 26px 22px;
  width: 100%;
  max-width: 720px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: fadeUp .45s ease both;
}
.form-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--teal-dark), var(--teal-light), #06b6d4);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
.form-header {
  text-align: center; margin-bottom: 12px; flex-shrink: 0;
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 8px;
}
.form-badge { order: 1; } .form-sub { order: 2; } .form-title { order: 3; flex-basis: 100%; } .form-card .incentive-strip { order: 4; }
.form-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--teal-xl); color: var(--teal-dark);
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 10px;
  border-radius: 20px; margin-bottom: 0;
}
.form-title {
  font-family: 'Syne', sans-serif;
  font-size: 24px; font-weight: 800;
  color: var(--ink2); line-height: 1.15; margin: 0 0 2px;
}
.form-title span { color: var(--teal); }
.form-sub { font-size: 12px; color: var(--muted); margin: 0; }
.form-card .incentive-strip {
  margin: 10px auto 0;
  padding: 7px 14px;
  font-size: 13px;
  gap: 4px 10px;
}

/* ── Form grid (all fields on one screen) ── */
#uploadForm {
  flex: 1 1 auto;
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  grid-template-rows: auto auto auto auto auto auto;
  grid-template-areas:
    "name     email"
    "upload   upload"
    "course   university"
    "semester year"
    "message  message"
    "submit   submit";
}
.f-name       { grid-area: name; }
.f-email      { grid-area: email; }
.f-upload     { grid-area: upload; }
.f-course     { grid-area: course; }
.f-university { grid-area: university; }
.f-semester   { grid-area: semester; }
.f-year       { grid-area: year; }
.f-message    { grid-area: message; display: flex; flex-direction: column; min-height: 0; }
.f-submit     { grid-area: submit; }

/* ── Fields ── */
.field { margin: 0; min-width: 0; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--ink2); margin-bottom: 4px; line-height: 1.25;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.field label .req { color: var(--error); margin-left: 2px; }
.field label .opt, .field label small { display: inline !important; font-weight: 400; color: var(--muted); font-size: 11px; margin: 0 0 0 3px; }

.field input, .field select, .field textarea {
  width: 100%; padding: 0 12px;
  height: var(--in-h);
  border: 2px solid var(--border); border-radius: var(--r);
  font-family: 'DM Sans', sans-serif; font-size: var(--fs-input);
  color: var(--ink); background: #fafafa;
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none; margin: 0;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal-light);
  box-shadow: 0 0 0 3px rgba(20,184,166,.12);
  background: #fff;
}
.field select {
  appearance: none; -webkit-appearance: none;
  padding-right: 28px; text-overflow: ellipsis;
  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 1.5l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.field textarea {
  /* compact description box (fixed small height) */
  flex: 0 0 auto; height: 56px; min-height: 0;
  padding: 8px 12px; resize: none; line-height: 1.4;
}

/* course / university / semester "Other" input sits next to the select */
.sem-row { display: flex; gap: 6px; position: relative; }
.sel-wrap { position: relative; flex: 1 1 0; min-width: 0; }
.sel-wrap select { width: 100%; }
.sem-row select { flex: 1 1 0; min-width: 0; }
.sem-row .sem-other { width: auto !important; flex: 1 1 0; min-width: 0; margin: 0; }
.sem-row:has(.sem-other:not(.hidden)) select { flex: 0 0 96px; }
.sem-row:has(.sem-other:not(.hidden)) .sel-wrap { flex: 0 0 96px; }
.sem-row .sem-other::placeholder { font-size: 13px; }
.hidden { display: none !important; }

/* ── Upload zone (compact, horizontal) ── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--r);
  padding: 0 14px; min-height: 58px;
  display: grid; grid-template-columns: auto 1fr; align-items: center;
  column-gap: 12px; text-align: left; cursor: pointer;
  background: #fafafa; position: relative; transition: all .2s;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--teal-light); background: #f0fdfa; }
.upload-zone.has-files { border-color: var(--success); background: #f0fdf4; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.uz-icon  { grid-row: 1 / span 2; font-size: 26px; transition: transform .3s; display: block; line-height: 1; }
.upload-zone:hover .uz-icon { transform: translateY(-2px); }
.uz-title { font-family: 'Syne', sans-serif; font-size: 14px; font-weight: 700; color: var(--ink2); line-height: 1.2; align-self: end; }
.uz-sub   { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.3; align-self: start; }

/* ── Progress (single slim row) ── */
.prog-wrap { margin-top: 6px; display: none; }
.prog-wrap.show { display: block; }
.prog-top  { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; }
.prog-label{ font-size: 11px; font-weight: 600; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prog-pct  { font-size: 11px; font-weight: 700; color: var(--teal); }
.prog-track{ height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; }
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal-dark), var(--teal-light));
  border-radius: 4px; transition: width .35s ease; width: 0%;
}
.prog-sub  { display: none; }

/* ── File pills (one scrolling line — never adds height) ── */
.file-pills { display: flex; flex-wrap: nowrap; gap: 5px; margin-top: 6px; overflow-x: auto; scrollbar-width: none; }
.file-pills:empty { display: none; }
.file-pills::-webkit-scrollbar { display: none; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  background: #fff; border: 1px solid var(--border);
  border-radius: 20px; padding: 2px 9px;
  font-size: 11px; color: var(--ink2); transition: all .2s;
}
.pill.uploading { border-color: var(--teal-light); color: var(--teal-dark); }
.pill.done      { border-color: var(--success); color: #065f46; background: #f0fdf4; }
.pill.error     { border-color: var(--error);   color: #991b1b; background: #fef2f2; }
.pill-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.uploading .pill-dot { background: var(--teal); animation: blink 1s infinite; }
.done      .pill-dot { background: var(--success); }
.error     .pill-dot { background: var(--error); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Status msg (max 2 lines) ── */
.status-msg {
  padding: 6px 10px; border-radius: 9px;
  font-size: 12px; font-weight: 500; margin-top: 6px; display: none;
  line-height: 1.3; white-space: pre-line;
  display: none; overflow: hidden;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.status-msg.show   { display: -webkit-box; }
.status-msg.error  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.status-msg.success{ background: #f0fdf4; color: #065f46; border: 1px solid #bbf7d0; }
.status-msg.info   { background: #f0fdfa; color: var(--teal-dark); border: 1px solid #99f6e4; }

/* ── Submit btn ── */
.submit-btn {
  width: 100%; height: 48px; padding: 0 18px; margin: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--teal-dark), var(--teal-light));
  color: #fff; border: none; border-radius: var(--r);
  font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700;
  cursor: pointer; transition: all .25s;
}
.submit-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(13,148,136,.3); }
.submit-btn:disabled { background: linear-gradient(135deg, #94a3b8, #cbd5e1); cursor: not-allowed; transform: none; box-shadow: none; }
.btn-note { font-size: 11px; font-weight: 400; opacity: .85; display: inline; margin: 0; font-family: 'DM Sans', sans-serif; }

/* ── Processing overlay ── */
.proc-overlay {
  position: fixed; inset: 0;
  background: rgba(15,32,39,.72);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: none; align-items: center; justify-content: center;
}
.proc-overlay.show { display: flex; }
.proc-card {
  background: #fff; border-radius: 18px;
  padding: 32px 28px; text-align: center;
  max-width: 320px; width: 90%;
  box-shadow: 0 8px 48px rgba(0,0,0,.18);
}
.proc-spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--teal-xl);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin .9s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.proc-title { font-family: 'Syne', sans-serif; font-size: 20px; font-weight: 800; color: var(--ink2); margin-bottom: 6px; }
.proc-sub   { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.proc-track { height: 6px; background: var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.proc-fill  { height: 100%; background: linear-gradient(90deg, var(--teal-dark), var(--teal-light)); border-radius: 6px; transition: width .6s ease; }
.proc-step  { font-size: 12px; color: var(--muted); }

/* ── Related links under the form ── */
.related-links-section { width: 100%; max-width: 720px; margin-top: 8px; padding: 0 12px; }

/* ── Footer ── */
.site-footer {
  text-align: center; padding: 16px 20px;
  font-size: 14px; color: #555;
  border-top: 1px solid var(--border); background: #fff;
}
.site-footer .disclaimer {
  margin-top: 8px; font-size: 13px; color: #6b7280; line-height: 1.5;
  max-width: 900px; margin-left: auto; margin-right: auto;
}

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

/* Touch devices: 16px inputs so iOS Safari doesn't zoom the page on focus */
@media (pointer: coarse) {
  :root { --fs-input: 16px; }
}

/* Phones / narrow screens */
@media (max-width: 600px) {
  :root { --in-h: 38px; --gap: 8px; }
  .form-stage { padding: 8px 8px; }
  .form-card  { padding: 14px 12px 14px; border-radius: 14px; }
  .form-header { margin-bottom: 8px; }
  .form-badge { font-size: 9.5px; padding: 2px 8px; }
  .form-sub { font-size: 11px; }
  .form-title { font-size: 19px; }
  .form-card .incentive-strip { margin-top: 4px; padding: 5px 10px; font-size: 11.5px; border-radius: 12px; gap: 2px 8px; }
  .incentive-strip .incentive-item { white-space: normal; }
  .field label { font-size: 11.5px; margin-bottom: 3px; }
  .field label small { font-size: 10px; }
  .upload-zone { min-height: 52px; padding: 0 12px; column-gap: 10px; }
  .uz-icon { font-size: 22px; }
  .uz-title { font-size: 13px; }
  .uz-sub { font-size: 10.5px; }
  .submit-btn { height: 44px; font-size: 15px; }
  .btn-note { display: none; }
  .field textarea { padding: 6px 10px; height: 44px; }
  .field input, .field select { padding-left: 10px; padding-right: 8px; }
  .field select { padding-right: 24px; background-position: right 9px center; }
}

/* Phones: when "Other" is chosen, keep the select just wide enough for the word "Other" */
@media (max-width: 600px) {
  .sem-row { gap: 5px; }
  .sem-row:has(.sem-other:not(.hidden)) select {
    flex: 0 0 74px; padding-left: 9px; padding-right: 20px; background-position: right 6px center;
  }
  .sem-row:has(.sem-other:not(.hidden)) .sel-wrap { flex: 0 0 74px; }
  .sem-row .sem-other { padding-left: 8px; padding-right: 6px; }
}

/* Short screens (any width): everything stays, just slimmer */
@media (max-height: 760px) {
  :root { --banner-h: 38px; --in-h: 36px; --gap: 6px; }
  .motivation-banner { height: 38px !important; padding: 4px 12px !important; gap: 8px !important; }
  .motivation-text { font-size: 11.5px !important; line-height: 1.25 !important; }
  .motivation-icon { font-size: 14px !important; }
  .form-badge { font-size: 9.5px; padding: 1px 8px; }
  .form-sub { font-size: 11px; }
  .form-header { margin-bottom: 6px; }
  .form-title { font-size: 18px; }
  .form-card .incentive-strip { margin-top: 3px; padding: 4px 10px; font-size: 11px; }
  .form-stage { padding-top: 6px; padding-bottom: 6px; }
  .form-card { padding-top: 10px; padding-bottom: 10px; }
  .field label { margin-bottom: 2px; }
  .field textarea { height: 40px; }
}

/* After files are picked, slim the zone a little (text stays) */
@media (max-height: 760px) {
  .upload-zone.has-files { min-height: 42px; }
  .upload-zone.has-files .uz-title { align-self: end; }
  .status-msg { -webkit-line-clamp: 1; }
  .prog-sub { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
}

/* Very short screens: tighter still (nothing removed) */
@media (max-height: 600px) {
  :root { --in-h: 33px; --gap: 5px; }
  .form-title { font-size: 16px; }
  .upload-zone { min-height: 42px; }
  .uz-icon { font-size: 18px; }
  .submit-btn { height: 38px; }
  .field textarea { height: 34px; }
}

/* ── Bigger boxes + bigger motivation text when there is room (never at the cost of fit) ── */
.motivation-banner .motivation-text { font-size: 15px; }
.motivation-banner .motivation-icon { font-size: 18px; }
.field textarea { height: 88px; }
.upload-zone { min-height: 84px; }
.uz-icon { font-size: 32px; }
.uz-title { font-size: 15px; }
.uz-sub { font-size: 12px; }

@media (max-width: 600px) {
  .motivation-banner .motivation-text { font-size: 13px; }
  .field textarea { height: 56px; }
  .upload-zone { min-height: 62px; }
  .uz-icon { font-size: 26px; }
  .uz-title { font-size: 14px; }
  .uz-sub { font-size: 11px; }
}
@media (max-height: 860px) {
  .field textarea { height: 64px; }
  .upload-zone { min-height: 66px; }
  .uz-icon { font-size: 28px; }
}
@media (max-height: 860px) and (max-width: 600px) {
  .field textarea { height: 50px; }
  .upload-zone { min-height: 56px; }
}
@media (max-height: 760px) {
  .motivation-banner .motivation-text { font-size: 12.5px !important; }
  .field textarea { height: 44px; }
  .upload-zone { min-height: 50px; }
  .uz-icon { font-size: 22px; }
  .uz-title { font-size: 13px; }
  .uz-sub { font-size: 10.5px; }
}
@media (max-height: 760px) and (min-height: 641px) {
  .field textarea { height: 52px; }
  .upload-zone { min-height: 56px; }
}
@media (max-height: 600px) {
  .field textarea { height: 34px; }
  .upload-zone { min-height: 42px; }
  .uz-icon { font-size: 18px; }
}

/* Phone / small-tablet LANDSCAPE: 4 columns so it still fits in one screen */
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  :root { --in-h: 32px; --gap: 6px; }
  .form-stage { padding: 6px; }
  .form-card { padding: 8px 12px 10px; max-width: 900px; }
  .form-header { margin-bottom: 4px; }
  .form-title { font-size: 16px; }
  .form-card .incentive-strip { padding: 2px 10px; font-size: 10.5px; margin-top: 0; }
  #uploadForm {
    grid-template-columns: repeat(4, minmax(0,1fr));
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "name     email   course   university"
      "semester year    upload   upload"
      "message  message message  submit";
  }
  .f-message textarea { height: 34px; }
  .upload-zone { min-height: 36px; padding: 0 8px; column-gap: 8px; }
  .uz-icon { font-size: 18px; }
  .uz-sub { font-size: 9.5px; }
  .uz-title { font-size: 12px; }
  .submit-btn { height: 100%; min-height: 36px; font-size: 14px; }
  .field label { font-size: 11px; margin-bottom: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .form-card, .proc-spinner, .pill-dot { animation: none !important; }
}


/* ── Semester: all options in one grid on phones (no scrolling list) ── */
.sem-tap { display: none; position: absolute; inset: 0; width: 100%; background: transparent; border: 0; padding: 0; cursor: pointer; border-radius: var(--r); }
.sem-pop {
  display: none; position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 60;
  width: min(250px, 86vw); padding: 8px; gap: 6px;
  grid-template-columns: repeat(3, 1fr);
  background: #fff; border: 2px solid var(--teal-light); border-radius: 14px;
  box-shadow: 0 10px 32px rgba(15,32,39,.22);
}
.sem-pop.show { display: grid; }
.sem-opt {
  height: 40px; border: 2px solid var(--border); border-radius: 10px; background: #f8fafc;
  font-family: 'DM Sans', sans-serif; font-size: 16px; font-weight: 600; color: var(--ink2); cursor: pointer;
}
.sem-opt.on { background: var(--teal); border-color: var(--teal-dark); color: #fff; }
.sem-opt:active { transform: scale(.96); }
@media (max-width: 600px) { .sem-tap { display: block; } }

/* ── Logged-in user: email column hidden, name takes the full row ── */
#uploadForm.no-email .f-email { display: none; }
#uploadForm.no-email {
  grid-template-areas:
    "name     name"
    "upload   upload"
    "course   university"
    "semester year"
    "message  message"
    "submit   submit";
}
@media (orientation: landscape) and (max-height: 520px) and (min-width: 560px) {
  #uploadForm.no-email {
    grid-template-areas:
      "name     name    course   university"
      "semester year    upload   upload"
      "message  message message  submit";
  }
}