/* AZoom shared styles. Phone first, with one laptop breakpoint at 768px. */

/* ---------- Fonts (stored locally) ---------- */
@font-face {
  font-family: "Inter";
  src: url("../media/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
}

@font-face {
  font-family: "Rammetto One";
  src: url("../media/fonts/rammetto-one.woff2") format("woff2");
}

/* ---------- Colours ---------- */
:root {
  --page-bg: #FBF6EA;
  --text: #14211F;
  --brand: #004F46;
  --buff: #EBD3A2;
  --buff-hover: #DFC386;
  --accent: #004F46;
  --accent-hover: #00382F;
  --error: #B5121B;
  --text-secondary: #4A5552;
  --text-muted: #5B6764;
  --border-card: #E8DCC0;
  --border-field: #BFAF86;
  --panel-bg: #F6EDD7;
  --photo-bg: #F0E3C4;
  --close-bg: #F3E8CC;
  --nav-text: #D9C48F;
  --footer-text: #E3D6B5;
  --white: #FFFFFF;
}

/* ---------- Page structure ---------- */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--page-bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 16px;
  letter-spacing: -0.01em;
}

main {
  flex: 1;
  width: 100%;
}

a {
  color: var(--text);
}

/* Content column used by every page */
.page-width {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Eyebrow, page title and line of text at the top of every page */
.page-intro {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 48px;
  padding-bottom: 24px;
}

.page-intro .eyebrow {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.page-intro h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.page-intro p {
  max-width: 620px;
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

/* A block of page content below the intro */
.page-section {
  padding-top: 16px;
  padding-bottom: 72px;
}

.section-title {
  margin: 0 0 16px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* ---------- Header ---------- */
#site-header {
  padding: 20px 16px 0;
}

.header-pill {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  max-width: 780px;
  margin: 0 auto;
  padding: 6px;
  border-radius: 32px;
  background-color: var(--brand);
  color: var(--white);
  box-shadow: 0 14px 34px rgba(0, 40, 36, 0.28);
}

.header-logo {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
  align-items: center;
  min-height: 44px;
  color: var(--white);
  font-family: "Rammetto One", "Inter", sans-serif;
  font-size: 20px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: uppercase;
  text-decoration: none;
}

/* Phone: a menu button on the right opens the links and the account button below the logo */
.header-menu-button {
  display: inline-flex;
  grid-column: 3;
  grid-row: 1;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--white);
  cursor: pointer;
  transition: background-color 150ms ease;
}

.menu-icon-close,
.header-menu-button[aria-expanded="true"] .menu-icon-open {
  display: none;
}

.header-menu-button[aria-expanded="true"] .menu-icon-close {
  display: block;
}

.header-menu {
  display: none;
  grid-column: 1 / -1;
  flex-direction: column;
  gap: 8px;
  padding: 8px 8px 10px;
  animation: banner-rise 200ms ease;
}

.header-pill.menu-open .header-menu {
  display: flex;
}

.header-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 16px;
  font-weight: 500;
}

.header-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--white);
  text-decoration: none;
  transition: color 150ms ease;
}

.header-nav a[aria-current="page"],
.header-nav a:active {
  color: var(--buff);
}

.header-account {
  display: flex;
  align-items: center;
  font-size: 16px;
}

.header-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 48px;
  padding: 0 22px;
  border: none;
  border-radius: 999px;
  background-color: var(--buff);
  color: var(--brand);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.header-action[hidden] {
  display: none;
}

.header-action svg {
  transition: transform 150ms ease;
}

/* ---------- Footer ---------- */
.site-footer {
  background-color: var(--brand);
  color: var(--footer-text);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px;
  font-size: 14px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--white);
  font-weight: 600;
  transition: color 150ms ease;
}

/* ---------- Buttons ---------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 22px;
  border: 1.5px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  background-color: var(--accent);
  color: var(--white);
  transition: background-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.button-secondary {
  background-color: var(--white);
  border-color: var(--text);
  color: var(--text);
  font-weight: 600;
  transition: background-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.button-full {
  width: 100%;
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Status badges ---------- */
.badge {
  display: inline-block;
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background-color: var(--close-bg);
  color: var(--text-muted);
}

.badge-available {
  background-color: #E3F4EA;
  color: #14633A;
}

.badge-reserved {
  background-color: #F6E5BD;
  color: #6B4A00;
}

.badge-rented {
  background-color: #E2ECFB;
  color: #1F4E96;
}

.badge-inspection {
  background-color: #ECE8F6;
  color: #4D3B86;
}

.badge-completed {
  background-color: #EBDFC2;
  color: #14211F;
}

.badge-cancelled {
  background-color: #F3ECDB;
  color: #5B6764;
}

/* ---------- Car cards ---------- */
.car-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.car-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-card);
  border-radius: 16px;
  background-color: var(--white);
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.car-photo {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
  overflow: hidden;
  background-color: var(--photo-bg);
  color: var(--text-muted);
  font-size: 13px;
}

.category-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 11px;
  border-radius: 999px;
  background-color: var(--white);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 1px 3px rgba(20, 33, 31, 0.25);
}

.category-economy {
  color: var(--brand);
}

.category-luxury {
  background-color: var(--buff);
  color: var(--brand);
}

.car-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 200ms ease;
}

.car-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.car-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.car-card-name {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
}

.car-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 14px;
  color: var(--text-secondary);
}

.car-rates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 12px;
  border-radius: 10px;
  background-color: var(--panel-bg);
}

.car-rates dt {
  font-size: 12px;
  color: var(--text-muted);
}

.car-rates dd {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 700;
}

.car-card-actions {
  margin-top: auto;
}

.car-card-actions:empty {
  display: none;
}

/* A car that cannot be booked is greyed out on every page */
.car-unavailable {
  opacity: 0.6;
}

.car-unavailable .car-photo {
  filter: grayscale(1);
}

/* Dashed box that takes the place of the Book button */
.unavailable-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  margin: 0;
  border: 1px dashed var(--border-field);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Forms ---------- */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field-wide {
  grid-column: 1 / -1;
}

.form-field label {
  font-size: 13px;
  font-weight: 600;
}

.form-field input,
.form-field select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--border-field);
  border-radius: 8px;
  background-color: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

/* A drop down: the browser arrow is replaced by a chevron (an inline image, not a file). It sits 12px from the right edge, like the calendar icon on the date fields, and the text keeps clear of it */
.form-field select {
  padding: 0 44px 0 10px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%234F4F4F' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-origin: border-box;
  background-position: right 12px center;
  background-size: 20px 20px;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.form-field textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px;
  border: 1px solid var(--border-field);
  border-radius: 8px;
  background-color: var(--white);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.form-field input:focus-visible,
.form-field select:focus-visible,
.form-field textarea:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 79, 70, 0.3);
}

input.input-error,
select.input-error,
textarea.input-error {
  border: 2px solid var(--error);
}

/* Error text under a field */
.field-error {
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
}

.field-error:empty {
  display: none;
}

.form-fieldset {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
}

.form-fieldset legend {
  margin-bottom: 10px;
  padding: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* The panel holding the form on both login pages */
.form-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 420px;
  margin: 0 auto 72px;
  padding: 28px;
  border: 1px solid var(--border-card);
  border-radius: 16px;
  background-color: var(--white);
}

.form-panel h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.form-panel .button-primary {
  width: 100%;
}

/* Cost summary panel inside the booking dialog */
.cost-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 10px;
  background-color: var(--panel-bg);
}

.cost-panel-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 15px;
}

.cost-panel-note {
  font-size: 13px;
  color: var(--text-secondary);
}

/* ---------- Messages ---------- */
.page-message {
  margin-bottom: 20px;
  padding: 14px 18px;
  border: 1px solid var(--error);
  border-radius: 12px;
  background-color: var(--white);
  color: var(--error);
  font-size: 15px;
  font-weight: 600;
  animation: banner-rise 200ms ease;
}

.confirmation-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px 20px;
  border-radius: 12px;
  background-color: #E3F4EA;
  color: #14633A;
  font-size: 15px;
  font-weight: 600;
  animation: banner-rise 200ms ease;
}

.confirmation-banner a {
  color: #14633A;
  font-weight: 700;
  transition: color 150ms ease;
}

@media (hover: hover) {
  .confirmation-banner a:hover {
    color: var(--error);
  }
}

@keyframes banner-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Page changes ---------- */
/* Browsers that support it crossfade between pages. The header keeps its place while the rest fades */
@view-transition {
  navigation: auto;
}

#site-header {
  view-transition-name: site-header;
}

::view-transition-group(root) {
  animation-duration: 250ms;
}

/* Every browser: the content of a new page fades in and rises a little */
main {
  animation: banner-rise 250ms ease both;
}

/* ---------- Record cards (bookings, car status, inspection) ---------- */
.record-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.record-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--border-card);
  border-radius: 16px;
  background-color: var(--white);
}

.record-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.record-card-head h2,
.record-card-head h3 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
}

.record-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 0;
}

.record-details dt {
  font-size: 12px;
  color: var(--text-muted);
}

.record-details dd {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.record-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.record-card-actions .button {
  flex: 1 1 160px;
}

/* ---------- Dialogs ---------- */
dialog {
  width: calc(100% - 32px); /* A dialog shrinks to its content without this, and keeps a 16px gap on a phone */
  max-width: 560px;
  padding: 28px;
  border: none;
  border-radius: 16px;
  background-color: #FFFFFF;
  color: var(--text);
}

dialog.dialog-small {
  max-width: 420px;
}

dialog[open] {
  animation: dialog-rise 200ms ease;
}

dialog::backdrop {
  background-color: rgba(0, 35, 31, 0.6);
  animation: backdrop-fade 200ms ease;
}

@keyframes dialog-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes backdrop-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* The layout goes on a form or div inside the dialog, never on the dialog itself */
.dialog-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dialog-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}

.dialog-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dialog-close {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background-color: var(--close-bg);
  color: var(--text);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

/* ---------- Text link ---------- */
.text-link {
  color: var(--text);
  transition: color 150ms ease;
}

/* A short line of help under a form */
.form-hint {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ---------- Hover effects (only on devices that can hover) ---------- */
@media (hover: hover) {
  .button-primary:not(:disabled):hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 79, 70, 0.3);
  }

  .button-secondary:not(:disabled):hover {
    background-color: var(--text);
    color: var(--white);
  }

  .car-card:not(.car-unavailable):hover {
    transform: translateY(-4px);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.12);
  }

  .car-card:not(.car-unavailable):hover .car-photo img {
    transform: scale(1.03);
  }

  .header-nav a:hover {
    color: var(--buff);
  }

  .header-menu-button:hover {
    background-color: rgba(255, 255, 255, 0.12);
  }

  .header-action:hover {
    background-color: var(--buff-hover);
  }

  .header-action:hover svg {
    transform: translateX(3px);
  }

  .dialog-close:hover {
    background-color: var(--text);
    color: var(--white);
  }

  .text-link:hover {
    color: var(--error);
  }

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

  .form-field input:hover,
  .form-field select:hover,
  .form-field textarea:hover {
    border-color: var(--text);
  }
}

.button:not(:disabled):active {
  transform: translateY(0);
}

.button-primary:active {
  box-shadow: none;
}

/* ---------- Focus ---------- */
a:focus-visible,
button:focus-visible,
dialog:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.header-pill a:focus-visible,
.header-pill button:focus-visible,
.site-footer a:focus-visible {
  outline-color: var(--buff);
}

/* ---------- Laptop ---------- */
@media (min-width: 768px) {
  .header-pill {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 20px;
    padding: 8px 8px 8px 24px;
  }

  .header-logo {
    justify-self: auto;
  }

  .header-menu-button {
    display: none;
  }

  /* The menu is always open on a laptop, and its children sit in the pill's row */
  .header-menu,
  .header-pill.menu-open .header-menu {
    display: contents;
    animation: none;
  }

  .header-nav {
    flex-direction: row;
    gap: 4px;
  }

  .header-nav a {
    padding: 0 12px;
  }

  .header-action {
    width: auto;
  }

  .record-card-actions .button {
    flex: 0 0 auto;
  }

  /* The sticky rule goes on #site-header itself, because a sticky element cannot leave its parent */
  #site-header {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .car-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* !important is needed: a class such as .button-primary beats *, and * does not match ::backdrop */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  ::backdrop {
    transition: none !important;
    animation: none !important;
  }

  /* Separate rule: a browser that does not know these selectors would drop a rule that lists them with the others */
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}
