/* dokumenty.domovnadeje.cz

   Colours, logo and type mirror domovnadeje.cz:
     --yellow  #F5C030   primary brand colour
     --cream   #FFF2C2   tint
     --ink     #111111   header, footer, text
     Poppins, self-hosted (see scripts/fetch-fonts.sh)

   One stylesheet for the public page and the admin page. No framework,
   no build step, no dark mode -- the brand is a light page with a black bar. */

:root {
  --yellow: #f5c030;
  --yellow-dark: #e2ab17;
  --cream: #fff2c2;
  --ink: #111111;
  --body: #333333;
  --muted: #767676;
  --line: #e6e6e6;
  --line-strong: #cccccc;
  --white: #ffffff;
  --bg: #ffffff;
  --danger: #b3261e;
  --danger-tint: #fdeceb;
  --focus: 0 0 0 3px rgb(245 192 48 / 45%);

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgb(17 17 17 / 4%);
  --shadow-lift: 0 6px 18px -10px rgb(17 17 17 / 25%);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--body);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Footer sits at the bottom of the viewport on short pages. */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  /* Guard: nothing may make the whole page scroll sideways. Wide things (the admin
     tables) scroll inside their own .table-wrap instead. */
  overflow-x: clip;
}

main {
  flex: 1 0 auto;
}

a {
  color: var(--ink);
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--ink);
  text-decoration-color: var(--yellow);
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--radius);
}

h1,
h2,
h3 {
  color: var(--ink);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.wrap {
  width: 100%;
  max-width: 60rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 10;
  padding: 0.5rem 0.9rem;
  background: var(--yellow);
  color: var(--ink);
  border-radius: var(--radius);
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  top: 0.75rem;
}

/* -------------------------------------------------------------------- header
   Same bar as the main site: black, logo left, white links, yellow on hover. */

.site-header {
  background: var(--ink);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  min-height: 4.5rem;
}

.brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: auto;
  height: 2.6rem;
  /* Without a ceiling the logo's intrinsic width sets the page's minimum width,
     which pushed everything off-screen on a phone. */
  max-width: min(220px, 45vw);
}

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: var(--white);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: color 0.2s;
}

.nav-link:hover {
  color: var(--yellow);
}

.who {
  color: rgb(255 255 255 / 70%);
  font-size: 0.875rem;
  min-width: 0;
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- main/text */

main {
  display: block;
}

.page-title {
  display: inline-block;
  margin: 2.75rem 0 0;
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.4rem);
  font-weight: 700;
  /* The brand's marker-pen highlight. */
  background-image: linear-gradient(transparent 68%, var(--yellow) 68%);
  background-repeat: no-repeat;
  padding: 0 0.1em 0.05em;
}

/* ---------------------------------------------------------------------- chips
   One button per category, plus "Vše". Only categories that hold documents
   are shown to the public. */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s;
}

.chip:hover {
  border-color: var(--ink);
}

.chip[aria-pressed="true"] {
  background: var(--yellow);
  border-color: var(--yellow);
  font-weight: 600;
}

.chip-count {
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] .chip-count {
  color: var(--ink);
}

/* ------------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  margin: 2rem 0 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.field > label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

.search {
  position: relative;
  flex: 1 1 16rem;
}

.search svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.05rem;
  height: 1.05rem;
  color: var(--muted);
  pointer-events: none;
}

input[type="text"],
input[type="search"],
select,
textarea {
  width: 100%;
  min-height: 2.875rem;
  padding: 0.6rem 0.9rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="search"] {
  padding-left: 2.6rem;
}

textarea {
  min-height: 4.5rem;
  resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--yellow);
  box-shadow: var(--focus);
}

select {
  width: auto;
  cursor: pointer;
}

.result-count {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

/* ------------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn:hover {
  border-color: var(--ink);
  background: var(--white);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled],
.btn[aria-busy="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* The main site's CTA: solid yellow pill. Reserved for the one primary action
   on a screen, so it keeps its weight. */
.btn-primary {
  background: var(--yellow);
  border-color: var(--yellow);
  border-radius: 999px;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
}

.btn-primary:hover {
  background: var(--yellow-dark);
  border-color: var(--yellow-dark);
  color: var(--ink);
}

.btn-danger {
  color: var(--danger);
  border-color: rgb(179 38 30 / 30%);
}

.btn-danger:hover {
  background: var(--danger-tint);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-sm {
  min-height: 2.125rem;
  padding: 0.3rem 0.8rem;
  font-size: 0.875rem;
}

.mt-1 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 3rem;
}

/* ----------------------------------------------------------------- downloads */

.doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.doc {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.15rem;
  padding: 1rem 1.15rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.doc:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift);
}

.doc-main {
  min-width: 0;
}

.doc-name {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.doc-name a {
  color: var(--ink);
  text-decoration: none;
}

.doc-name a:hover {
  text-decoration: underline;
  text-decoration-color: var(--yellow);
  text-decoration-thickness: 2px;
}

.doc-desc {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9375rem;
  overflow-wrap: anywhere;
}

.doc-meta {
  margin: 0.45rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.doc-meta span + span::before {
  content: "·";
  margin-right: 0.5rem;
}

.doc-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-badge {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--radius);
  background: var(--cream);
  color: var(--ink);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.doc.is-editing {
  grid-template-columns: minmax(0, 1fr);
}

.doc.is-editing .edit-form {
  max-width: none;
}

/* -------------------------------------------------------------------- states */

.state {
  padding: 3.5rem 1.5rem;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--muted);
}

.state h2 {
  margin: 0 0 0.35rem;
  font-size: 1.0625rem;
}

.state p {
  margin: 0;
  font-size: 0.9375rem;
}

.skeleton {
  height: 5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(90deg, var(--white) 25%, #f6f6f6 37%, var(--white) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* -------------------------------------------------------------------- alerts */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  border: 1px solid var(--line-strong);
  background: #fafafa;
  margin: 0 0 1.25rem;
}

.alert[hidden] {
  display: none;
}

.alert-error {
  background: var(--danger-tint);
  border-color: rgb(179 38 30 / 30%);
  color: var(--danger);
}

.alert-success {
  background: #f1f8f2;
  border-color: #cfe4d3;
  color: #1c6b35;
}

.alert-info {
  background: var(--cream);
  border-color: var(--yellow);
  color: var(--ink);
}

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

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card > h2 {
  margin: 0 0 0.25rem;
  font-size: 1.125rem;
}

.card > h2 + p {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

/* Tab panels have no card around them: the tab already says which section you are in,
   so a bordered box and a repeating heading just add noise. */
.panel {
  margin-bottom: 1.5rem;
}

.panel > .toolbar:first-child,
.panel > .field:first-child {
  margin-top: 0;
}

/* Section tabs on the admin page: one section at a time, not everything at once. */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.1rem 0 1.4rem;
}

.tab {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.5rem 1.15rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.tab:hover {
  border-color: var(--ink);
}

.tab[aria-selected="true"] {
  background: var(--yellow);
  border-color: var(--yellow);
  font-weight: 600;
}

.tab[hidden] {
  display: none;
}

.card[id] {
  scroll-margin-top: 1rem;
}

.grid-2 {
  display: grid;
  gap: 0.875rem;
}

@media (min-width: 34rem) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

/* ------------------------------------------------------------------ dropzone */

.dropzone {
  display: grid;
  place-items: center;
  gap: 0.35rem;
  padding: 2rem 1rem;
  text-align: center;
  background: #fbfbfb;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--yellow);
  background: #fffdf5;
}

.dropzone strong {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
}

.dropzone span {
  font-size: 0.875rem;
  color: var(--muted);
}

.dropzone input[type="file"] {
  display: none;
}

/* ------------------------------------------------------------------ progress */

.progress {
  height: 0.5rem;
  background: #f0f0f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 1rem 0 0.5rem;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--yellow);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress[hidden],
.progress-bar[hidden] {
  display: none;
}

/* -------------------------------------------------------------------- table */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

th,
td {
  padding: 0.75rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #fbfbfb;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fbfbfb;
}

td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 15rem;
}

.cell-name .file-badge {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.5625rem;
  flex: none;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: var(--mono);
  font-size: 0.75rem;
  word-break: break-all;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.edit-form {
  display: grid;
  gap: 0.6rem;
  max-width: 34rem;
  padding: 0.25rem 0;
}

.edit-form input {
  min-height: 2.5rem;
}

.truncate {
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------------- footer */

.site-footer {
  margin-top: 4rem;
  background: var(--ink);
  color: rgb(255 255 255 / 70%);
  font-size: 0.875rem;
  flex-shrink: 0;
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.site-footer a {
  color: var(--white);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--yellow);
}

.site-footer .signout {
  margin-left: auto;
}

/* --------------------------------------------------------------- responsive */

@media (max-width: 46rem) {
  .wrap {
    padding: 0 1.1rem;
  }

  .site-header .wrap {
    min-height: 3.75rem;
    gap: 0.6rem;
    flex-wrap: wrap;
    padding-top: 0.65rem;
    padding-bottom: 0.65rem;
  }

  .brand-logo {
    height: 1.9rem;
  }

  .nav-link {
    padding: 0.4rem 0.5rem;
    font-size: 0.9375rem;
  }

  .who {
    max-width: 8rem;
  }

  .doc {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.9rem;
    padding: 0.9rem 1rem;
  }

  .doc-action {
    grid-column: 2;
  }

  .doc-action .btn {
    width: 100%;
  }

  .doc-action {
    flex-wrap: wrap;
  }

  /* Phone: turn each table row into a labelled block. No sideways scrolling, and
     nothing important has to be hidden. */
  .table-wrap {
    overflow-x: visible;
    border: 0;
  }

  .table-wrap table,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap td {
    display: block;
    width: auto;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tr {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.2rem;
    margin-bottom: 0.6rem;
  }

  .table-wrap tr:hover {
    background: var(--white);
  }

  .table-wrap td {
    border: 0;
    padding: 0.3rem 0.85rem;
  }

  .table-wrap td.num {
    text-align: left;
  }

  .table-wrap td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  td.num,
  .cell-name,
  .truncate {
    min-width: 0;
    max-width: none;
    white-space: normal;
  }

  .row-actions {
    margin-top: 0.35rem;
  }

  .row-actions .btn {
    flex: 1 1 auto;
  }

  /* Everything fits now, so nothing needs hiding. */
  .table-wrap .col-date,
  .table-wrap .mono {
    display: block;
  }

  .toolbar {
    align-items: stretch;
  }

  /* Put the search and the sort on their own lines instead of squeezing them in. */
  .toolbar .field,
  .toolbar select {
    flex: 1 1 100%;
    width: 100%;
  }

  th,
  td {
    padding: 0.6rem 0.7rem;
    font-size: 0.875rem;
  }

  .cell-name {
    min-width: 0;
  }

  .truncate {
    max-width: 12rem;
  }

  .chips {
    gap: 0.4rem;
    margin-top: 1.1rem;
  }

  .chip {
    padding: 0.3rem 0.7rem;
    font-size: 0.8125rem;
  }

  .card {
    padding: 1.1rem;
  }

  .page-title {
    margin-top: 2rem;
  }

  .toolbar {
    margin-top: 1.25rem;
  }

  /* Comfortable tap targets. */
  .btn-sm {
    min-height: 2.4rem;
    padding: 0.4rem 0.9rem;
  }

  .tabs {
    gap: 0.4rem;
    margin: 0.9rem 0 1.2rem;
  }

  .tab {
    flex: 1 1 auto;
    padding: 0.5rem 0.8rem;
    font-size: 0.875rem;
  }
}

@media (max-width: 26rem) {
  .who {
    display: none;
  }

  .brand-logo {
    height: 1.7rem;
  }

  .nav-link {
    font-size: 0.875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header,
  .toolbar,
  .doc-action,
  .site-footer {
    display: none;
  }

  .doc {
    border-color: #ddd;
    box-shadow: none;
    break-inside: avoid;
  }
}
