/* responsive.css - tablet, phone, landscape and touch layouts (load this LAST) */

body {
  overscroll-behavior: none
}

@supports (height:100dvh) {
  body {
    height: 100dvh
  }
}

@media(max-width:900px) {
  .brand small {
    display: none
  }
}

/* ---------- tablets ---------- */
@media(max-width:820px) {
  .app {
    grid-template-columns: 84px 1fr 76px;
    grid-template-rows: 1fr 116px
  }

  .group {
    grid-template-columns: repeat(2, 34px)
  }

  .tool {
    width: 34px;
    height: 34px
  }

  .act {
    width: 48px;
    height: 48px
  }
}

/* ---------- phones in portrait: tools and actions become scrolling strips ---------- */
@media(max-width:600px) and (orientation:portrait) {
  .topbar {
    height: 56px;
    padding: 0 10px;
    gap: 6px
  }

  .brand img {
    height: 40px
  }

  .menus {
    margin-left: 2px;
    gap: 4px
  }

  .nbtn {
    padding: 4px 10px;
    font-size: 12px
  }

  .name-wrap {
    display: none
  }

  /* the name is set in Save as... */

  /* menus open as a full-width sheet so they never run off the screen */
  .dd-panel {
    position: fixed;
    left: 8px;
    right: 8px;
    top: 60px;
    min-width: 0;
    max-height: calc(100vh - 80px);
    max-height: calc(100dvh - 80px);
    overflow-y: auto
  }

  .actionbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 10px
  }

  .save-lbl {
    display: none
  }

  .save {
    padding: 7px 12px
  }

  .textbar {
    order: 9;
    width: 100%;
    justify-content: center;
    border-radius: 14px;
    overflow-x: auto
  }

  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto auto;
    grid-template-areas: "stage" "left" "right" "bottom"
  }

  .coords {
    font-size: 11px;
    left: 8px;
    bottom: 6px
  }

  /* tools: one scrolling row, with a fade at the edge to hint there is more */
  .left {
    display: flex;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-top: 3px solid var(--ink);
    padding: 6px 32px 8px 10px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent)
  }

  .group {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    justify-content: flex-start
  }

  .tool {
    flex: none;
    width: 42px;
    height: 42px
  }

  .left .rule {
    flex: none;
    width: 0;
    height: 30px;
    border-top: none;
    border-left: 2px dashed var(--lime-deep);
    margin: 0 10px
  }

  /* actions: one row */
  .right {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    border-left: none;
    border-top: 3px solid var(--ink);
    padding: 6px 10px;
    gap: 8px;
    scrollbar-width: none
  }

  .right .rule {
    width: 0;
    height: 28px;
    margin: 0 4px;
    border-top: none;
    border-left: 2px dashed var(--lime-deep)
  }

  .act {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    box-shadow: 0 2px 0 var(--ink)
  }

  .act svg {
    width: 24px;
    height: 24px
  }

  /* colours and brush sizes: compact, scrolls sideways */
  .bottom {
    gap: 14px;
    padding: 8px 32px calc(8px + env(safe-area-inset-bottom, 0px)) 12px;
    border-top: 3px solid var(--ink);
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent)
  }

  .slots {
    gap: 8px
  }

  .slot {
    width: 118px;
    height: 34px;
    padding: 0 6px 0 10px;
    font-size: 13px;
    gap: 8px
  }

  .palette {
    grid-template-columns: repeat(9, 30px);
    grid-template-rows: 30px 30px;
    gap: 8px
  }

  .sw {
    width: 30px;
    height: 30px
  }

  .sw.none::after {
    top: -3px;
    height: 36px
  }

  .vr {
    margin: 10px 0
  }

  .size {
    width: 40px;
    height: 40px;
    border-radius: 12px
  }
}

.left::-webkit-scrollbar,
.right::-webkit-scrollbar,
.bottom::-webkit-scrollbar {
  display: none
}

/* ---------- touch screens: handles are always visible and bigger ---------- */
@media(pointer:coarse) {
  .page-h {
    opacity: 1;
    transform: scale(1.8)
  }

  .text-h,
  .shape-rot {
    transform: scale(1.6)
  }

  .ibtn {
    width: 38px;
    height: 38px
  }

  .zoomval {
    min-height: 38px
  }

  .tbtn {
    width: 36px;
    height: 36px
  }

  .textbar select,
  .sv-box select,
  .sv-box input {
    font-size: 16px
  }
}

/* ---------- short landscape (phones on their side) ---------- */
@media(max-height:520px) and (orientation:landscape) {
  .topbar {
    height: 48px
  }

  .brand img {
    height: 36px
  }

  .actionbar {
    padding: 4px 12px;
    gap: 8px
  }

  .ibtn {
    width: 36px;
    height: 36px
  }

  .app {
    grid-template-columns: 84px 1fr 66px;
    grid-template-rows: minmax(0, 1fr) 88px
  }

  .group {
    grid-template-columns: repeat(2, 34px);
    gap: 8px
  }

  .tool {
    width: 34px;
    height: 34px
  }

  .act {
    width: 46px;
    height: 46px
  }

  .bottom {
    gap: 14px;
    padding: 0 14px
  }

  .slots {
    gap: 6px
  }

  .slot {
    width: 120px;
    height: 34px;
    font-size: 13px
  }

  .palette {
    grid-template-columns: repeat(9, 28px);
    grid-template-rows: 28px 28px;
    gap: 8px
  }

  .sw {
    width: 28px;
    height: 28px
  }

  .size {
    width: 40px;
    height: 40px
  }
}

@media (prefers-reduced-motion:reduce) {
  * {
    animation: none !important;
    transition: none !important
  }
}

/* more space left and right of the tool buttons (not on portrait phones, which use strips) */
@media(min-width:601px), (orientation:landscape) {
  .app {
    grid-template-columns: 132px 1fr 92px
  }

  .left {
    padding: 14px 16px;
    scrollbar-gutter: stable
  }

  .group {
    gap: 12px
  }
}