/*
 * Food Drawing section: the colouring band. Ported from the source site's
 * food-drawing styles; colours, type and buttons come from the child tokens
 * and the kit's .button. The swatch colours are data (data-color and an
 * inline --swatch), never written here.
 */

body.drawing-locked {
  overflow: hidden;
  touch-action: none;
}

body.using-eraser .food-drawing-section canvas {
  cursor: cell;
}

.section-food-drawing {
  position: relative;
  isolation: isolate;
  background-color: var(--white);
}

/* The first child of the section, outside .container: covers the whole box, padding included. */
.food-drawing__background {
  position: absolute;
  inset: 0;
  z-index: -1;
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
}

.food-drawing-section {
  font-family: var(--font-family);
  color: var(--black);
}

.food-drawing-section .drawing-header {
  margin-bottom: 2rem;
  text-align: center;
}

.food-drawing-section .drawing-header .headline {
  margin: 0;
  text-align: center;
}

.food-drawing-section .drawing-header p {
  margin: 1rem 0 0;
}

.food-drawing-section .drawing-grid {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 3rem;
}

.food-drawing-section .drawing-canvas-container {
  position: relative;
  width: 100%;
  height: 31.25rem;
  border: none;
  color: var(--black);
}

.food-drawing-section .drawing-canvas-container svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.food-drawing-section .drawing-canvas-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.food-drawing-section .color-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
}

.food-drawing-section .color-swatch {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--swatch);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.food-drawing-section .color-swatch:hover,
.food-drawing-section .color-swatch:focus-visible {
  transform: scale(1.2);
}

.food-drawing-section .eraser {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--black);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.food-drawing-section .eraser svg {
  width: 100%;
  height: auto;
}

.food-drawing-section .eraser:hover,
.food-drawing-section .eraser:focus-visible {
  transform: scale(1.2);
}

/* A text control, as on the source site; not a kit button. */
.food-drawing-section .reset-canvas {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--black);
  font-family: inherit;
  font-size: var(--button--font-size--sm);
  font-weight: var(--font-weight--bold);
  text-decoration: underline;
  cursor: pointer;
}

/* Wins over .mobile-only below: food-drawing.js hides #exit-drawing-mobile with it. */
.food-drawing-section .hidden,
.food-drawing-section .mobile-only.hidden {
  display: none !important;
}

.food-drawing-section .mobile-start-drawing {
  display: none;
}

.food-drawing-section .mobile-only {
  display: none !important;
}

@media only screen and (min-width: 768px) {
  .food-drawing-section .exit-drawing-wrapper {
    position: absolute;
    top: 1.25rem;
    right: 2.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 1rem;
  }

  .food-drawing-section #exit-drawing {
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
  }

  .food-drawing-section .exit-popup {
    max-width: 17rem;
    margin-bottom: 0.5rem;
    padding: 1.25rem;
    border-radius: var(--border-radius--md);
    background: var(--primary);
    color: var(--white);
    font-size: 0.875rem;
    font-weight: var(--font-weight--bold);
    line-height: 1.4;
    text-align: center;
  }
}

@media only screen and (max-width: 767px) {
  .section-food-drawing {
    padding-bottom: 0;
  }

  .food-drawing-section .drawing-grid {
    flex-direction: column-reverse;
    margin-bottom: 2rem;
  }

  .food-drawing-section .drawing-canvas-container {
    height: 18.75rem;
  }

  .food-drawing-section .color-picker,
  .food-drawing-section .exit-drawing-wrapper {
    display: none;
  }

  .food-drawing-section.drawing-mode .color-picker,
  .food-drawing-section.drawing-mode .exit-drawing-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
  }

  .food-drawing-section.drawing-mode .color-picker {
    padding: 1.25rem;
    border-radius: var(--border-radius--lg) var(--border-radius--lg) 0 0;
    background: var(--white);
  }

  .food-drawing-section .exit-popup,
  .food-drawing-section .desktop-only {
    display: none;
  }

  .food-drawing-section .mobile-only {
    display: inline-flex !important;
  }

  .food-drawing-section .mobile-start-drawing-container {
    position: sticky;
    bottom: 0;
    z-index: 10;
    padding: 1.25rem;
    border-radius: var(--border-radius--lg) var(--border-radius--lg) 0 0;
    background: var(--white);
  }

  .food-drawing-section .mobile-start-drawing {
    display: flex;
    width: 100%;
  }

  .food-drawing-section.drawing-mode .mobile-start-drawing {
    display: none;
  }
}
